1 """The Nibe Heat Pump climate."""
3 from __future__
import annotations
5 from datetime
import date
8 from nibe.coil
import Coil
9 from nibe.coil_groups
import (
15 from nibe.exceptions
import CoilNotFoundException
19 ATTR_TARGET_TEMP_HIGH,
36 VALUES_COOL_WITH_ROOM_SENSOR_OFF,
37 VALUES_MIXING_VALVE_CLOSED_STATE,
38 VALUES_PRIORITY_COOLING,
39 VALUES_PRIORITY_HEATING,
41 from .coordinator
import CoilCoordinator
46 config_entry: ConfigEntry,
47 async_add_entities: AddEntitiesCallback,
49 """Set up platform."""
51 coordinator: CoilCoordinator = hass.data[DOMAIN][config_entry.entry_id]
53 main_unit = UNIT_COILGROUPS[coordinator.series][
"main"]
55 def climate_systems():
56 for key, group
in CLIMATE_COILGROUPS.get(coordinator.series, ()).items():
59 except CoilNotFoundException
as exception:
60 LOGGER.debug(
"Skipping climate: %s due to %s", key, exception)
68 _attr_entity_category =
None
69 _attr_supported_features = (
70 ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
71 | ClimateEntityFeature.TARGET_TEMPERATURE
73 _attr_hvac_modes = [HVACMode.AUTO, HVACMode.HEAT, HVACMode.HEAT_COOL]
74 _attr_target_temperature_step = 0.5
77 _enable_turn_on_off_backwards_compatibility =
False
81 coordinator: CoilCoordinator,
84 climate: ClimateCoilGroup,
86 """Initialize entity."""
91 unit.cooling_with_room_sensor,
93 climate.setpoint_heat,
94 climate.setpoint_cool,
95 climate.mixing_valve_state,
96 climate.active_accessory,
97 climate.use_room_sensor,
111 def _get(address: int) -> Coil:
112 return coordinator.heatpump.get_coil_by_address(address)
119 except CoilNotFoundException:
124 if climate.active_accessory
is None:
136 def _get_value(coil: Coil) -> int | str | float | date |
None:
139 def _get_float(coil: Coil) -> float |
None:
148 in VALUES_COOL_WITH_ROOM_SENSOR_OFF
152 mode = HVACMode.HEAT_COOL
160 if mode == HVACMode.HEAT_COOL:
164 elif mode == HVACMode.HEAT:
176 in VALUES_MIXING_VALVE_CLOSED_STATE
179 elif prio
in VALUES_PRIORITY_HEATING:
181 elif prio
in VALUES_PRIORITY_COOLING:
192 """Return if entity is available."""
193 coordinator = self.coordinator
196 if not coordinator.last_update_success:
202 if active_accessory := coordinator.get_coil_value(active):
203 return active_accessory ==
"ON"
208 """Set target temperatures."""
209 coordinator = self.coordinator
210 hvac_mode = kwargs.get(ATTR_HVAC_MODE, self.
_attr_hvac_mode_attr_hvac_mode)
212 if (temperature := kwargs.get(ATTR_TEMPERATURE))
is not None:
213 if hvac_mode == HVACMode.HEAT:
214 await coordinator.async_write_coil(
217 elif hvac_mode == HVACMode.COOL:
219 await coordinator.async_write_coil(
224 f
"{hvac_mode} mode not supported for {self.name}"
228 "'set_temperature' requires 'hvac_mode' when passing"
229 " 'temperature' and 'hvac_mode' is not already set to"
233 if (temperature := kwargs.get(ATTR_TARGET_TEMP_LOW))
is not None:
234 await coordinator.async_write_coil(self.
_coil_setpoint_heat_coil_setpoint_heat, temperature)
238 and (temperature := kwargs.get(ATTR_TARGET_TEMP_HIGH))
is not None
240 await coordinator.async_write_coil(self.
_coil_setpoint_cool_coil_setpoint_cool, temperature)
243 """Set new target hvac mode."""
244 coordinator = self.coordinator
246 if hvac_mode == HVACMode.HEAT_COOL:
247 await coordinator.async_write_coil(
251 elif hvac_mode == HVACMode.HEAT:
252 await coordinator.async_write_coil(
256 elif hvac_mode == HVACMode.AUTO:
257 await coordinator.async_write_coil(
263 f
"{hvac_mode} mode not supported for {self.name}"
_coil_cooling_with_room_sensor
_attr_current_temperature
_attr_target_temperature_high
None _handle_coordinator_update(self)
None async_set_temperature(self, **Any kwargs)
_attr_target_temperature_low
_attr_entity_registry_enabled_default
None __init__(self, CoilCoordinator coordinator, str key, UnitCoilGroup unit, ClimateCoilGroup climate)
None async_set_hvac_mode(self, HVACMode hvac_mode)
int|str|float|date|None get_coil_value(self, Coil coil)
float|None get_coil_float(self, Coil coil)
None async_write_ha_state(self)
str|None _get_value(int value, list[str] values)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)