Async syntax 5, light & lock & remote & scene & telegram & helpers (#17019)

This commit is contained in:
cdce8p authored and Paulus Schoutsen committed 2018-10-01 08:56:50 +02:00
1 parent 9e4c8f45d6
commit 3b5e5cbcd6
28 files changed
+112 -195

No files matched your search

+2 -4
View File
@@ -4,7 +4,6 @@ Component to interface with various locks that can be controlled remotely.
For more details about this component, please refer to the documentation
at https://home-assistant.io/components/lock/
"""
import asyncio
from datetime import timedelta
import functools as ft
import logging
@@ -57,13 +56,12 @@ def is_locked(hass, entity_id=None):
return hass.states.is_state(entity_id, STATE_LOCKED)
@asyncio.coroutine
def async_setup(hass, config):
async def async_setup(hass, config):
"""Track states and offer events for locks."""
component = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_LOCKS)
yield from component.async_setup(config)
await component.async_setup(config)
component.async_register_entity_service(
SERVICE_UNLOCK, LOCK_SERVICE_SCHEMA,
@@ -4,7 +4,6 @@ Support for BMW cars with BMW ConnectedDrive.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/lock.bmw_connected_drive/
"""
import asyncio
import logging
from homeassistant.components.bmw_connected_drive import DOMAIN as BMW_DOMAIN
@@ -111,8 +110,7 @@ class BMWLock(LockDevice):
"""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.
+8 -13
View File
@@ -4,7 +4,6 @@ Support for MQTT locks.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/lock.mqtt/
"""
import asyncio
import logging
import voluptuous as vol
@@ -41,9 +40,8 @@ PLATFORM_SCHEMA = mqtt.MQTT_RW_PLATFORM_SCHEMA.extend({
}).extend(mqtt.MQTT_AVAILABILITY_SCHEMA.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):
"""Set up the MQTT lock."""
if discovery_info is not None:
config = PLATFORM_SCHEMA(discovery_info)
@@ -96,11 +94,10 @@ class MqttLock(MqttAvailability, MqttDiscoveryUpdate, LockDevice):
self._template = value_template
self._discovery_hash = discovery_hash
@asyncio.coroutine
def async_added_to_hass(self):
async def async_added_to_hass(self):
"""Subscribe to 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):
@@ -119,7 +116,7 @@ class MqttLock(MqttAvailability, MqttDiscoveryUpdate, LockDevice):
# Force into optimistic mode.
self._optimistic = True
else:
yield from mqtt.async_subscribe(
await mqtt.async_subscribe(
self.hass, self._state_topic, message_received, self._qos)
@property
@@ -142,8 +139,7 @@ class MqttLock(MqttAvailability, MqttDiscoveryUpdate, LockDevice):
"""Return true if we do optimistic updates."""
return self._optimistic
@asyncio.coroutine
def async_lock(self, **kwargs):
async def async_lock(self, **kwargs):
"""Lock the device.
This method is a coroutine.
@@ -156,8 +152,7 @@ class MqttLock(MqttAvailability, MqttDiscoveryUpdate, LockDevice):
self._state = True
self.async_schedule_update_ha_state()
@asyncio.coroutine
def async_unlock(self, **kwargs):
async def async_unlock(self, **kwargs):
"""Unlock the device.
This method is a coroutine.
+1 -3
View File
@@ -4,7 +4,6 @@ Nuki.io lock platform.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/lock.nuki/
"""
import asyncio
from datetime import timedelta
import logging
@@ -92,8 +91,7 @@ class NukiLock(LockDevice):
self._name = nuki_lock.name
self._battery_critical = nuki_lock.battery_critical
@asyncio.coroutine
def async_added_to_hass(self):
async def async_added_to_hass(self):
"""Call when entity is added to hass."""
if NUKI_DATA not in self.hass.data:
self.hass.data[NUKI_DATA] = {}
+1 -3
View File
@@ -4,7 +4,6 @@ Support for Wink locks.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/lock.wink/
"""
import asyncio
import logging
import voluptuous as vol
@@ -131,8 +130,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class WinkLockDevice(WinkDevice, LockDevice):
"""Representation of a Wink lock."""
@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']['lock'].append(self)
+3 -5
View File
@@ -4,7 +4,6 @@ Z-Wave platform that handles simple door locks.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/lock.zwave/
"""
import asyncio
import logging
import voluptuous as vol
@@ -119,11 +118,10 @@ CLEAR_USERCODE_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):
"""Set up the Z-Wave Lock platform."""
yield from zwave.async_setup_platform(
await zwave.async_setup_platform(
hass, config, async_add_entities, discovery_info)
network = hass.data[zwave.const.DATA_NETWORK]