1 """Support for Broadlink selects."""
3 from __future__
import annotations
12 from .
import BroadlinkDevice
13 from .const
import DOMAIN
14 from .entity
import BroadlinkEntity
25 DAY_NAME_TO_ID = {v: k
for k, v
in DAY_ID_TO_NAME.items()}
30 config_entry: ConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up the Broadlink select."""
34 device = hass.data[DOMAIN].devices[config_entry.entry_id]
39 """Representation of a Broadlink day of week."""
41 _attr_has_entity_name =
True
42 _attr_current_option: str |
None =
None
43 _attr_options =
list(DAY_NAME_TO_ID)
44 _attr_translation_key =
"day_of_week"
46 def __init__(self, device: BroadlinkDevice) ->
None:
47 """Initialize the select."""
53 """Update the state of the entity."""
54 if data
is None or "dayofweek" not in data:
60 """Change the selected option."""
61 await self.
_device_device.async_request(
62 self.
_device_device.api.set_time,
66 day=DAY_NAME_TO_ID[option],
None __init__(self, BroadlinkDevice device)
None _update_state(self, dict[str, Any] data)
None async_select_option(self, str option)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)