1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

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
2016-10-04 20:44:32 -07:00
committed by GitHub
parent be7401f4a2
commit 5085cdb0f7
19 changed files with 231 additions and 87 deletions

View File

@@ -4,11 +4,11 @@ Offer time listening automation rules.
For more details about this automation rule, please refer to the documentation
at https://home-assistant.io/components/automation/#time-trigger
"""
import asyncio
import logging
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_AFTER, CONF_PLATFORM
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.event import async_track_time_change
@@ -39,10 +39,10 @@ def async_trigger(hass, config, action):
minutes = config.get(CONF_MINUTES)
seconds = config.get(CONF_SECONDS)
@asyncio.coroutine
@callback
def time_automation_listener(now):
"""Listen for time changes and calls action."""
hass.async_add_job(action, {
hass.async_run_job(action, {
'trigger': {
'platform': 'time',
'now': now,