diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index c5110a2ad5a..a42e6e880b5 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -4,7 +4,6 @@ Component to interface with an alarm control panel. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel/ """ -import asyncio from datetime import timedelta import logging @@ -31,13 +30,12 @@ ALARM_SERVICE_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_setup(hass, config): +async def async_setup(hass, config): """Track states and offer events for sensors.""" component = hass.data[DOMAIN] = EntityComponent( logging.getLogger(__name__), DOMAIN, hass, SCAN_INTERVAL) - yield from component.async_setup(config) + await component.async_setup(config) component.async_register_entity_service( SERVICE_ALARM_DISARM, ALARM_SERVICE_SCHEMA, diff --git a/homeassistant/components/alarm_control_panel/alarmdecoder.py b/homeassistant/components/alarm_control_panel/alarmdecoder.py index 5606209d1e6..25496dff0eb 100644 --- a/homeassistant/components/alarm_control_panel/alarmdecoder.py +++ b/homeassistant/components/alarm_control_panel/alarmdecoder.py @@ -4,7 +4,6 @@ Support for AlarmDecoder-based alarm control panels (Honeywell/DSC). For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.alarmdecoder/ """ -import asyncio import logging import voluptuous as vol @@ -59,8 +58,7 @@ class AlarmDecoderAlarmPanel(alarm.AlarmControlPanel): self._ready = None self._zone_bypassed = None - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" self.hass.helpers.dispatcher.async_dispatcher_connect( SIGNAL_PANEL_MESSAGE, self._message_callback) diff --git a/homeassistant/components/alarm_control_panel/alarmdotcom.py b/homeassistant/components/alarm_control_panel/alarmdotcom.py index 98766deb3b6..9b07dc41690 100644 --- a/homeassistant/components/alarm_control_panel/alarmdotcom.py +++ b/homeassistant/components/alarm_control_panel/alarmdotcom.py @@ -4,7 +4,6 @@ Interfaces with Alarm.com alarm control panels. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.alarmdotcom/ """ -import asyncio import logging import re @@ -32,9 +31,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -@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 a Alarm.com control panel.""" name = config.get(CONF_NAME) code = config.get(CONF_CODE) @@ -42,7 +40,7 @@ def async_setup_platform(hass, config, async_add_entities, password = config.get(CONF_PASSWORD) alarmdotcom = AlarmDotCom(hass, name, code, username, password) - yield from alarmdotcom.async_login() + await alarmdotcom.async_login() async_add_entities([alarmdotcom]) @@ -63,15 +61,13 @@ class AlarmDotCom(alarm.AlarmControlPanel): self._alarm = Alarmdotcom( username, password, self._websession, hass.loop) - @asyncio.coroutine - def async_login(self): + async def async_login(self): """Login to Alarm.com.""" - yield from self._alarm.async_login() + await self._alarm.async_login() - @asyncio.coroutine - def async_update(self): + async def async_update(self): """Fetch the latest state.""" - yield from self._alarm.async_update() + await self._alarm.async_update() return self._alarm.state @property @@ -106,23 +102,20 @@ class AlarmDotCom(alarm.AlarmControlPanel): 'sensor_status': self._alarm.sensor_status } - @asyncio.coroutine - def async_alarm_disarm(self, code=None): + async def async_alarm_disarm(self, code=None): """Send disarm command.""" if self._validate_code(code): - yield from self._alarm.async_alarm_disarm() + await self._alarm.async_alarm_disarm() - @asyncio.coroutine - def async_alarm_arm_home(self, code=None): + async def async_alarm_arm_home(self, code=None): """Send arm hom command.""" if self._validate_code(code): - yield from self._alarm.async_alarm_arm_home() + await self._alarm.async_alarm_arm_home() - @asyncio.coroutine - def async_alarm_arm_away(self, code=None): + async def async_alarm_arm_away(self, code=None): """Send arm away command.""" if self._validate_code(code): - yield from self._alarm.async_alarm_arm_away() + await self._alarm.async_alarm_arm_away() def _validate_code(self, code): """Validate given code.""" diff --git a/homeassistant/components/alarm_control_panel/egardia.py b/homeassistant/components/alarm_control_panel/egardia.py index 4e278c10e07..dfd60c4abde 100644 --- a/homeassistant/components/alarm_control_panel/egardia.py +++ b/homeassistant/components/alarm_control_panel/egardia.py @@ -4,7 +4,6 @@ Interfaces with Egardia/Woonveilig alarm control panel. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.egardia/ """ -import asyncio import logging import requests @@ -61,8 +60,7 @@ class EgardiaAlarm(alarm.AlarmControlPanel): self._rs_codes = rs_codes self._rs_port = rs_port - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Add Egardiaserver callback if enabled.""" if self._rs_enabled: _LOGGER.debug("Registering callback to Egardiaserver") diff --git a/homeassistant/components/alarm_control_panel/envisalink.py b/homeassistant/components/alarm_control_panel/envisalink.py index df91884b32c..f0f3d2a43f7 100644 --- a/homeassistant/components/alarm_control_panel/envisalink.py +++ b/homeassistant/components/alarm_control_panel/envisalink.py @@ -4,7 +4,6 @@ Support for Envisalink-based alarm control panels (Honeywell/DSC). For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.envisalink/ """ -import asyncio import logging import voluptuous as vol @@ -32,9 +31,8 @@ ALARM_KEYPRESS_SCHEMA = vol.Schema({ }) -@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): """Perform the setup for Envisalink alarm panels.""" configured_partitions = discovery_info['partitions'] code = discovery_info[CONF_CODE] @@ -88,8 +86,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel): _LOGGER.debug("Setting up alarm: %s", alarm_name) super().__init__(alarm_name, info, controller) - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" async_dispatcher_connect( self.hass, SIGNAL_KEYPAD_UPDATE, self._update_callback) @@ -128,8 +125,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel): state = STATE_ALARM_DISARMED return state - @asyncio.coroutine - def async_alarm_disarm(self, code=None): + async def async_alarm_disarm(self, code=None): """Send disarm command.""" if code: self.hass.data[DATA_EVL].disarm_partition( @@ -138,8 +134,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel): self.hass.data[DATA_EVL].disarm_partition( str(self._code), self._partition_number) - @asyncio.coroutine - def async_alarm_arm_home(self, code=None): + async def async_alarm_arm_home(self, code=None): """Send arm home command.""" if code: self.hass.data[DATA_EVL].arm_stay_partition( @@ -148,8 +143,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel): self.hass.data[DATA_EVL].arm_stay_partition( str(self._code), self._partition_number) - @asyncio.coroutine - def async_alarm_arm_away(self, code=None): + async def async_alarm_arm_away(self, code=None): """Send arm away command.""" if code: self.hass.data[DATA_EVL].arm_away_partition( @@ -158,8 +152,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel): self.hass.data[DATA_EVL].arm_away_partition( str(self._code), self._partition_number) - @asyncio.coroutine - def async_alarm_trigger(self, code=None): + async def async_alarm_trigger(self, code=None): """Alarm trigger command. Will be used to trigger a panic alarm.""" self.hass.data[DATA_EVL].panic_alarm(self._panic_type) diff --git a/homeassistant/components/alarm_control_panel/manual_mqtt.py b/homeassistant/components/alarm_control_panel/manual_mqtt.py index 7bf9443424c..834a502baa0 100644 --- a/homeassistant/components/alarm_control_panel/manual_mqtt.py +++ b/homeassistant/components/alarm_control_panel/manual_mqtt.py @@ -4,7 +4,6 @@ Support for manual alarms controllable via MQTT. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.manual_mqtt/ """ -import asyncio import copy import datetime import logging @@ -363,8 +362,8 @@ class ManualMQTTAlarm(alarm.AlarmControlPanel): return mqtt.async_subscribe( self.hass, self._command_topic, message_received, self._qos) - @asyncio.coroutine - def _async_state_changed_listener(self, entity_id, old_state, new_state): + async def _async_state_changed_listener(self, entity_id, old_state, + new_state): """Publish state change to MQTT.""" mqtt.async_publish( self.hass, self._state_topic, new_state.state, self._qos, True) diff --git a/homeassistant/components/alarm_control_panel/mqtt.py b/homeassistant/components/alarm_control_panel/mqtt.py index d8193f958da..ad1c0d1e3b8 100644 --- a/homeassistant/components/alarm_control_panel/mqtt.py +++ b/homeassistant/components/alarm_control_panel/mqtt.py @@ -4,7 +4,6 @@ This platform enables the possibility to control a MQTT alarm. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.mqtt/ """ -import asyncio import logging import re @@ -111,11 +110,10 @@ class MqttAlarm(MqttAvailability, MqttDiscoveryUpdate, self._code = code self._discovery_hash = discovery_hash - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Subscribe mqtt events.""" - yield from MqttAvailability.async_added_to_hass(self) - yield from MqttDiscoveryUpdate.async_added_to_hass(self) + await MqttAvailability.async_added_to_hass(self) + await MqttDiscoveryUpdate.async_added_to_hass(self) @callback def message_received(topic, payload, qos): @@ -128,7 +126,7 @@ class MqttAlarm(MqttAvailability, MqttDiscoveryUpdate, self._state = payload self.async_schedule_update_ha_state() - yield from mqtt.async_subscribe( + await mqtt.async_subscribe( self.hass, self._state_topic, message_received, self._qos) @property @@ -155,8 +153,7 @@ class MqttAlarm(MqttAvailability, MqttDiscoveryUpdate, return 'Number' return 'Any' - @asyncio.coroutine - def async_alarm_disarm(self, code=None): + async def async_alarm_disarm(self, code=None): """Send disarm command. This method is a coroutine. @@ -167,8 +164,7 @@ class MqttAlarm(MqttAvailability, MqttDiscoveryUpdate, self.hass, self._command_topic, self._payload_disarm, self._qos, self._retain) - @asyncio.coroutine - def async_alarm_arm_home(self, code=None): + async def async_alarm_arm_home(self, code=None): """Send arm home command. This method is a coroutine. @@ -179,8 +175,7 @@ class MqttAlarm(MqttAvailability, MqttDiscoveryUpdate, self.hass, self._command_topic, self._payload_arm_home, self._qos, self._retain) - @asyncio.coroutine - def async_alarm_arm_away(self, code=None): + async def async_alarm_arm_away(self, code=None): """Send arm away command. This method is a coroutine. diff --git a/homeassistant/components/alarm_control_panel/satel_integra.py b/homeassistant/components/alarm_control_panel/satel_integra.py index 86603763396..c4e42855d8a 100644 --- a/homeassistant/components/alarm_control_panel/satel_integra.py +++ b/homeassistant/components/alarm_control_panel/satel_integra.py @@ -4,7 +4,6 @@ Support for Satel Integra alarm, using ETHM module: https://www.satel.pl/en/ . For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.satel_integra/ """ -import asyncio import logging import homeassistant.components.alarm_control_panel as alarm @@ -18,9 +17,8 @@ _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['satel_integra'] -@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 for Satel Integra alarm panels.""" if not discovery_info: return @@ -39,8 +37,7 @@ class SatelIntegraAlarmPanel(alarm.AlarmControlPanel): self._state = None self._arm_home_mode = arm_home_mode - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" async_dispatcher_connect( self.hass, SIGNAL_PANEL_MESSAGE, self._message_callback) @@ -74,21 +71,18 @@ class SatelIntegraAlarmPanel(alarm.AlarmControlPanel): """Return the state of the device.""" return self._state - @asyncio.coroutine - def async_alarm_disarm(self, code=None): + async def async_alarm_disarm(self, code=None): """Send disarm command.""" if code: - yield from self.hass.data[DATA_SATEL].disarm(code) + await self.hass.data[DATA_SATEL].disarm(code) - @asyncio.coroutine - def async_alarm_arm_away(self, code=None): + async def async_alarm_arm_away(self, code=None): """Send arm away command.""" if code: - yield from self.hass.data[DATA_SATEL].arm(code) + await self.hass.data[DATA_SATEL].arm(code) - @asyncio.coroutine - def async_alarm_arm_home(self, code=None): + async def async_alarm_arm_home(self, code=None): """Send arm home command.""" if code: - yield from self.hass.data[DATA_SATEL].arm( + await self.hass.data[DATA_SATEL].arm( code, self._arm_home_mode) diff --git a/homeassistant/components/alarm_control_panel/wink.py b/homeassistant/components/alarm_control_panel/wink.py index d75fad30c96..001c6fad85c 100644 --- a/homeassistant/components/alarm_control_panel/wink.py +++ b/homeassistant/components/alarm_control_panel/wink.py @@ -4,7 +4,6 @@ Interfaces with Wink Cameras. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/alarm_control_panel.wink/ """ -import asyncio import logging import homeassistant.components.alarm_control_panel as alarm @@ -38,8 +37,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): class WinkCameraDevice(WinkDevice, alarm.AlarmControlPanel): """Representation a Wink camera alarm.""" - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Call when entity is added to hass.""" self.hass.data[DOMAIN]['entities']['alarm_control_panel'].append(self) diff --git a/homeassistant/components/automation/event.py b/homeassistant/components/automation/event.py index e19a85edae6..a9605f343fd 100644 --- a/homeassistant/components/automation/event.py +++ b/homeassistant/components/automation/event.py @@ -4,7 +4,6 @@ Offer event listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#event-trigger """ -import asyncio import logging import voluptuous as vol @@ -25,8 +24,7 @@ TRIGGER_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for events based on configuration.""" event_type = config.get(CONF_EVENT_TYPE) event_data_schema = vol.Schema( diff --git a/homeassistant/components/automation/homeassistant.py b/homeassistant/components/automation/homeassistant.py index b55d99f706a..30ab979d6f4 100644 --- a/homeassistant/components/automation/homeassistant.py +++ b/homeassistant/components/automation/homeassistant.py @@ -4,7 +4,6 @@ Offer Home Assistant core automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/components/automation/#homeassistant-trigger """ -import asyncio import logging import voluptuous as vol @@ -23,8 +22,7 @@ TRIGGER_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for events based on configuration.""" event = config.get(CONF_EVENT) diff --git a/homeassistant/components/automation/litejet.py b/homeassistant/components/automation/litejet.py index c827fe8f7a4..c0d2dd99ba2 100644 --- a/homeassistant/components/automation/litejet.py +++ b/homeassistant/components/automation/litejet.py @@ -4,7 +4,6 @@ Trigger an automation when a LiteJet switch is released. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/automation.litejet/ """ -import asyncio import logging import voluptuous as vol @@ -33,8 +32,7 @@ TRIGGER_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for events based on configuration.""" number = config.get(CONF_NUMBER) held_more_than = config.get(CONF_HELD_MORE_THAN) diff --git a/homeassistant/components/automation/mqtt.py b/homeassistant/components/automation/mqtt.py index 60c33ca9b0e..99d5ab8674c 100644 --- a/homeassistant/components/automation/mqtt.py +++ b/homeassistant/components/automation/mqtt.py @@ -4,7 +4,6 @@ Offer MQTT listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#mqtt-trigger """ -import asyncio import json import voluptuous as vol @@ -25,8 +24,7 @@ TRIGGER_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" topic = config.get(CONF_TOPIC) payload = config.get(CONF_PAYLOAD) @@ -51,6 +49,6 @@ def async_trigger(hass, config, action): 'trigger': data }) - remove = yield from mqtt.async_subscribe( + remove = await mqtt.async_subscribe( hass, topic, mqtt_automation_listener) return remove diff --git a/homeassistant/components/automation/numeric_state.py b/homeassistant/components/automation/numeric_state.py index f0dcbf0be57..675b6f3653a 100644 --- a/homeassistant/components/automation/numeric_state.py +++ b/homeassistant/components/automation/numeric_state.py @@ -4,7 +4,6 @@ Offer numeric state listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#numeric-state-trigger """ -import asyncio import logging import voluptuous as vol @@ -29,8 +28,7 @@ TRIGGER_SCHEMA = vol.All(vol.Schema({ _LOGGER = logging.getLogger(__name__) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" entity_id = config.get(CONF_ENTITY_ID) below = config.get(CONF_BELOW) diff --git a/homeassistant/components/automation/state.py b/homeassistant/components/automation/state.py index 263d4158e25..46c5cafa071 100644 --- a/homeassistant/components/automation/state.py +++ b/homeassistant/components/automation/state.py @@ -4,7 +4,6 @@ Offer state listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#state-trigger """ -import asyncio import voluptuous as vol from homeassistant.core import callback @@ -27,8 +26,7 @@ TRIGGER_SCHEMA = vol.All(vol.Schema({ }), cv.key_dependency(CONF_FOR, CONF_TO)) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" entity_id = config.get(CONF_ENTITY_ID) from_state = config.get(CONF_FROM, MATCH_ALL) diff --git a/homeassistant/components/automation/sun.py b/homeassistant/components/automation/sun.py index 497b8453267..7cefe6953a1 100644 --- a/homeassistant/components/automation/sun.py +++ b/homeassistant/components/automation/sun.py @@ -4,7 +4,6 @@ Offer sun based automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#sun-trigger """ -import asyncio from datetime import timedelta import logging @@ -25,8 +24,7 @@ TRIGGER_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for events based on configuration.""" event = config.get(CONF_EVENT) offset = config.get(CONF_OFFSET) diff --git a/homeassistant/components/automation/template.py b/homeassistant/components/automation/template.py index 67a44f1a347..c0d83b1067f 100644 --- a/homeassistant/components/automation/template.py +++ b/homeassistant/components/automation/template.py @@ -4,7 +4,6 @@ Offer template automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#template-trigger """ -import asyncio import logging import voluptuous as vol @@ -23,8 +22,7 @@ TRIGGER_SCHEMA = IF_ACTION_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" value_template = config.get(CONF_VALUE_TEMPLATE) value_template.hass = hass diff --git a/homeassistant/components/automation/time.py b/homeassistant/components/automation/time.py index a3a8496c3c5..eccc31581a0 100644 --- a/homeassistant/components/automation/time.py +++ b/homeassistant/components/automation/time.py @@ -4,7 +4,6 @@ Offer time listening automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#time-trigger """ -import asyncio import logging import voluptuous as vol @@ -29,8 +28,7 @@ TRIGGER_SCHEMA = vol.All(vol.Schema({ }), cv.has_at_least_one_key(CONF_HOURS, CONF_MINUTES, CONF_SECONDS, CONF_AT)) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" if CONF_AT in config: at_time = config.get(CONF_AT) diff --git a/homeassistant/components/automation/zone.py b/homeassistant/components/automation/zone.py index f30dfe753cb..dfc9cc418bf 100644 --- a/homeassistant/components/automation/zone.py +++ b/homeassistant/components/automation/zone.py @@ -4,7 +4,6 @@ Offer zone automation rules. For more details about this automation rule, please refer to the documentation at https://home-assistant.io/docs/automation/trigger/#zone-trigger """ -import asyncio import voluptuous as vol from homeassistant.core import callback @@ -27,8 +26,7 @@ TRIGGER_SCHEMA = vol.Schema({ }) -@asyncio.coroutine -def async_trigger(hass, config, action): +async def async_trigger(hass, config, action): """Listen for state changes based on configuration.""" entity_id = config.get(CONF_ENTITY_ID) zone_entity_id = config.get(CONF_ZONE) diff --git a/homeassistant/components/binary_sensor/ads.py b/homeassistant/components/binary_sensor/ads.py index d46ff5ec2ee..1ee56cac9d3 100644 --- a/homeassistant/components/binary_sensor/ads.py +++ b/homeassistant/components/binary_sensor/ads.py @@ -4,7 +4,6 @@ Support for ADS binary sensors. For more details about this platform, please refer to the documentation. https://home-assistant.io/components/binary_sensor.ads/ """ -import asyncio import logging import voluptuous as vol @@ -50,8 +49,7 @@ class AdsBinarySensor(BinarySensorDevice): self._ads_hub = ads_hub self.ads_var = ads_var - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register device notification.""" def update(name, value): """Handle device notifications.""" diff --git a/homeassistant/components/binary_sensor/alarmdecoder.py b/homeassistant/components/binary_sensor/alarmdecoder.py index 82bcc50259f..1b50d6c6c72 100644 --- a/homeassistant/components/binary_sensor/alarmdecoder.py +++ b/homeassistant/components/binary_sensor/alarmdecoder.py @@ -4,7 +4,6 @@ Support for AlarmDecoder zone states- represented as binary sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.alarmdecoder/ """ -import asyncio import logging from homeassistant.components.binary_sensor import BinarySensorDevice @@ -64,8 +63,7 @@ class AlarmDecoderBinarySensor(BinarySensorDevice): self._relay_addr = relay_addr self._relay_chan = relay_chan - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" self.hass.helpers.dispatcher.async_dispatcher_connect( SIGNAL_ZONE_FAULT, self._fault_callback) diff --git a/homeassistant/components/binary_sensor/android_ip_webcam.py b/homeassistant/components/binary_sensor/android_ip_webcam.py index 58de81c30e7..085bafd3ae3 100644 --- a/homeassistant/components/binary_sensor/android_ip_webcam.py +++ b/homeassistant/components/binary_sensor/android_ip_webcam.py @@ -4,8 +4,6 @@ Support for IP Webcam binary sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.android_ip_webcam/ """ -import asyncio - from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.android_ip_webcam import ( KEY_MAP, DATA_IP_WEBCAM, AndroidIPCamEntity, CONF_HOST, CONF_NAME) @@ -13,9 +11,8 @@ from homeassistant.components.android_ip_webcam import ( DEPENDENCIES = ['android_ip_webcam'] -@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 the IP Webcam binary sensors.""" if discovery_info is None: return @@ -51,8 +48,7 @@ class IPWebcamBinarySensor(AndroidIPCamEntity, BinarySensorDevice): """Return true if the binary sensor is on.""" return self._state - @asyncio.coroutine - def async_update(self): + async def async_update(self): """Retrieve latest state.""" state, _ = self._ipcam.export_sensor(self._sensor) self._state = state == 1.0 diff --git a/homeassistant/components/binary_sensor/bayesian.py b/homeassistant/components/binary_sensor/bayesian.py index 88669d67d80..f7802f0f29d 100644 --- a/homeassistant/components/binary_sensor/bayesian.py +++ b/homeassistant/components/binary_sensor/bayesian.py @@ -4,7 +4,6 @@ Use Bayesian Inference to trigger a binary sensor. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.bayesian/ """ -import asyncio import logging from collections import OrderedDict @@ -74,9 +73,8 @@ def update_probability(prior, prob_true, prob_false): return probability -@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 the Bayesian Binary sensor.""" name = config.get(CONF_NAME) observations = config.get(CONF_OBSERVATIONS) @@ -119,8 +117,7 @@ class BayesianBinarySensor(BinarySensorDevice): 'state': self._process_state } - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Call when entity about to be added.""" @callback def async_threshold_sensor_state_listener(entity, old_state, @@ -214,7 +211,6 @@ class BayesianBinarySensor(BinarySensorDevice): ATTR_PROBABILITY_THRESHOLD: self._probability_threshold, } - @asyncio.coroutine - def async_update(self): + async def async_update(self): """Get the latest data and update the states.""" self._deviation = bool(self.probability >= self._probability_threshold) diff --git a/homeassistant/components/binary_sensor/bmw_connected_drive.py b/homeassistant/components/binary_sensor/bmw_connected_drive.py index e3b1a941bd2..3fe8136c93b 100644 --- a/homeassistant/components/binary_sensor/bmw_connected_drive.py +++ b/homeassistant/components/binary_sensor/bmw_connected_drive.py @@ -4,7 +4,6 @@ Reads vehicle status from BMW connected drive portal. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.bmw_connected_drive/ """ -import asyncio import logging from homeassistant.components.binary_sensor import BinarySensorDevice @@ -193,8 +192,7 @@ class BMWConnectedDriveSensor(BinarySensorDevice): """Schedule a state update.""" self.schedule_update_ha_state(True) - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Add callback after being added to hass. Show latest data after startup. diff --git a/homeassistant/components/binary_sensor/egardia.py b/homeassistant/components/binary_sensor/egardia.py index 0db2cac667f..56d7dda17ba 100644 --- a/homeassistant/components/binary_sensor/egardia.py +++ b/homeassistant/components/binary_sensor/egardia.py @@ -4,7 +4,6 @@ Interfaces with Egardia/Woonveilig alarm control panel. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.egardia/ """ -import asyncio import logging from homeassistant.components.binary_sensor import BinarySensorDevice @@ -18,9 +17,8 @@ EGARDIA_TYPE_TO_DEVICE_CLASS = {'IR Sensor': 'motion', 'IR': 'motion'} -@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): """Initialize the platform.""" if (discovery_info is None or discovery_info[ATTR_DISCOVER_DEVICES] is None): diff --git a/homeassistant/components/binary_sensor/envisalink.py b/homeassistant/components/binary_sensor/envisalink.py index 2568879bcc6..276ace8dd51 100644 --- a/homeassistant/components/binary_sensor/envisalink.py +++ b/homeassistant/components/binary_sensor/envisalink.py @@ -4,7 +4,6 @@ Support for Envisalink zone states- represented as binary sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.envisalink/ """ -import asyncio import logging import datetime @@ -22,9 +21,8 @@ _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['envisalink'] -@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 the Envisalink binary sensor devices.""" configured_zones = discovery_info['zones'] @@ -56,8 +54,7 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice): _LOGGER.debug('Setting up zone: %s', zone_name) super().__init__(zone_name, info, controller) - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" async_dispatcher_connect( self.hass, SIGNAL_ZONE_UPDATE, self._update_callback) diff --git a/homeassistant/components/binary_sensor/ffmpeg_motion.py b/homeassistant/components/binary_sensor/ffmpeg_motion.py index 365bcafbd69..899d442c14e 100644 --- a/homeassistant/components/binary_sensor/ffmpeg_motion.py +++ b/homeassistant/components/binary_sensor/ffmpeg_motion.py @@ -4,7 +4,6 @@ Provides a binary sensor which is a collection of ffmpeg tools. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.ffmpeg_motion/ """ -import asyncio import logging import voluptuous as vol @@ -46,9 +45,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -@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 the FFmpeg binary motion sensor.""" manager = hass.data[DATA_FFMPEG] @@ -98,8 +96,7 @@ class FFmpegMotion(FFmpegBinarySensor): self.ffmpeg = SensorMotion( manager.binary, hass.loop, self._async_callback) - @asyncio.coroutine - def _async_start_ffmpeg(self, entity_ids): + async def _async_start_ffmpeg(self, entity_ids): """Start a FFmpeg instance. This method is a coroutine. @@ -116,7 +113,7 @@ class FFmpegMotion(FFmpegBinarySensor): ) # run - yield from self.ffmpeg.open_sensor( + await self.ffmpeg.open_sensor( input_source=self._config.get(CONF_INPUT), extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS), ) diff --git a/homeassistant/components/binary_sensor/ffmpeg_noise.py b/homeassistant/components/binary_sensor/ffmpeg_noise.py index 73c84ac336d..60eb236767a 100644 --- a/homeassistant/components/binary_sensor/ffmpeg_noise.py +++ b/homeassistant/components/binary_sensor/ffmpeg_noise.py @@ -4,7 +4,6 @@ Provides a binary sensor which is a collection of ffmpeg tools. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.ffmpeg_noise/ """ -import asyncio import logging import voluptuous as vol @@ -43,9 +42,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -@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 the FFmpeg noise binary sensor.""" manager = hass.data[DATA_FFMPEG] @@ -67,8 +65,7 @@ class FFmpegNoise(FFmpegBinarySensor): self.ffmpeg = SensorNoise( manager.binary, hass.loop, self._async_callback) - @asyncio.coroutine - def _async_start_ffmpeg(self, entity_ids): + async def _async_start_ffmpeg(self, entity_ids): """Start a FFmpeg instance. This method is a coroutine. @@ -82,7 +79,7 @@ class FFmpegNoise(FFmpegBinarySensor): peak=self._config.get(CONF_PEAK), ) - yield from self.ffmpeg.open_sensor( + await self.ffmpeg.open_sensor( input_source=self._config.get(CONF_INPUT), output_dest=self._config.get(CONF_OUTPUT), extra_cmd=self._config.get(CONF_EXTRA_ARGUMENTS), diff --git a/homeassistant/components/binary_sensor/insteon.py b/homeassistant/components/binary_sensor/insteon.py index 533ff2d76c0..c399d31a95b 100644 --- a/homeassistant/components/binary_sensor/insteon.py +++ b/homeassistant/components/binary_sensor/insteon.py @@ -4,7 +4,6 @@ Support for INSTEON dimmers via PowerLinc Modem. For more details about this component, please refer to the documentation at https://home-assistant.io/components/binary_sensor.insteon/ """ -import asyncio import logging from homeassistant.components.binary_sensor import BinarySensorDevice @@ -22,9 +21,8 @@ SENSOR_TYPES = {'openClosedSensor': 'opening', 'batterySensor': 'battery'} -@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 the INSTEON device class for the hass platform.""" insteon_modem = hass.data['insteon'].get('modem') diff --git a/homeassistant/components/binary_sensor/isy994.py b/homeassistant/components/binary_sensor/isy994.py index 36dacb06738..31a9606d950 100644 --- a/homeassistant/components/binary_sensor/isy994.py +++ b/homeassistant/components/binary_sensor/isy994.py @@ -4,8 +4,6 @@ Support for ISY994 binary sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.isy994/ """ - -import asyncio import logging from datetime import timedelta from typing import Callable @@ -121,10 +119,9 @@ class ISYBinarySensorDevice(ISYDevice, BinarySensorDevice): self._computed_state = bool(self._node.status._val) self._status_was_unknown = False - @asyncio.coroutine - def async_added_to_hass(self) -> None: + async def async_added_to_hass(self) -> None: """Subscribe to the node and subnode event emitters.""" - yield from super().async_added_to_hass() + await super().async_added_to_hass() self._node.controlEvents.subscribe(self._positive_node_control_handler) @@ -261,10 +258,9 @@ class ISYBinarySensorHeartbeat(ISYDevice, BinarySensorDevice): self._parent_device = parent_device self._heartbeat_timer = None - @asyncio.coroutine - def async_added_to_hass(self) -> None: + async def async_added_to_hass(self) -> None: """Subscribe to the node and subnode event emitters.""" - yield from super().async_added_to_hass() + await super().async_added_to_hass() self._node.controlEvents.subscribe( self._heartbeat_node_control_handler) diff --git a/homeassistant/components/binary_sensor/mqtt.py b/homeassistant/components/binary_sensor/mqtt.py index 944cea96b33..baaf6a9a567 100644 --- a/homeassistant/components/binary_sensor/mqtt.py +++ b/homeassistant/components/binary_sensor/mqtt.py @@ -4,7 +4,6 @@ Support for MQTT binary sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.mqtt/ """ -import asyncio import logging from typing import Optional @@ -115,11 +114,10 @@ class MqttBinarySensor(MqttAvailability, MqttDiscoveryUpdate, self._unique_id = unique_id self._discovery_hash = discovery_hash - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Subscribe mqtt events.""" - yield from MqttAvailability.async_added_to_hass(self) - yield from MqttDiscoveryUpdate.async_added_to_hass(self) + await MqttAvailability.async_added_to_hass(self) + await MqttDiscoveryUpdate.async_added_to_hass(self) @callback def state_message_received(topic, payload, qos): @@ -139,7 +137,7 @@ class MqttBinarySensor(MqttAvailability, MqttDiscoveryUpdate, self.async_schedule_update_ha_state() - yield from mqtt.async_subscribe( + await mqtt.async_subscribe( self.hass, self._state_topic, state_message_received, self._qos) @property diff --git a/homeassistant/components/binary_sensor/mychevy.py b/homeassistant/components/binary_sensor/mychevy.py index d1438379da1..c1e3b6f0aac 100644 --- a/homeassistant/components/binary_sensor/mychevy.py +++ b/homeassistant/components/binary_sensor/mychevy.py @@ -3,8 +3,6 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.mychevy/ """ - -import asyncio import logging from homeassistant.components.mychevy import ( @@ -22,9 +20,8 @@ SENSORS = [ ] -@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 the MyChevy sensors.""" if discovery_info is None: return @@ -75,8 +72,7 @@ class EVBinarySensor(BinarySensorDevice): """Return the car.""" return self._conn.get_car(self._car_vid) - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" self.hass.helpers.dispatcher.async_dispatcher_connect( UPDATE_TOPIC, self.async_update_callback) diff --git a/homeassistant/components/binary_sensor/mystrom.py b/homeassistant/components/binary_sensor/mystrom.py index 23f40ce0a7f..5785ed464fd 100644 --- a/homeassistant/components/binary_sensor/mystrom.py +++ b/homeassistant/components/binary_sensor/mystrom.py @@ -4,7 +4,6 @@ Support for the myStrom buttons. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.mystrom/ """ -import asyncio import logging from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDevice @@ -16,9 +15,8 @@ _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['http'] -@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 myStrom Binary Sensor.""" hass.http.register_view(MyStromView(async_add_entities)) @@ -37,14 +35,12 @@ class MyStromView(HomeAssistantView): self.buttons = {} self.add_entities = add_entities - @asyncio.coroutine - def get(self, request): + async def get(self, request): """Handle the GET request received from a myStrom button.""" - res = yield from self._handle(request.app['hass'], request.query) + res = await self._handle(request.app['hass'], request.query) return res - @asyncio.coroutine - def _handle(self, hass, data): + async def _handle(self, hass, data): """Handle requests to the myStrom endpoint.""" button_action = next(( parameter for parameter in data diff --git a/homeassistant/components/binary_sensor/satel_integra.py b/homeassistant/components/binary_sensor/satel_integra.py index 3500f0a0576..8aff02d55a7 100644 --- a/homeassistant/components/binary_sensor/satel_integra.py +++ b/homeassistant/components/binary_sensor/satel_integra.py @@ -4,7 +4,6 @@ Support for Satel Integra zone states- represented as binary sensors. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.satel_integra/ """ -import asyncio import logging from homeassistant.components.binary_sensor import BinarySensorDevice @@ -20,9 +19,8 @@ DEPENDENCIES = ['satel_integra'] _LOGGER = logging.getLogger(__name__) -@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 the Satel Integra binary sensor devices.""" if not discovery_info: return @@ -50,8 +48,7 @@ class SatelIntegraBinarySensor(BinarySensorDevice): self._zone_type = zone_type self._state = 0 - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" async_dispatcher_connect( self.hass, SIGNAL_ZONES_UPDATED, self._zones_updated) diff --git a/homeassistant/components/binary_sensor/template.py b/homeassistant/components/binary_sensor/template.py index c5bfa593022..89547dffbc9 100644 --- a/homeassistant/components/binary_sensor/template.py +++ b/homeassistant/components/binary_sensor/template.py @@ -4,7 +4,6 @@ Support for exposing a templated binary sensor. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.template/ """ -import asyncio import logging import voluptuous as vol @@ -46,9 +45,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -@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 template binary sensors.""" sensors = [] @@ -109,8 +107,7 @@ class BinarySensorTemplate(BinarySensorDevice): self._delay_on = delay_on self._delay_off = delay_off - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Register callbacks.""" @callback def template_bsensor_state_listener(entity, old_state, new_state): diff --git a/homeassistant/components/binary_sensor/threshold.py b/homeassistant/components/binary_sensor/threshold.py index fd7ead08822..0dadf3a61fd 100644 --- a/homeassistant/components/binary_sensor/threshold.py +++ b/homeassistant/components/binary_sensor/threshold.py @@ -4,7 +4,6 @@ Support for monitoring if a sensor value is below/above a threshold. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.threshold/ """ -import asyncio import logging import voluptuous as vol @@ -54,9 +53,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ }) -@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 the Threshold sensor.""" entity_id = config.get(CONF_ENTITY_ID) name = config.get(CONF_NAME) @@ -147,8 +145,7 @@ class ThresholdSensor(BinarySensorDevice): ATTR_UPPER: self._threshold_upper, } - @asyncio.coroutine - def async_update(self): + async def async_update(self): """Get the latest data and updates the states.""" def below(threshold): """Determine if the sensor value is below a threshold.""" diff --git a/homeassistant/components/binary_sensor/trend.py b/homeassistant/components/binary_sensor/trend.py index ae6fd5562bf..0b168e45b4d 100644 --- a/homeassistant/components/binary_sensor/trend.py +++ b/homeassistant/components/binary_sensor/trend.py @@ -4,7 +4,6 @@ A sensor that monitors trends in other components. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.trend/ """ -import asyncio from collections import deque import logging import math @@ -138,8 +137,7 @@ class SensorTrend(BinarySensorDevice): """No polling needed.""" return False - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Complete device setup after being added to hass.""" @callback def trend_sensor_state_listener(entity, old_state, new_state): @@ -160,8 +158,7 @@ class SensorTrend(BinarySensorDevice): self.hass, self._entity_id, trend_sensor_state_listener) - @asyncio.coroutine - def async_update(self): + async def async_update(self): """Get the latest data and update the states.""" # Remove outdated samples if self._sample_duration > 0: @@ -173,7 +170,7 @@ class SensorTrend(BinarySensorDevice): return # Calculate gradient of linear trend - yield from self.hass.async_add_job(self._calculate_gradient) + await self.hass.async_add_job(self._calculate_gradient) # Update state self._state = ( diff --git a/homeassistant/components/binary_sensor/wink.py b/homeassistant/components/binary_sensor/wink.py index 1976e49f446..a950289789e 100644 --- a/homeassistant/components/binary_sensor/wink.py +++ b/homeassistant/components/binary_sensor/wink.py @@ -4,7 +4,6 @@ Support for Wink binary sensors. For more details about this platform, please refer to the documentation at at https://home-assistant.io/components/binary_sensor.wink/ """ -import asyncio import logging from homeassistant.components.binary_sensor import BinarySensorDevice @@ -101,8 +100,7 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice): else: self.capability = None - @asyncio.coroutine - def async_added_to_hass(self): + async def async_added_to_hass(self): """Call when entity is added to hass.""" self.hass.data[DOMAIN]['entities']['binary_sensor'].append(self) diff --git a/homeassistant/components/binary_sensor/workday.py b/homeassistant/components/binary_sensor/workday.py index 1d85d9c9a47..82b5e66629a 100644 --- a/homeassistant/components/binary_sensor/workday.py +++ b/homeassistant/components/binary_sensor/workday.py @@ -4,7 +4,6 @@ Sensor to indicate whether the current day is a workday. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/binary_sensor.workday/ """ -import asyncio import logging from datetime import datetime, timedelta @@ -162,8 +161,7 @@ class IsWorkdaySensor(BinarySensorDevice): CONF_OFFSET: self._days_offset } - @asyncio.coroutine - def async_update(self): + async def async_update(self): """Get date and look whether it is a holiday.""" # Default is no workday self._state = False