1 """The Nibe Heat Pump sensors."""
3 from __future__
import annotations
5 from datetime
import date
7 from nibe.coil
import Coil
8 from nibe.coil_groups
import WATER_HEATER_COILGROUPS, WaterHeaterCoilGroup
9 from nibe.exceptions
import CoilNotFoundException
15 WaterHeaterEntityFeature,
26 VALUES_TEMPORARY_LUX_INACTIVE,
27 VALUES_TEMPORARY_LUX_ONE_TIME_INCREASE,
29 from .coordinator
import CoilCoordinator
34 config_entry: ConfigEntry,
35 async_add_entities: AddEntitiesCallback,
37 """Set up platform."""
39 coordinator: CoilCoordinator = hass.data[DOMAIN][config_entry.entry_id]
42 for key, group
in WATER_HEATER_COILGROUPS.get(coordinator.series, ()).items():
45 except CoilNotFoundException
as exception:
46 LOGGER.debug(
"Skipping water heater: %r", exception)
54 _attr_entity_category =
None
55 _attr_has_entity_name =
True
56 _attr_supported_features = WaterHeaterEntityFeature.OPERATION_MODE
62 coordinator: CoilCoordinator,
64 desc: WaterHeaterCoilGroup,
66 """Initialize entity."""
72 desc.hot_water_comfort_mode,
73 *set(desc.start_temperature.values()),
74 *set(desc.stop_temperature.values()),
75 desc.active_accessory,
89 self._operation_mode_to_lux: dict[str, str] = {}
91 def _get(address: int) -> Coil:
92 return coordinator.heatpump.get_coil_by_address(address)
94 def _map(data: dict[str, int]) -> dict[str, Coil]:
95 return {key: _get(address)
for key, address
in data.items()}
101 if desc.temporary_lux:
104 if address := desc.active_accessory:
109 def _add_lux_mode(temporary_lux: str, operation_mode: str) ->
None:
121 self._operation_mode_to_lux[operation_mode] = temporary_lux
123 _add_lux_mode(VALUES_TEMPORARY_LUX_ONE_TIME_INCREASE, STATE_HIGH_DEMAND)
124 _add_lux_mode(VALUES_TEMPORARY_LUX_INACTIVE, STATE_HEAT_PUMP)
130 if not self.coordinator.data:
133 def _get_float(coil: Coil |
None) -> float |
None:
138 def _get_value(coil: Coil |
None) -> int | str | float | date |
None:
160 == VALUES_TEMPORARY_LUX_ONE_TIME_INCREASE
170 """Return if entity is available."""
171 if not self.coordinator.last_update_success:
180 return active_accessory ==
"ON"
185 """Set new target operation mode."""
189 lux = self._operation_mode_to_lux.
get(operation_mode)
191 raise ValueError(f
"Unsupported operation mode {operation_mode}")
int|str|float|date|None get_coil_value(self, Coil coil)
None async_write_coil(self, Coil coil, float|str value)
float|None get_coil_float(self, Coil coil)
_attr_current_temperature
_attr_target_temperature_high
None __init__(self, CoilCoordinator coordinator, str key, WaterHeaterCoilGroup desc)
None async_set_operation_mode(self, str operation_mode)
_coil_hot_water_comfort_mode
None _handle_coordinator_update(self)
_attr_target_temperature_low
_attr_entity_registry_enabled_default
str|None _get_value(int value, list[str] values)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)