Update triggers to use HassJob (#41450)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
J. Nick KostonandPaulus Schoutsen authored and GitHub committed 2020-10-08 09:44:34 +02:00
1 parent 7537a3a7c8
commit b51a160cce
13 files changed
+55 -41

No files matched your search

+4 -3
View File
@@ -10,7 +10,7 @@ from homeassistant.const import (
CONF_PLATFORM,
SUN_EVENT_SUNRISE,
)
from homeassistant.core import callback
from homeassistant.core import HassJob, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_sunrise, async_track_sunset
@@ -34,12 +34,13 @@ async def async_attach_trigger(hass, config, action, automation_info):
description = event
if offset:
description = f"{description} with offset"
job = HassJob(action)
@callback
def call_action():
"""Call action with right context."""
hass.async_run_job(
action,
hass.async_run_hass_job(
job,
{
"trigger": {
"platform": "sun",