1 """Base class for a device entity integrated in devolo Home Control."""
3 from __future__
import annotations
6 from urllib.parse
import urlparse
8 from devolo_home_control_api.devices.zwave
import Zwave
9 from devolo_home_control_api.homecontrol
import HomeControl
15 from .const
import DOMAIN
16 from .subscriber
import Subscriber
18 _LOGGER = logging.getLogger(__name__)
22 """Abstract representation of a device within devolo Home Control."""
24 _attr_has_entity_name =
True
27 self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str
29 """Initialize a devolo device entity."""
34 device_instance.is_online()
39 configuration_url=f
"https://{urlparse(device_instance.href).netloc}",
41 manufacturer=device_instance.brand,
42 model=device_instance.name,
43 model_id=device_instance.identifier,
44 name=device_instance.settings_property[
"general_device_settings"].name,
45 suggested_area=device_instance.settings_property[
46 "general_device_settings"
50 self.
subscribersubscriber: Subscriber |
None =
None
56 """Call when entity is added to hass."""
67 """Call when entity is removed or disabled."""
72 def _sync(self, message: tuple) ->
None:
73 """Update the state."""
81 """Handle generic messages."""
84 and message[2] ==
"battery_level"
87 self.
_value_value = message[1]
88 elif len(message) == 3
and message[2] ==
"status":
92 _LOGGER.debug(
"No valid message received: %s", message)
None async_added_to_hass(self)
None _sync(self, tuple message)
None _generic_message(self, tuple message)
None async_will_remove_from_hass(self)
None __init__(self, HomeControl homecontrol, Zwave device_instance, str element_uid)
str|None device_class(self)
None schedule_update_ha_state(self, bool force_refresh=False)
DeviceInfo|None device_info(self)