1 """Python Control of Nobø Hub - Nobø Energy Control."""
3 from __future__
import annotations
7 from pynobo
import nobo
10 ATTR_TARGET_TEMP_HIGH,
37 ClimateEntityFeature.PRESET_MODE | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
40 PRESET_MODES = [PRESET_NONE, PRESET_COMFORT, PRESET_ECO, PRESET_AWAY]
48 config_entry: ConfigEntry,
49 async_add_entities: AddEntitiesCallback,
51 """Set up the Nobø Ecohub platform from UI configuration."""
54 hub: nobo = hass.data[DOMAIN][config_entry.entry_id]
57 nobo.API.OVERRIDE_TYPE_NOW
58 if config_entry.options.get(CONF_OVERRIDE_TYPE) == OVERRIDE_TYPE_NOW
59 else nobo.API.OVERRIDE_TYPE_CONSTANT
67 """Representation of a Nobø zone.
69 A Nobø zone consists of a group of physical devices that are
70 controlled as a unity.
74 _attr_has_entity_name =
True
75 _attr_max_temp = MAX_TEMPERATURE
76 _attr_min_temp = MIN_TEMPERATURE
77 _attr_precision = PRECISION_TENTHS
78 _attr_hvac_modes = [HVACMode.HEAT, HVACMode.AUTO]
79 _attr_hvac_mode = HVACMode.AUTO
80 _attr_preset_modes = PRESET_MODES
81 _attr_supported_features = SUPPORT_FLAGS
82 _attr_temperature_unit = UnitOfTemperature.CELSIUS
83 _attr_target_temperature_step = 1
85 _enable_turn_on_off_backwards_compatibility =
False
87 def __init__(self, zone_id, hub: nobo, override_type) ->
None:
88 """Initialize the climate device."""
94 identifiers={(DOMAIN, f
"{hub.hub_serial}:{zone_id}")},
95 name=hub.zones[zone_id][ATTR_NAME],
96 via_device=(DOMAIN, hub.hub_info[ATTR_SERIAL]),
97 suggested_area=hub.zones[zone_id][ATTR_NAME],
102 """Register callback from hub."""
106 """Deregister callback from hub."""
110 """Set new target HVAC mode, if it's supported."""
111 if hvac_mode
not in self.
hvac_modeshvac_modes:
113 f
"Zone {self._id} '{self._attr_name}' called with unsupported HVAC mode"
116 if hvac_mode == HVACMode.AUTO:
118 elif hvac_mode == HVACMode.HEAT:
122 """Set new zone override."""
123 if preset_mode == PRESET_ECO:
124 mode = nobo.API.OVERRIDE_MODE_ECO
125 elif preset_mode == PRESET_AWAY:
126 mode = nobo.API.OVERRIDE_MODE_AWAY
127 elif preset_mode == PRESET_COMFORT:
128 mode = nobo.API.OVERRIDE_MODE_COMFORT
130 mode = nobo.API.OVERRIDE_MODE_NORMAL
131 await self.
_nobo_nobo.async_create_override(
134 nobo.API.OVERRIDE_TARGET_ZONE,
139 """Set new target temperature."""
140 if ATTR_TARGET_TEMP_LOW
in kwargs:
141 low = round(kwargs[ATTR_TARGET_TEMP_LOW])
142 high = round(kwargs[ATTR_TARGET_TEMP_HIGH])
144 high =
max(low, high)
145 await self.
_nobo_nobo.async_update_zone(
146 self.
_id_id, temp_comfort_c=high, temp_eco_c=low
150 """Fetch new state data for this zone."""
155 """Read the current state from the hub. These are only local calls."""
156 state = self.
_nobo_nobo.get_current_zone_mode(self.
_id_id, dt_util.now())
160 if state == nobo.API.NAME_OFF:
162 elif state == nobo.API.NAME_AWAY:
164 elif state == nobo.API.NAME_ECO:
166 elif state == nobo.API.NAME_COMFORT:
169 if self.
_nobo_nobo.get_zone_override_mode(self.
_id_id) != nobo.API.NAME_NORMAL:
172 current_temperature = self.
_nobo_nobo.get_current_zone_temperature(self.
_id_id)
174 None if current_temperature
is None else float(current_temperature)
177 self.
_nobo_nobo.zones[self.
_id_id][ATTR_TEMP_COMFORT_C]
180 self.
_nobo_nobo.zones[self.
_id_id][ATTR_TEMP_ECO_C]
None async_set_preset_mode(self, str preset_mode)
list[HVACMode] hvac_modes(self)
_attr_current_temperature
None async_added_to_hass(self)
None async_will_remove_from_hass(self)
_attr_target_temperature_low
None async_set_hvac_mode(self, HVACMode hvac_mode)
_attr_target_temperature_high
None async_set_preset_mode(self, str preset_mode)
None async_set_temperature(self, **Any kwargs)
def _after_update(self, hub)
None __init__(self, zone_id, nobo hub, override_type)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)