Shelly - Power Meter resets total consumption on power loss

Not quite. What you need to do is keep track of the last reading from the device.

    if(currReading < lastReading) tcp = tcp + currReading
    else tcp = tcp + (currReading - lastReading)

The first reading after the reset will treat the currReading as the delta to add to your running total. Every reading after that we add the difference between the current reading and the last reading to the running total.

1 Like