1 """Python Control of Nobø Hub - Nobø Energy Control."""
3 from __future__
import annotations
5 from pynobo
import nobo
19 from .const
import ATTR_SERIAL, ATTR_ZONE_ID, DOMAIN, NOBO_MANUFACTURER
24 config_entry: ConfigEntry,
25 async_add_entities: AddEntitiesCallback,
27 """Set up any temperature sensors connected to the Nobø Ecohub."""
30 hub: nobo = hass.data[DOMAIN][config_entry.entry_id]
34 for component
in hub.components.values()
35 if component[ATTR_MODEL].has_temp_sensor
40 """A Nobø device with a temperature sensor."""
42 _attr_device_class = SensorDeviceClass.TEMPERATURE
43 _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS
44 _attr_state_class = SensorStateClass.MEASUREMENT
45 _attr_should_poll =
False
46 _attr_has_entity_name =
True
48 def __init__(self, serial: str, hub: nobo) ->
None:
49 """Initialize the temperature sensor."""
50 self._temperature: StateType =
None
53 component = hub.components[self.
_id_id]
55 zone_id = component[ATTR_ZONE_ID]
58 suggested_area = hub.zones[zone_id][ATTR_NAME]
60 identifiers={(DOMAIN, component[ATTR_SERIAL])},
61 name=component[ATTR_NAME],
62 manufacturer=NOBO_MANUFACTURER,
63 model=component[ATTR_MODEL].name,
64 via_device=(DOMAIN, hub.hub_info[ATTR_SERIAL]),
65 suggested_area=suggested_area,
70 """Register callback from hub."""
74 """Deregister callback from hub."""
79 """Read the current state from the hub. This is a local call."""
80 value = self.
_nobo_nobo.get_current_component_temperature(self.
_id_id)
None __init__(self, str serial, nobo hub)
None async_added_to_hass(self)
None async_will_remove_from_hass(self)
None _after_update(self, hub)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)