1 """Provides device automations for control of LG webOS Smart TV."""
3 from __future__
import annotations
5 import voluptuous
as vol
8 DEVICE_TRIGGER_BASE_SCHEMA,
9 InvalidDeviceAutomationConfig,
18 from .const
import DOMAIN
19 from .helpers
import (
20 async_get_client_by_device_entry,
21 async_get_device_entry_by_device_id,
23 from .triggers.turn_on
import (
24 PLATFORM_TYPE
as TURN_ON_PLATFORM_TYPE,
25 async_get_turn_on_trigger,
28 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]
46 if DOMAIN
in hass.data:
48 except ValueError
as err:
55 _hass: HomeAssistant, device_id: str
56 ) -> list[dict[str, str]]:
57 """List device triggers for device."""
64 action: TriggerActionType,
65 trigger_info: TriggerInfo,
67 """Attach a trigger."""
68 if (trigger_type := config[CONF_TYPE]) == TURN_ON_PLATFORM_TYPE:
70 CONF_PLATFORM: trigger_type,
71 CONF_DEVICE_ID: config[CONF_DEVICE_ID],
73 trigger_config = await trigger.async_validate_trigger_config(
76 return await trigger.async_attach_trigger(
77 hass, trigger_config, action, 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)
SamsungTVBridge async_get_client_by_device_entry(HomeAssistant hass, DeviceEntry device)
ConfigType async_validate_trigger_config(HomeAssistant hass, ConfigType config)
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)