|
1 | 1 | """Modbus api for stiebel eltron heat pumps. This file is generated. Do not modify it manually.""" |
2 | 2 |
|
| 3 | +from __future__ import annotations |
| 4 | + |
3 | 5 | from enum import Enum |
4 | 6 |
|
5 | 7 | from . import ( |
@@ -150,7 +152,7 @@ class LwzEnergyDataRegisters(IsgRegisters): |
150 | 152 | ELEC_BOOSTER_DHW = 3032 |
151 | 153 |
|
152 | 154 |
|
153 | | -LWZ_SYSTEM_VALUES_REGISTERS = { |
| 155 | +LWZ_SYSTEM_VALUES_REGISTERS: dict[IsgRegisters, ModbusRegister] = { |
154 | 156 | LwzSystemValuesRegisters.ACTUAL_ROOM_T_HC1: ModbusRegister(address=1, name="ACTUAL ROOM T HC1", unit="°C", min=-20.0, max=60.0, data_type=2, key=LwzSystemValuesRegisters.ACTUAL_ROOM_T_HC1), |
155 | 157 | LwzSystemValuesRegisters.SET_ROOM_TEMPERATURE_HC1: ModbusRegister( |
156 | 158 | address=2, name="SET ROOM TEMPERATURE HC1", unit="°C", min=-20.0, max=60.0, data_type=2, key=LwzSystemValuesRegisters.SET_ROOM_TEMPERATURE_HC1 |
@@ -211,7 +213,7 @@ class LwzEnergyDataRegisters(IsgRegisters): |
211 | 213 | ), |
212 | 214 | } |
213 | 215 |
|
214 | | -LWZ_SYSTEM_PARAMETERS_REGISTERS = { |
| 216 | +LWZ_SYSTEM_PARAMETERS_REGISTERS: dict[IsgRegisters, ModbusRegister] = { |
215 | 217 | LwzSystemParametersRegisters.OPERATING_MODE: ModbusRegister(address=1001, name="OPERATING MODE", unit="", min=0.0, max=14.0, data_type=8, key=LwzSystemParametersRegisters.OPERATING_MODE), |
216 | 218 | LwzSystemParametersRegisters.ROOM_TEMPERATURE_DAY_HK1: ModbusRegister( |
217 | 219 | address=1002, name="ROOM TEMPERATURE DAY", unit="°C", min=10.0, max=30.0, data_type=2, key=LwzSystemParametersRegisters.ROOM_TEMPERATURE_DAY_HK1 |
@@ -257,15 +259,15 @@ class LwzEnergyDataRegisters(IsgRegisters): |
257 | 259 | LwzSystemParametersRegisters.RESTART_ISG: ModbusRegister(address=1027, name="RESTART ISG", unit="", min=0.0, max=2.0, data_type=6, key=LwzSystemParametersRegisters.RESTART_ISG), |
258 | 260 | } |
259 | 261 |
|
260 | | -LWZ_SYSTEM_STATE_REGISTERS = { |
| 262 | +LWZ_SYSTEM_STATE_REGISTERS: dict[IsgRegisters, ModbusRegister] = { |
261 | 263 | LwzSystemStateRegisters.OPERATING_STATUS: ModbusRegister(address=2001, name="OPERATING STATUS", unit="", min=0.0, max=65535.0, data_type=6, key=LwzSystemStateRegisters.OPERATING_STATUS), |
262 | 264 | LwzSystemStateRegisters.FAULT_STATUS: ModbusRegister(address=2002, name="FAULT STATUS", unit="", min=0.0, max=1.0, data_type=6, key=LwzSystemStateRegisters.FAULT_STATUS), |
263 | 265 | LwzSystemStateRegisters.BUS_STATUS: ModbusRegister(address=2003, name="BUS STATUS", unit="", min=-4.0, max=0.0, data_type=6, key=LwzSystemStateRegisters.BUS_STATUS), |
264 | 266 | LwzSystemStateRegisters.DEFROST_INITIATED: ModbusRegister(address=2004, name="DEFROST INITIATED", unit="", min=0.0, max=1.0, data_type=6, key=LwzSystemStateRegisters.DEFROST_INITIATED), |
265 | 267 | LwzSystemStateRegisters.OPERATING_STATUS_2: ModbusRegister(address=2005, name="OPERATING STATUS 2", unit="", min=0.0, max=65535.0, data_type=6, key=LwzSystemStateRegisters.OPERATING_STATUS_2), |
266 | 268 | } |
267 | 269 |
|
268 | | -LWZ_ENERGY_DATA_REGISTERS = { |
| 270 | +LWZ_ENERGY_DATA_REGISTERS: dict[IsgRegisters, ModbusRegister] = { |
269 | 271 | LwzEnergyDataRegisters.HEAT_METER_HTG_DAY: ModbusRegister(address=3001, name="HEAT METER HTG DAY", unit="kWh", min=0.0, max=65535.0, data_type=6, key=LwzEnergyDataRegisters.HEAT_METER_HTG_DAY), |
270 | 272 | LwzEnergyDataRegisters.HEAT_METER_HTG_TTL_LOW: ModbusRegister( |
271 | 273 | address=3002, name="HEAT METER HTG TTL", unit="kWh", min=0.0, max=999.0, data_type=6, key=LwzEnergyDataRegisters.HEAT_METER_HTG_TTL_LOW |
@@ -364,7 +366,7 @@ def __init__(self, host: str, port: int = 502, device_id: int = 1) -> None: |
364 | 366 | device_id, |
365 | 367 | ) |
366 | 368 |
|
367 | | - async def async_update(self): |
| 369 | + async def async_update(self) -> None: |
368 | 370 | """Request current values from heat pump.""" |
369 | 371 | await super().async_update() |
370 | 372 | for registerblock in self._register_blocks: |
@@ -402,42 +404,53 @@ async def async_update(self): |
402 | 404 | else: |
403 | 405 | self._data[LwzSystemValuesRegisters.COMPRESSOR_STARTS] = compressor_starts_high * 1000 + compressor_starts_low |
404 | 406 |
|
405 | | - def get_current_temp(self): |
| 407 | + def get_current_temp(self) -> float | None: |
406 | 408 | """Get the current room temperature.""" |
407 | 409 | return self.get_register_value(LwzSystemValuesRegisters.ACTUAL_ROOM_T_HC1) |
408 | 410 |
|
409 | | - def get_target_temp(self): |
| 411 | + def get_target_temp(self) -> float | None: |
410 | 412 | """Get the target room temperature.""" |
411 | 413 | return self.get_register_value(LwzSystemParametersRegisters.ROOM_TEMPERATURE_DAY_HK1) |
412 | 414 |
|
413 | | - async def set_target_temp(self, temp): |
| 415 | + async def set_target_temp(self, temp: float) -> None: |
414 | 416 | """Set the target room temperature (day)(HC1).""" |
415 | 417 | await self.write_register_value(LwzSystemParametersRegisters.ROOM_TEMPERATURE_DAY_HK1, temp) |
416 | 418 |
|
417 | | - def get_current_humidity(self): |
| 419 | + def get_current_humidity(self) -> float | None: |
418 | 420 | """Get the current room humidity.""" |
419 | 421 | return self.get_register_value(LwzSystemValuesRegisters.RELATIVE_HUMIDITY_HC1) |
420 | 422 |
|
421 | 423 | # Handle operation mode |
422 | 424 |
|
423 | 425 | def get_operation(self) -> OperatingMode: |
424 | 426 | """Return the current mode of operation.""" |
425 | | - op_mode = int(self.get_register_value(LwzSystemParametersRegisters.OPERATING_MODE)) |
426 | | - return OperatingMode(op_mode) |
| 427 | + op_mode = self.get_register_value(LwzSystemParametersRegisters.OPERATING_MODE) |
| 428 | + if op_mode is None: |
| 429 | + return OperatingMode.EMERGENCY_OPERATION |
| 430 | + return OperatingMode(int(op_mode)) |
427 | 431 |
|
428 | | - async def set_operation(self, mode: OperatingMode): |
| 432 | + async def set_operation(self, mode: OperatingMode) -> None: |
429 | 433 | """Set the operation mode.""" |
430 | 434 | await self.write_register_value(LwzSystemParametersRegisters.OPERATING_MODE, mode.value) |
431 | 435 |
|
432 | 436 | def get_heating_status(self) -> bool: |
433 | 437 | """Return heater status.""" |
434 | | - return bool(int(self.get_register_value(LwzSystemStateRegisters.OPERATING_STATUS)) & (1 << 2)) |
| 438 | + value = self.get_register_value(LwzSystemStateRegisters.OPERATING_STATUS) |
| 439 | + if value is None: |
| 440 | + return False |
| 441 | + return bool(int(value) & (1 << 2)) |
435 | 442 |
|
436 | 443 | def get_cooling_status(self) -> bool: |
437 | 444 | """Cooling status.""" |
438 | | - return bool(int(self.get_register_value(LwzSystemStateRegisters.OPERATING_STATUS)) & (1 << 3)) |
| 445 | + value = self.get_register_value(LwzSystemStateRegisters.OPERATING_STATUS) |
| 446 | + if value is None: |
| 447 | + return False |
| 448 | + return bool(int(value) & (1 << 3)) |
439 | 449 |
|
440 | 450 | def get_filter_alarm_status(self) -> bool: |
441 | 451 | """Return filter alarm.""" |
| 452 | + value = self.get_register_value(LwzSystemStateRegisters.OPERATING_STATUS) |
| 453 | + if value is None: |
| 454 | + return False |
442 | 455 | filter_mask = (1 << 8) | (1 << 12) | (1 << 13) |
443 | | - return bool(int(self.get_register_value(LwzSystemStateRegisters.OPERATING_STATUS)) & filter_mask) |
| 456 | + return bool(int(value) & filter_mask) |
0 commit comments