1 """Base class for KNX devices."""
3 from __future__
import annotations
5 from typing
import TYPE_CHECKING, Any
7 from xknx.devices
import Device
as XknxDevice
15 from .const
import DOMAIN
16 from .storage.config_store
import PlatformControllerBase
17 from .storage.const
import CONF_DEVICE_INFO
20 from .
import KNXModule
24 """Class to manage dynamic adding and reloading of UI entities."""
28 knx_module: KNXModule,
29 entity_platform: EntityPlatform,
30 entity_class: type[KnxUiEntity],
32 """Initialize the UI platform."""
37 async
def create_entity(self, unique_id: str, config: dict[str, Any]) ->
None:
38 """Add a new UI entity."""
44 self, entity_entry: RegistryEntry, config: dict[str, Any]
46 """Update an existing UI entities configuration."""
47 await self.
_entity_platform_entity_platform.async_remove_entity(entity_entry.entity_id)
52 """Representation of a KNX entity."""
54 _attr_should_poll =
False
55 _knx_module: KNXModule
60 """Return the name of the KNX device."""
61 return self._device.name
65 """Return True if entity is available."""
66 return self._knx_module.connected
69 """Request a state update from KNX bus."""
70 await self._device.sync()
73 """Call after device was updated."""
77 """Store register state change callback and start device object."""
79 self._device.xknx.devices.async_add(self._device)
85 """Disconnect device object when removed."""
87 self._device.xknx.devices.async_remove(self._device)
91 """Representation of a KNX entity configured from YAML."""
93 def __init__(self, knx_module: KNXModule, device: XknxDevice) ->
None:
94 """Initialize the YAML entity."""
100 """Representation of a KNX UI entity."""
103 _attr_has_entity_name =
True
106 self, knx_module: KNXModule, unique_id: str, entity_config: dict[str, Any]
108 """Initialize the UI entity."""
111 if entity_category := entity_config.get(CONF_ENTITY_CATEGORY):
113 if device_info := entity_config.get(CONF_DEVICE_INFO):
None __init__(self, KNXModule knx_module, str unique_id, dict[str, Any] entity_config)
None __init__(self, KNXModule knx_module, XknxDevice device)
None after_update_callback(self, XknxDevice _device)
None async_will_remove_from_hass(self)
None async_added_to_hass(self)
None async_write_ha_state(self)