Add async_safe annotation (#3688)
* Add async_safe annotation * More async_run_job * coroutine -> async_save * Lint * Rename async_safe -> callback * Add tests to core for different job types * Add one more test with different type of callbacks * Fix typing signature for callback methods * Fix callback service executed method * Fix method signatures for callback
This commit is contained in:
1 parent
be7401f4a2
commit
5085cdb0f7
19 files changed
+231
-87
No files matched your search
@@ -9,6 +9,7 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT, PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE,
|
||||
@@ -79,7 +80,7 @@ class SensorTemplate(Entity):
|
||||
|
||||
self.update()
|
||||
|
||||
@asyncio.coroutine
|
||||
@callback
|
||||
def template_sensor_state_listener(entity, old_state, new_state):
|
||||
"""Called when the target device changes state."""
|
||||
hass.loop.create_task(self.async_update_ha_state(True))
|
||||
|
||||
Reference in new issue
Block a user