Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch components.sensor.zha to await syntax. #16619

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions homeassistant/components/sensor/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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
Expand All @@ -17,20 +16,18 @@
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,
Expand All @@ -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
)
Expand Down