more error handling
This commit is contained in:
parent
734f4cf4e9
commit
b35b19a007
1 changed files with 9 additions and 6 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue