1 """Provides device automations for control of Samsung TV."""
3 from __future__
import annotations
5 import voluptuous
as vol
8 DEVICE_TRIGGER_BASE_SCHEMA,
9 InvalidDeviceAutomationConfig,
18 from .helpers
import (
19 async_get_client_by_device_entry,
20 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}
28 TRIGGER_SCHEMA = DEVICE_TRIGGER_BASE_SCHEMA.extend(
30 vol.Required(CONF_TYPE): vol.In(TRIGGER_TYPES),
36 hass: HomeAssistant, config: ConfigType
38 """Validate config."""
41 if config[CONF_TYPE] == TURN_ON_PLATFORM_TYPE:
42 device_id = config[CONF_DEVICE_ID]
46 except ValueError
as err:
53 _hass: HomeAssistant, device_id: str
54 ) -> list[dict[str, str]]:
55 """List device triggers for device."""
62 action: TriggerActionType,
63 trigger_info: TriggerInfo,
65 """Attach a trigger."""
66 if (trigger_type := config[CONF_TYPE]) == TURN_ON_PLATFORM_TYPE:
68 CONF_PLATFORM: trigger_type,
69 CONF_DEVICE_ID: config[CONF_DEVICE_ID],
71 trigger_config = await trigger.async_validate_trigger_config(
74 return await trigger.async_attach_trigger(
75 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)
ConfigType async_validate_trigger_config(HomeAssistant hass, ConfigType config)
CALLBACK_TYPE async_attach_trigger(HomeAssistant hass, ConfigType config, TriggerActionType action, TriggerInfo trigger_info)
list[dict[str, str]] async_get_triggers(HomeAssistant _hass, str device_id)
SamsungTVBridge async_get_client_by_device_entry(HomeAssistant hass, DeviceEntry device)