1 """Support for KNX/IP text."""
3 from __future__
import annotations
6 from xknx.devices
import Notification
as XknxNotification
7 from xknx.dpt
import DPTLatin1
9 from homeassistant
import config_entries
25 from .
import KNXModule
26 from .const
import CONF_RESPOND_TO_READ, CONF_STATE_ADDRESS, KNX_ADDRESS, KNX_MODULE_KEY
27 from .entity
import KnxYamlEntity
33 async_add_entities: AddEntitiesCallback,
35 """Set up sensor(s) for KNX platform."""
36 knx_module = hass.data[KNX_MODULE_KEY]
37 config: list[ConfigType] = knx_module.config_yaml[Platform.TEXT]
43 """Return a KNX Notification to be used within XKNX."""
44 return XknxNotification(
46 name=config[CONF_NAME],
47 group_address=config[KNX_ADDRESS],
48 group_address_state=config.get(CONF_STATE_ADDRESS),
49 respond_to_read=config[CONF_RESPOND_TO_READ],
50 value_type=config[CONF_TYPE],
55 """Representation of a KNX text."""
57 _device: XknxNotification
60 def __init__(self, knx_module: KNXModule, config: ConfigType) ->
None:
61 """Initialize a KNX text."""
63 knx_module=knx_module,
69 if issubclass(self.
_device_device.remote_value.dpt_class, DPTLatin1)
70 else r"[\u0000-\u007f]*"
76 """Restore last state."""
78 if not self.
_device_device.remote_value.readable
and (
81 if last_state.state
not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
82 self.
_device_device.remote_value.value = last_state.state
86 """Return the value reported by the text."""
87 return self.
_device_device.message
90 """Change the value."""
91 await self.
_device_device.set(value)
str|None native_value(self)
None __init__(self, KNXModule knx_module, ConfigType config)
None async_added_to_hass(self)
None async_set_value(self, str value)
State|None async_get_last_state(self)
XknxNotification _create_notification(XKNX xknx, ConfigType config)
None async_setup_entry(HomeAssistant hass, config_entries.ConfigEntry config_entry, AddEntitiesCallback async_add_entities)