1 """Component for wiffi support."""
3 from datetime
import timedelta
13 from .const
import CHECK_ENTITIES_SIGNAL, DEFAULT_TIMEOUT, DOMAIN, UPDATE_ENTITY_SIGNAL
17 """Generate a unique string for the entity."""
18 return f
"{device.mac_address.replace(':', '')}-{metric.name}"
22 """Common functionality for all wiffi entities."""
24 _attr_should_poll =
False
27 """Initialize the base elements of a wiffi entity."""
31 connections={(dr.CONNECTION_NETWORK_MAC, device.mac_address)},
32 identifiers={(DOMAIN, device.mac_address)},
33 manufacturer=
"stall.biz",
34 model=device.moduletype,
35 name=f
"{device.moduletype} {device.mac_address}",
36 sw_version=device.sw_version,
37 configuration_url=device.configuration_url,
42 self.
_timeout_timeout = options.get(CONF_TIMEOUT, DEFAULT_TIMEOUT)
45 """Entity has been added to hass."""
49 f
"{UPDATE_ENTITY_SIGNAL}-{self._id}",
60 """Reset value expiration date.
62 Will be called by derived classes after a value update has been received.
68 """Update the value of the entity."""
72 """Periodically check if entity value has been updated.
74 If there are no more updates from the wiffi device, the value will be
78 self.
_value_value
is not None
86 """Measurement entities have a value in present time."""
92 """Metered entities have a value that keeps increasing until reset."""
93 return self.
_attr_name_attr_name.endswith(
"_pro_h")
or self.
_attr_name_attr_name.endswith(
"_heute")
def __init__(self, device, metric, options)
def _update_value_callback(self, device, metric)
def reset_expiration_date(self)
def _is_measurement_entity(self)
def async_added_to_hass(self)
def _is_metered_entity(self)
def _check_expiration_date(self)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
def generate_unique_id(device, metric)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)