From 0d0bda9658616d955bc410bf3d3eee30189b9395 Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Fri, 14 Sep 2018 15:29:10 -0400 Subject: [PATCH] Switch components.sensor.zha to await syntax. (#16619) --- homeassistant/components/sensor/zha.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/sensor/zha.py b/homeassistant/components/sensor/zha.py index 9962270dfd7..0d5b40d1d98 100644 --- a/homeassistant/components/sensor/zha.py +++ b/homeassistant/components/sensor/zha.py @@ -4,7 +4,6 @@ Sensors on Zigbee Home Automation networks. For more details on this platform, please refer to the documentation at https://home-assistant.io/components/sensor.zha/ """ -import asyncio import logging from homeassistant.components.sensor import DOMAIN @@ -17,20 +16,18 @@ _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['zha'] -@asyncio.coroutine -def async_setup_platform(hass, config, async_add_entities, - discovery_info=None): +async def async_setup_platform(hass, config, async_add_entities, + discovery_info=None): """Set up Zigbee Home Automation sensors.""" discovery_info = zha.get_discovery_info(hass, discovery_info) if discovery_info is None: return - sensor = yield from make_sensor(discovery_info) + sensor = await make_sensor(discovery_info) async_add_entities([sensor], update_before_add=True) -@asyncio.coroutine -def make_sensor(discovery_info): +async def make_sensor(discovery_info): """Create ZHA sensors factory.""" from zigpy.zcl.clusters.measurement import ( RelativeHumidity, TemperatureMeasurement, PressureMeasurement, @@ -57,7 +54,7 @@ def make_sensor(discovery_info): if discovery_info['new_join']: cluster = list(in_clusters.values())[0] - yield from zha.configure_reporting( + await zha.configure_reporting( sensor.entity_id, cluster, sensor.value_attribute, reportable_change=sensor.min_reportable_change )