Skip to content

Commit

Permalink
handle modbus errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelErmer committed Mar 9, 2023
1 parent d3def00 commit 9048776
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dbus-solax-x1-pvinverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, servicename, deviceinstance, paths, productname='Solax X1', c
else:
self._dbusservice.add_path(
path, settings['initial'], gettextcallback=settings['textformat'], writeable=True, onchangecallback=self._handlechangedvalue)

self._updateRunning = False
# last update
self._lastUpdate = 0
self._lastCloudUpdate = 0
Expand Down Expand Up @@ -286,6 +286,9 @@ def _predictACPowerValue(self, lastUpdate, lastValue, lastValueChangePercSecond)
return lastValue*((1+((time.time() - lastUpdate)*lastValueChangePercSecond)))

def _update(self):
if (self._updateRunning):
return True
self._updateRunning = True
logging.info("Running _uppdate")
config = self._getConfig()
try:
Expand Down Expand Up @@ -411,7 +414,8 @@ def _update(self):
logging.info("_update failed, modbus not ready yet")
except Exception as e:
logging.critical('Error at %s', '_update', exc_info=e)


self._updateRunning = False
# return true, otherwise add_timeout will be removed from GObject - see docs http://library.isr.ist.utl.pt/docs/pygtk2reference/gobject-functions.html#function-gobject--timeout-add
return True

Expand Down

0 comments on commit 9048776

Please sign in to comment.