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,
|
"voltage/average": 0x002A,
|
||||||
}.items()
|
}.items()
|
||||||
):
|
):
|
||||||
|
try:
|
||||||
read = self.modbus.read_input_registers(address, 2)
|
read = self.modbus.read_input_registers(address, 2)
|
||||||
longs = word_list_to_long(read)
|
longs = word_list_to_long(read)
|
||||||
if len(longs) == 1:
|
if len(longs) == 1:
|
||||||
self._publish(readable, decode_ieee(longs[0]))
|
self._publish(readable, decode_ieee(longs[0]))
|
||||||
else:
|
else:
|
||||||
self._publish(readable, sum([decode_ieee(x) for x in longs]))
|
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:
|
if idx % 20:
|
||||||
self.modbus.close()
|
self.modbus.close()
|
||||||
self.modbus.open()
|
self.modbus.open()
|
||||||
|
|
Loading…
Reference in a new issue