Async syntax 5, light & lock & remote & scene & telegram & helpers (#17019)
This commit is contained in:
1 parent
9e4c8f45d6
commit
3b5e5cbcd6
28 files changed
+112
-195
No files matched your search
@@ -5,7 +5,6 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/light.template/
|
||||
"""
|
||||
import logging
|
||||
import asyncio
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -49,9 +48,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 Template Lights."""
|
||||
lights = []
|
||||
|
||||
@@ -182,8 +180,7 @@ class LightTemplate(Light):
|
||||
"""Return the entity picture to use in the frontend, if any."""
|
||||
return self._entity_picture
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
@callback
|
||||
def template_light_state_listener(entity, old_state, new_state):
|
||||
@@ -203,8 +200,7 @@ class LightTemplate(Light):
|
||||
self.hass.bus.async_listen_once(
|
||||
EVENT_HOMEASSISTANT_START, template_light_startup)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn the light on."""
|
||||
optimistic_set = False
|
||||
# set optimistic states
|
||||
@@ -222,21 +218,19 @@ class LightTemplate(Light):
|
||||
self.hass.async_add_job(self._level_script.async_run(
|
||||
{"brightness": kwargs[ATTR_BRIGHTNESS]}))
|
||||
else:
|
||||
yield from self._on_script.async_run()
|
||||
await self._on_script.async_run()
|
||||
|
||||
if optimistic_set:
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the light off."""
|
||||
yield from self._off_script.async_run()
|
||||
await self._off_script.async_run()
|
||||
if self._template is None:
|
||||
self._state = False
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
async def async_update(self):
|
||||
"""Update the state from the template."""
|
||||
if self._template is not None:
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user