more error handling

This commit is contained in:
Franzi 2024-08-05 09:53:24 +02:00
parent 734f4cf4e9
commit b35b19a007
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -104,12 +104,15 @@ class SDM630_MQTT:
"voltage/average": 0x002A,
}.items()
):
try:
read = self.modbus.read_input_registers(address, 2)
longs = word_list_to_long(read)
if len(longs) == 1:
self._publish(readable, decode_ieee(longs[0]))
else:
self._publish(readable, sum([decode_ieee(x) for x in longs]))
except Exception:
LOG.exception(f'error while reading {readable} from meter')
if idx % 20:
self.modbus.close()
self.modbus.open()