OctoPrint-TPLinkSmartplug icon indicating copy to clipboard operation
OctoPrint-TPLinkSmartplug copied to clipboard

[Feature Request]: Add additional field to database representing "corrected" total energy usage

Open puterboy opened this issue 5 months ago • 3 comments

I noticed that sometimes my TPLink plug seems to reset (maybe do to a firmware update or just a glitch), in which case the total column in the energy_data.db database reverts to 'zero' This of course messes up the cumulative energy consumption and shows up as a sharp drop in the total in the corresponding graph.

This can be corrected by adding an additional corrected_total field to the database, calculated as follows:

  • If new total >= old total, corrected_total = total
  • else corrected_total = old total + total

Now this might night catch all reset situations if the plug resets and then runs for a long time without octoprint running so that the reset total exceeds the last stored total, but it should correct most errors...

Adding this correction should help with longer term energy tracking... And in any case you would still have the raw 'total' field present...

You may also want to add a reset button that would allow one to manually reset the `total'

puterboy avatar Feb 04 '24 01:02 puterboy