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 9 forks source link

Cached values while offline #16

Open poggenpower opened 2 years ago

poggenpower commented 2 years ago

When the power switch went off at night, because of solar power outage, rtcmon is responding with the last read values. See screenshot. Is this by intention? Is there a way to reset the values when offline?

Screenshot 2022-04-04 at 23 53 44
svalouch commented 2 years ago

That's mostly an oversight / TODO, as my inverter is online all the time unless the BMS fails I had not really a driver to implement it yet, sorry.

The plan is to either add a reset()-function to the dataclasses or re-instantiate them at the appropriate time, this would automatically make the metrics output empty as all values would be at the default None.

I guess the best way to do this is by making the DeviceManager go through its own startup sequence (again), which triggers (re)building its inventory so it knows what to query for. I thought about two triggers:

  1. When the connection has been lost for longer than a few seconds/minutes (configurable) to avoid the slow inventory rebuild when there's just a small a fluke on the network.
  2. When a signal such as SIGHUP is received, so if a firmware update is too fast one can trigger this without having to restart the whole thing. Though that's very low prio.

Rebuilding the inventory is important anyway, because changes to the setup such as (physically) changing the battery or solar generator configuration need to be detected, and they happen when the device is offline. So this is the perfect time to cause this.