mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Update kodi device trigger to use async_run_hass_job (#41531)
This commit is contained in:
parent
5ebf5996f1
commit
fef2700351
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||||||
CONF_PLATFORM,
|
CONF_PLATFORM,
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
|
from homeassistant.core import CALLBACK_TYPE, Event, HassJob, HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv, entity_registry
|
from homeassistant.helpers import config_validation as cv, entity_registry
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
@ -63,11 +63,13 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]:
|
|||||||
def _attach_trigger(
|
def _attach_trigger(
|
||||||
hass: HomeAssistant, config: ConfigType, action: AutomationActionType, event_type
|
hass: HomeAssistant, config: ConfigType, action: AutomationActionType, event_type
|
||||||
):
|
):
|
||||||
|
job = HassJob(action)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_event(event: Event):
|
def _handle_event(event: Event):
|
||||||
if event.data[ATTR_ENTITY_ID] == config[CONF_ENTITY_ID]:
|
if event.data[ATTR_ENTITY_ID] == config[CONF_ENTITY_ID]:
|
||||||
hass.async_run_job(
|
hass.async_run_hass_job(
|
||||||
action,
|
job,
|
||||||
{"trigger": {**config, "description": event_type}},
|
{"trigger": {**config, "description": event_type}},
|
||||||
event.context,
|
event.context,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user