Skip to content

Commit 25bb43d

Browse files
committed
check and debugging of connection lost
1 parent 729f182 commit 25bb43d

File tree

3 files changed

+21
-322
lines changed

3 files changed

+21
-322
lines changed

custom_components/weishaupt_modbus/entities.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737

3838
async def check_available(modbus_item, config_entry) -> bool:
39+
"""function checks if item is valid and available"""
3940
_modbus_api = config_entry.runtime_data
4041
mbo = ModbusObject(_modbus_api, modbus_item)
4142
_useless = await mbo.value
@@ -410,8 +411,18 @@ def calc_power(self, val, x, y):
410411

411412
def translate_val(self, val):
412413
"""Translate a value from the modbus."""
414+
# this is necessary to avoid errors when re-connection heatpump
413415
if val is None:
414416
return None
417+
if len(val) < 3:
418+
return None
419+
if val[0] is None:
420+
return None
421+
if val[1] is None:
422+
return None
423+
if val[2] is None:
424+
return None
425+
415426
val_0 = self.calc_percentage(val[0])
416427
val_x = self.calc_temperature(val[1]) / 10
417428
val_y = self.calc_temperature(val[2]) / 10

custom_components/weishaupt_modbus/itemconst.py

Lines changed: 0 additions & 317 deletions
This file was deleted.

0 commit comments

Comments
 (0)