Collect energy consumption over power-fails / power offs

Hi there,
I got a question regarding tracking my energy consumption.

I have several smart plugs (zwave) in use, they all can report current load and energy consumption.
I collect the item values in the database so I can see the chart over time for the energy consumption.

Some of them persist the energy consumption so no problem if I power them off or there is a power failure.
But some of them loose the energy consumption values it there is a power failure or if I remove them from the power plug. In these cases I loose my collected energy consumption and it starts again at zero.

Has someone an idea how to work around this problem?
Is it possible to persist the energy consumption value e.g. on a daily base and write it back to the device if it re-connects?
Or any other ideas how to solve that?


Sell the plugs which forget their settings on eBay and replace by plugs which persist the values.
Every other “solution” is just a nightmare to setup and maintain.

Not what I hoped for, but not a surprise :slight_smile:
Unfortunately the ones that persist the values have other issues, and my favorite ones from devolo (which I really like and they work smooth) have this problem.
Also, it is not so easy to determine upfront if a smart plug persists or not, it’s often not described in the user manual.
Can you recommend some?

Do they report back the current (now) consumption? 8f so, log that and calculate the watts/min and work out your kw/h.

Rather use your own master value rather than the plug.

1 Like

Fibaro Wall Plugs. I haven’t had any issues with gen5 but also have an aeotec gen 5 stick.
There are mixed reports on the Fibaro plugs on Amazon but that’s the case with nearly all Z-Wave equipment :frowning:

1 Like

Poll them for data every 10 seconds. Log it to something with persistence like RRDs.

For a more “house wide” energy consumption you could try one of these: (They also do a non-DIN rail version)

You’ll need a MODBus to Wifi converter. I only have a custom one for a solar panel, but as I might be going down this route, I will publish my firmware for reading data from these meters.

Do you count up forever or do you reset to 0 periodically (e.g. once a month)?

I assume you are using persistence to store the values into the database, right? If so you will need to use restoreOnStartup for these Items.

Create a Rule that triggers when the Item for these plugs changes.

if(previousState > currentState)
    triggeringItem.postUpdate(previousState + currentState)

Now where it get’s complicated is handling the case where you deliberately reset the value to 0. You may have to do something like Design Pattern: Manual Trigger Detection.

You will also need to account for changes to/from NULL and UNDEF states and you will likely need to case the states to Numbers. And that erroneous low value will get saved to your persistence. To avoid that, you will need to use a proxy Item to persist the value and in that Rule above update the proxy Item instead of the linked Item.

thanks for your tips…
very interesting… maybe I’ll use this for the plugs who cannot persist their values instead of selling them… and buy new ones.
One thing isnt clear to me:

-> Yes, correct

-> is this some setting in the item?

Is this the implementation of “restoreOnStartup” or is it additionally?

Thx Markus

This is what you need to implement in a Rule to detect when the running sum was lost on the device and update it with the last running sum value. It’s just notional and not a complete solution.

1 Like

thx, I think i got it…
I’ll give it a try :slight_smile: