1 """Support for esphome texts."""
3 from __future__
import annotations
5 from functools
import partial
7 from aioesphomeapi
import EntityInfo, TextInfo, TextMode
as EsphomeTextMode, TextState
14 convert_api_error_ha_error,
15 esphome_state_property,
16 platform_async_setup_entry,
18 from .enum_mapper
import EsphomeEnumMapper
22 EsphomeTextMode.TEXT: TextMode.TEXT,
23 EsphomeTextMode.PASSWORD: TextMode.PASSWORD,
29 """A text implementation for esphome."""
33 """Set attrs from static info."""
39 self.
_attr_mode_attr_mode = TEXT_MODES.from_esphome(static_info.mode)
or TextMode.TEXT
42 @esphome_state_property
44 """Return the state of the entity."""
46 return None if state.missing_state
else state.state
48 @convert_api_error_ha_error
50 """Update the current value."""
51 self.
_client_client.text_command(self.
_key_key, value)
54 async_setup_entry = partial(
55 platform_async_setup_entry,
57 entity_type=EsphomeText,
str|None native_value(self)
None _on_static_info_update(self, EntityInfo static_info)
None async_set_value(self, str value)