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