1 """Provides device automations for Arcam FMJ Receiver control."""
3 from __future__
import annotations
5 import voluptuous
as vol
21 from .const
import DOMAIN, EVENT_TURN_ON
23 TRIGGER_TYPES = {
"turn_on"}
24 TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
26 vol.Required(CONF_ENTITY_ID): cv.entity_id_or_uuid,
27 vol.Required(CONF_TYPE): vol.In(TRIGGER_TYPES),
33 hass: HomeAssistant, device_id: str
34 ) -> list[dict[str, str]]:
35 """List device triggers for Arcam FMJ Receiver control devices."""
36 entity_registry = er.async_get(hass)
40 CONF_PLATFORM:
"device",
41 CONF_DEVICE_ID: device_id,
43 CONF_ENTITY_ID: entry.id,
46 for entry
in er.async_entries_for_device(entity_registry, device_id)
47 if entry.domain ==
"media_player"
54 action: TriggerActionType,
55 trigger_info: TriggerInfo,
57 """Attach a trigger."""
58 trigger_data = trigger_info[
"trigger_data"]
61 if config[CONF_TYPE] ==
"turn_on":
62 registry = er.async_get(hass)
63 entity_id = er.async_resolve_entity_id(registry, config[ATTR_ENTITY_ID])
66 def _handle_event(event: Event) ->
None:
67 if event.data[ATTR_ENTITY_ID] == entity_id:
68 hass.async_run_hass_job(
74 "description": f
"{DOMAIN} - {entity_id}",
75 "entity_id": entity_id,
81 return hass.bus.async_listen(EVENT_TURN_ON, _handle_event)
list[dict[str, str]] async_get_triggers(HomeAssistant hass, str device_id)
CALLBACK_TYPE async_attach_trigger(HomeAssistant hass, ConfigType config, TriggerActionType action, TriggerInfo trigger_info)