1 """PlaatoEntity class."""
5 from pyplaato.models.device
import PlaatoDevice
17 EXTRA_STATE_ATTRIBUTES,
24 """Representation of a Plaato Entity."""
26 _attr_should_poll =
False
28 def __init__(self, data, sensor_type, coordinator=None):
29 """Initialize the sensor."""
37 self.
_attr_name_attr_name = f
"{DOMAIN} {self._device_type} {self._device_name} {self._sensor_name}".title()
39 if firmware := self.
_sensor_data_sensor_data.firmware_version:
42 identifiers={(DOMAIN, self.
_device_id_device_id)},
43 manufacturer=
"Plaato",
46 sw_version=sw_version,
51 return PlaatoEntity._to_snake_case(self.
_sensor_data_sensor_data.attributes)
65 """Return the state attributes of the monitored installation."""
69 for attr_key, plaato_key
in EXTRA_STATE_ATTRIBUTES.items()
71 and self.
_attributes_attributes[plaato_key]
is not None
77 """Return if sensor is available."""
83 """When entity is added to hass."""
93 self.async_write_ha_state,
99 return {k.lower().replace(
" ",
"_"): v
for k, v
in dictionary.items()}
PlaatoDevice _sensor_data(self)
def _to_snake_case(dict dictionary)
dict[str, Any]|None extra_state_attributes(self)
def __init__(self, data, sensor_type, coordinator=None)
def async_added_to_hass(self)
None async_add_listener(HomeAssistant hass, Callable[[], None] listener)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)