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:
Paulus Schoutsen authored and GitHub committed 2016-10-04 20:44:32 -07:00
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.binary_sensor import (
BinarySensorDevice, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
SENSOR_CLASSES_SCHEMA)
@@ -82,7 +83,7 @@ class BinarySensorTemplate(BinarySensorDevice):
self.update()
@asyncio.coroutine
@callback
def template_bsensor_state_listener(entity, old_state, new_state):
"""Called when the target device changes state."""
hass.loop.create_task(self.async_update_ha_state(True))