Background: I have various Shelly Plug S’s in my home, which are integrated to Home Assistant. Yesterday I went to see some history data from HA, and it had very nicely just lost months worth of consumption data. I decided that it’s finally time to install EmonCMS and start to collect the data there as well (as a better time series DB for the job).
I have now managed to expose both W and kWh entities from Home Assistant to EmonCMS, and those show as a single input node with multiple err… attributes? Anyway, I can see the current values on the Inputs page:
I also managed to create related feeds by reading the basic guides. The power input updates every 10 seconds (minimum time for the time series DB, right?), and here is the input processing for it:
The kWh input updates (really) every 60 seconds (because based on HA data, that is the interval when Shelly plugs send that info), and here is the input processing for it:
I also store this data in a feed with 60 second slots.
My question is:
I have two different ways to obtain the kWh data, either directly from a Shelly Plug S, or by calculating it form the W value in EmonCMS. Is one these more preferable than the other? On a long run, can one of these provide me more accurate data over time than the other?
It is really your choice - linked with what happens when things go wrong.
First, the energy values from both sources should work out the same. If your Shelly Plug has a different idea of time to emonCMS (which eventually works on Internet time), then I can see that a small error might arise from there. Or it could be due to the values sent being rounded to the nearest unit, or truncated.
But I think the main concern is what happens when the Shelly resets its memory of the accumulated energy. If you use the Wh or the kWh accumulator, these remember the last “good” value when the incoming feed returns to zero and continues accumulating regardless, as the ‘Help’ explains: “This processor ensures that when the emonTx [read this as ‘your Shelly’] is reset the watt-hour count in emoncms does not reset, it also checks and filters out spikes in energy use that are larger than a max power threshold set in the processor, assuming these are errors, the max power threshold is set to 60 kW.”
I can only say why the emonTx accumulates the energy on-board and sends it with the power values - it was to get around the problem of data lost in transit. We also send the power in multiples of 1 watt, but the energy that is represented by the fractional part that is lost is carried forwards into the next value sent.