svalouch / rctmon

Pulls data from RCT Power GmbH devices for use with monitoring systems.
https://rctmon.readthedocs.io
GNU General Public License v3.0
17 stars 8 forks source link

fix: connection recover after timeout #15

Closed poggenpower closed 2 years ago

poggenpower commented 2 years ago

Had issues to reconnect to powerswitch after nightly shutdown.

rctmon ran into an endless:

rctmon.daemon.socket - WARNING - No data received for 180 seconds, disconnecting
rctmon.daemon.socket - INFO - Socket disconnected
rctmon.daemon - INFO - Time to attempt reconnection

once the powerswitch shutdown, because of solar power loss at night. But in the morning when the powerswitch was back online rctmon didn't recover and stay in that loop.

Small timer reset when connecting fixes this issue.

Another option would be to change the logic here https://github.com/svalouch/rctmon/blob/main/src/rctmon/daemon.py#L241-L269 and run code in the last else part right after re-connection, which triggers a real read before resetting the counter.
If you prefere that approach let me know. I will update the PR accordingly.

ouned commented 2 years ago

https://github.com/svalouch/rctmon/pull/17

saw yours after creating mine xD sry

we went with the same code, good sign :)

poggenpower commented 2 years ago

As this was also fixed in #17 I will close this one.