1 """Support for ZHA controls using the select platform."""
3 from __future__
import annotations
16 from .entity
import ZHAEntity
17 from .helpers
import (
20 async_add_entities
as zha_async_add_entities,
21 convert_zha_error_to_ha_error,
25 _LOGGER = logging.getLogger(__name__)
30 config_entry: ConfigEntry,
31 async_add_entities: AddEntitiesCallback,
33 """Set up the Zigbee Home Automation siren from config entry."""
35 entities_to_create = zha_data.platforms[Platform.SELECT]
41 zha_async_add_entities,
47 config_entry.async_on_unload(unsub)
51 """Representation of a ZHA select entity."""
53 def __init__(self, entity_data: EntityData, **kwargs: Any) ->
None:
54 """Initialize the ZHA select entity."""
55 super().
__init__(entity_data, **kwargs)
56 self.
_attr_options_attr_options = self.entity_data.entity.info_object.options
60 """Return the selected entity option to represent the entity state."""
61 return self.entity_data.entity.current_option
63 @convert_zha_error_to_ha_error
65 """Change the selected option."""
66 await self.entity_data.entity.async_select_option(option=option)
71 """Restore entity state."""
72 if state.state
and state.state
not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
73 self.entity_data.entity.restore_external_state_attributes(
str|None current_option(self)
None restore_external_state_attributes(self, State state)
None async_select_option(self, str option)
None __init__(self, EntityData entity_data, **Any kwargs)
None async_write_ha_state(self)
HAZHAData get_zha_data(HomeAssistant hass)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)