From c99cb0e2ca1b38ce1bc167a8011bbfbea3f2c2bc Mon Sep 17 00:00:00 2001 From: Olaf Strama Date: Thu, 17 Oct 2024 21:19:59 +0200 Subject: [PATCH] bugfixing --- custom_components/weishaupt_modbus/entities.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/custom_components/weishaupt_modbus/entities.py b/custom_components/weishaupt_modbus/entities.py index 48574ca..c6bc5fe 100644 --- a/custom_components/weishaupt_modbus/entities.py +++ b/custom_components/weishaupt_modbus/entities.py @@ -87,6 +87,8 @@ def calcPercentage(self,val: float): def translateVal(self): # reads an translates a value from the modbus mbo = ModbusObject(self._config_entry, self._modbus_item) + if mbo == None: + return None val = mbo.value match self._modbus_item.format: case FORMATS.TEMPERATUR: @@ -104,6 +106,8 @@ def translateVal(self): def translateVal(self,value): # translates and writes a value to the modbus mbo = ModbusObject(self._config_entry, self._modbus_item) + if mbo == None: + return val = None match self._modbus_item.format: # logically, this belongs to the ModbusItem, but doing it here @@ -168,9 +172,13 @@ def translateVal(self): mb_x = ModbusItem(self._modbus_item.getNumberFromText("x"),"x",FORMATS.TEMPERATUR,TYPES.SENSOR_CALC,DEVICES.SYS, TEMPRANGE_STD) mbo_x = ModbusObject(self._config_entry, mb_x) + if mbo_x == None: + return None val_x = self.calcTemperature(mbo_x.value) / 10 mb_y = ModbusItem(self._modbus_item.getNumberFromText("y"),"y",FORMATS.TEMPERATUR,TYPES.SENSOR_CALC,DEVICES.WP, TEMPRANGE_STD) mbo_y = ModbusObject(self._config_entry, mb_y) + if mbo_x == None: + return None val_y = self.calcTemperature(mbo_y.value) / 10 match self._modbus_item.format: