1 """Support for DomesticHotWaterProduction."""
3 from __future__
import annotations
5 from typing
import Any, cast
7 from pyoverkiz.enums
import OverkizCommand, OverkizCommandParam, OverkizState
14 WaterHeaterEntityFeature,
18 from ..coordinator
import OverkizDataUpdateCoordinator
19 from ..entity
import OverkizEntity
21 OVERKIZ_TO_OPERATION_MODE: dict[str, str] = {
22 OverkizCommandParam.STANDARD: STATE_ON,
23 OverkizCommandParam.HIGH_DEMAND: STATE_HIGH_DEMAND,
24 OverkizCommandParam.STOP: STATE_OFF,
25 OverkizCommandParam.MANUAL_ECO_ACTIVE: STATE_ECO,
26 OverkizCommandParam.MANUAL_ECO_INACTIVE: STATE_OFF,
27 OverkizCommandParam.ECO: STATE_ECO,
28 OverkizCommandParam.AUTO: STATE_ECO,
29 OverkizCommandParam.AUTO_MODE: STATE_ECO,
30 OverkizCommandParam.BOOST: STATE_PERFORMANCE,
34 OverkizCommandParam.ABSENCE,
35 OverkizCommandParam.AWAY,
36 OverkizCommandParam.FROSTPROTECTION,
39 DEFAULT_MIN_TEMP: float = 30
40 DEFAULT_MAX_TEMP: float = 70
44 """Representation of a DomesticHotWaterProduction Water Heater."""
46 _attr_temperature_unit = UnitOfTemperature.CELSIUS
47 _attr_supported_features = (
48 WaterHeaterEntityFeature.TARGET_TEMPERATURE
49 | WaterHeaterEntityFeature.OPERATION_MODE
53 self, device_url: str, coordinator: OverkizDataUpdateCoordinator
56 super().
__init__(device_url, coordinator)
59 self.operation_mode_to_overkiz: dict[str, str] = {}
61 state_mode_definition = self.
executorexecutor.select_definition_state(
62 OverkizState.IO_DHW_MODE, OverkizState.MODBUSLINK_DHW_MODE
64 for param, mode
in OVERKIZ_TO_OPERATION_MODE.items():
68 not state_mode_definition
69 or state_mode_definition.values
70 and param
in state_mode_definition.values
72 self.operation_mode_to_overkiz[mode] = param
77 """Return true if boost mode is on."""
79 if self.
executorexecutor.has_state(OverkizState.IO_DHW_BOOST_MODE):
81 self.
executorexecutor.select_state(OverkizState.IO_DHW_BOOST_MODE)
82 == OverkizCommandParam.ON
85 if self.
executorexecutor.has_state(OverkizState.MODBUSLINK_DHW_BOOST_MODE):
87 self.
executorexecutor.select_state(OverkizState.MODBUSLINK_DHW_BOOST_MODE)
88 == OverkizCommandParam.ON
91 if self.
executorexecutor.has_state(OverkizState.CORE_BOOST_MODE_DURATION):
95 self.
executorexecutor.select_state(OverkizState.CORE_BOOST_MODE_DURATION),
100 operating_mode = self.
executorexecutor.select_state(OverkizState.CORE_OPERATING_MODE)
103 if isinstance(operating_mode, dict):
104 if operating_mode.get(OverkizCommandParam.RELAUNCH):
108 operating_mode.get(OverkizCommandParam.RELAUNCH),
110 == OverkizCommandParam.ON
114 return cast(str, operating_mode) == OverkizCommandParam.BOOST
120 """Return true if away mode is on."""
122 if self.
executorexecutor.has_state(OverkizState.IO_DHW_ABSENCE_MODE):
124 self.
executorexecutor.select_state(OverkizState.IO_DHW_ABSENCE_MODE)
125 == OverkizCommandParam.ON
128 if self.
executorexecutor.has_state(OverkizState.MODBUSLINK_DHW_ABSENCE_MODE):
130 self.
executorexecutor.select_state(OverkizState.MODBUSLINK_DHW_ABSENCE_MODE)
131 == OverkizCommandParam.ON
134 operating_mode = self.
executorexecutor.select_state(OverkizState.CORE_OPERATING_MODE)
137 if isinstance(operating_mode, dict):
138 if operating_mode.get(OverkizCommandParam.ABSENCE):
142 operating_mode.get(OverkizCommandParam.ABSENCE),
144 == OverkizCommandParam.ON
146 if operating_mode.get(OverkizCommandParam.AWAY):
150 operating_mode.get(OverkizCommandParam.AWAY),
152 == OverkizCommandParam.ON
156 return cast(str, operating_mode)
in DHWP_AWAY_MODES
162 """Return the minimum temperature."""
163 min_temp = self.
devicedevice.states[OverkizState.CORE_MINIMAL_TEMPERATURE_MANUAL_MODE]
165 return cast(float, min_temp.value_as_float)
166 return DEFAULT_MIN_TEMP
170 """Return the maximum temperature."""
171 max_temp = self.
devicedevice.states[OverkizState.CORE_MAXIMAL_TEMPERATURE_MANUAL_MODE]
173 return cast(float, max_temp.value_as_float)
174 return DEFAULT_MAX_TEMP
178 """Return the current temperature."""
179 current_temperature = self.
devicedevice.states[
180 OverkizState.IO_MIDDLE_WATER_TEMPERATURE
182 if current_temperature:
183 return current_temperature.value_as_float
184 current_temperature = self.
devicedevice.states[
185 OverkizState.MODBUSLINK_MIDDLE_WATER_TEMPERATURE
187 if current_temperature:
188 return current_temperature.value_as_float
193 """Return the temperature we try to reach."""
195 target_temperature = self.
devicedevice.states[
196 OverkizState.CORE_WATER_TARGET_TEMPERATURE
198 if target_temperature:
199 return target_temperature.value_as_float
201 target_temperature = self.
devicedevice.states[
202 OverkizState.CORE_TARGET_DWH_TEMPERATURE
204 if target_temperature:
205 return target_temperature.value_as_float
207 target_temperature = self.
devicedevice.states[OverkizState.CORE_TARGET_TEMPERATURE]
208 if target_temperature:
209 return target_temperature.value_as_float
215 """Return the highbound target temperature we try to reach."""
216 target_temperature_high = self.
devicedevice.states[
217 OverkizState.CORE_MAXIMAL_TEMPERATURE_MANUAL_MODE
219 if target_temperature_high:
220 return target_temperature_high.value_as_float
225 """Return the lowbound target temperature we try to reach."""
226 target_temperature_low = self.
devicedevice.states[
227 OverkizState.CORE_MINIMAL_TEMPERATURE_MANUAL_MODE
229 if target_temperature_low:
230 return target_temperature_low.value_as_float
234 """Set new target temperature."""
235 target_temperature = kwargs[ATTR_TEMPERATURE]
237 if self.
executorexecutor.has_command(OverkizCommand.SET_TARGET_TEMPERATURE):
238 await self.
executorexecutor.async_execute_command(
239 OverkizCommand.SET_TARGET_TEMPERATURE, target_temperature
241 elif self.
executorexecutor.has_command(OverkizCommand.SET_WATER_TARGET_TEMPERATURE):
242 await self.
executorexecutor.async_execute_command(
243 OverkizCommand.SET_WATER_TARGET_TEMPERATURE, target_temperature
246 if self.
executorexecutor.has_command(OverkizCommand.REFRESH_TARGET_TEMPERATURE):
247 await self.
executorexecutor.async_execute_command(
248 OverkizCommand.REFRESH_TARGET_TEMPERATURE
250 elif self.
executorexecutor.has_command(OverkizCommand.REFRESH_WATER_TARGET_TEMPERATURE):
251 await self.
executorexecutor.async_execute_command(
252 OverkizCommand.REFRESH_WATER_TARGET_TEMPERATURE
257 """Return current operation ie. eco, electric, performance, ..."""
259 return OVERKIZ_TO_OPERATION_MODE[OverkizCommandParam.BOOST]
261 current_dwh_mode = cast(
264 OverkizState.IO_DHW_MODE, OverkizState.MODBUSLINK_DHW_MODE
267 if current_dwh_mode
in OVERKIZ_TO_OPERATION_MODE:
268 return OVERKIZ_TO_OPERATION_MODE[current_dwh_mode]
273 """Set new target operation mode."""
275 if operation_mode == STATE_PERFORMANCE:
276 if self.
executorexecutor.has_command(OverkizCommand.SET_BOOST_MODE):
277 await self.
executorexecutor.async_execute_command(
278 OverkizCommand.SET_BOOST_MODE, OverkizCommand.ON
281 if self.
executorexecutor.has_command(OverkizCommand.SET_BOOST_MODE_DURATION):
282 await self.
executorexecutor.async_execute_command(
283 OverkizCommand.SET_BOOST_MODE_DURATION, 7
285 await self.
executorexecutor.async_execute_command(
286 OverkizCommand.REFRESH_BOOST_MODE_DURATION
289 if self.
executorexecutor.has_command(OverkizCommand.SET_CURRENT_OPERATING_MODE):
290 current_operating_mode = self.
executorexecutor.select_state(
291 OverkizState.CORE_OPERATING_MODE
294 if current_operating_mode
and isinstance(current_operating_mode, dict):
295 await self.
executorexecutor.async_execute_command(
296 OverkizCommand.SET_CURRENT_OPERATING_MODE,
298 OverkizCommandParam.RELAUNCH: OverkizCommandParam.ON,
299 OverkizCommandParam.ABSENCE: OverkizCommandParam.OFF,
308 if self.
executorexecutor.has_command(OverkizCommand.SET_BOOST_MODE):
309 await self.
executorexecutor.async_execute_command(
310 OverkizCommand.SET_BOOST_MODE, OverkizCommand.OFF
313 if self.
executorexecutor.has_command(OverkizCommand.SET_CURRENT_OPERATING_MODE):
314 current_operating_mode = self.
executorexecutor.select_state(
315 OverkizState.CORE_OPERATING_MODE
318 if current_operating_mode
and isinstance(current_operating_mode, dict):
319 await self.
executorexecutor.async_execute_command(
320 OverkizCommand.SET_CURRENT_OPERATING_MODE,
322 OverkizCommandParam.RELAUNCH: OverkizCommandParam.OFF,
323 OverkizCommandParam.ABSENCE: OverkizCommandParam.OFF,
327 await self.
executorexecutor.async_execute_command(
328 OverkizCommand.SET_DHW_MODE, self.operation_mode_to_overkiz[operation_mode]
331 if self.
executorexecutor.has_command(OverkizCommand.REFRESH_BOOST_MODE_DURATION):
332 await self.
executorexecutor.async_execute_command(
333 OverkizCommand.REFRESH_BOOST_MODE_DURATION
336 if self.
executorexecutor.has_command(OverkizCommand.REFRESH_DHW_MODE):
337 await self.
executorexecutor.async_execute_command(OverkizCommand.REFRESH_DHW_MODE)
None async_set_operation_mode(self, str operation_mode)
str|None current_operation(self)
bool|None is_away_mode_on(self)
bool _is_boost_mode_on(self)
float|None current_temperature(self)
float|None target_temperature(self)
float|None target_temperature_low(self)
float|None target_temperature_high(self)
None __init__(self, str device_url, OverkizDataUpdateCoordinator coordinator)
None async_set_temperature(self, **Any kwargs)