mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Update arcam_fmj device trigger to use async_run_hass_job (#41530)
This commit is contained in:
parent
fef2700351
commit
822ad0ae9c
@ -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
|
||||||
|
|
||||||
@ -57,6 +57,7 @@ async def async_attach_trigger(
|
|||||||
) -> CALLBACK_TYPE:
|
) -> CALLBACK_TYPE:
|
||||||
"""Attach a trigger."""
|
"""Attach a trigger."""
|
||||||
config = TRIGGER_SCHEMA(config)
|
config = TRIGGER_SCHEMA(config)
|
||||||
|
job = HassJob(action)
|
||||||
|
|
||||||
if config[CONF_TYPE] == "turn_on":
|
if config[CONF_TYPE] == "turn_on":
|
||||||
entity_id = config[CONF_ENTITY_ID]
|
entity_id = config[CONF_ENTITY_ID]
|
||||||
@ -64,8 +65,8 @@ async def async_attach_trigger(
|
|||||||
@callback
|
@callback
|
||||||
def _handle_event(event: Event):
|
def _handle_event(event: Event):
|
||||||
if event.data[ATTR_ENTITY_ID] == entity_id:
|
if event.data[ATTR_ENTITY_ID] == entity_id:
|
||||||
hass.async_run_job(
|
hass.async_run_hass_job(
|
||||||
action,
|
job,
|
||||||
{"trigger": {**config, "description": f"{DOMAIN} - {entity_id}"}},
|
{"trigger": {**config, "description": f"{DOMAIN} - {entity_id}"}},
|
||||||
event.context,
|
event.context,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user