1 """Provides device triggers for LG Netcast."""
3 from __future__
import annotations
7 import voluptuous
as vol
10 DEVICE_TRIGGER_BASE_SCHEMA,
11 InvalidDeviceAutomationConfig,
20 from .const
import DOMAIN
21 from .helpers
import async_get_device_entry_by_device_id
22 from .triggers.turn_on
import (
23 PLATFORM_TYPE
as TURN_ON_PLATFORM_TYPE,
24 async_get_turn_on_trigger,
27 TRIGGER_TYPES = {TURN_ON_PLATFORM_TYPE}
29 TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
31 vol.Required(CONF_TYPE): vol.In(TRIGGER_TYPES),
37 hass: HomeAssistant, config: ConfigType
39 """Validate config."""
42 if config[CONF_TYPE] == TURN_ON_PLATFORM_TYPE:
43 device_id = config[CONF_DEVICE_ID]
47 except ValueError
as err:
50 if DOMAIN
in hass.data:
51 for config_entry_id
in device.config_entries:
52 if hass.data[DOMAIN].
get(config_entry_id):
56 f
"Device {device.id} is not from an existing {DOMAIN} config entry"
63 _hass: HomeAssistant, device_id: str
64 ) -> list[dict[str, Any]]:
65 """List device triggers for LG Netcast devices."""
72 action: TriggerActionType,
73 trigger_info: TriggerInfo,
75 """Attach a trigger."""
76 if (trigger_type := config[CONF_TYPE]) == TURN_ON_PLATFORM_TYPE:
78 CONF_PLATFORM: trigger_type,
79 CONF_DEVICE_ID: config[CONF_DEVICE_ID],
81 trigger_config = await trigger.async_validate_trigger_config(
84 return await trigger.async_attach_trigger(
85 hass, trigger_config, action, trigger_info
web.Response get(self, web.Request request, str config_key)
list[dict[str, Any]] async_get_triggers(HomeAssistant _hass, str device_id)
ConfigType async_validate_trigger_config(HomeAssistant hass, ConfigType config)
CALLBACK_TYPE async_attach_trigger(HomeAssistant hass, ConfigType config, TriggerActionType action, TriggerInfo trigger_info)
DeviceEntry async_get_device_entry_by_device_id(HomeAssistant hass, str device_id)
dict[str, str] async_get_turn_on_trigger(str device_id)