Closed jyavenard closed 3 years ago
I agree. Note that a new integration called powercalc https://github.com/bramstroker/homeassistant-powercalc does just this. It updates every 10 minutes or at a different interval as specified by the option scan_interval
I believe the root cause of this is #16
I should have amended that bug maybe rather than creating a new one.
Note that a new integration called powercalc https://github.com/bramstroker/homeassistant-powercalc
the issue here is the original value of the sensor created by the iotawatt integration ; if the sensor isn't updated, it doesn't matter how regularly you integrate it. you'll always get the wrong result
This is an issue I discussed in https://community.home-assistant.io/t/custom-component-iotawatt-energy-monitor-integration/254110/107?u=jyavenard
What we can see when dragging the mouse over that graph, we can see that there were no updates to the sensor until 9:00:39 where it reads -188.1W
As I use the Riemann Sum integration with the right method, it considers that -188.1W is the average wattage since the last read. so 0.1881kWh * 9h = 1.06kWh will be what the first value stored will be for the Export Energy for the day; skewing the result of the entire day.
I had opened that bug: https://github.com/home-assistant/core/issues/55130
After writing a little automation writing to a file whenever a sensor was updated:
it quickly became evident on what was happening:
in there I see every 30s:
the iota output sensor for the export output (which would be 0 at this time of night) aren't updated. As such when dealing with data points that should be: (00:00:00, 0) (00:00:30, 0) (00:01:00, 0) (00:01:30, 0) ... repeat (08:59:30, 0) (09:00:00, 188.1) (09:00:30, 205)
what the
integration
gets to be provided is in fact: (00:00:00, 0) (09:00:00, 188.1) (09:00:30, 205)And so the first data entered at 9AM will be 188.1W9h = 1.692kWh instead of 188.1W30s = 188.1W*30/3600h = 0.0015675kWh
The sensors must be updated even if the value isn't changing as it otherwise can't be used with the HA
integration
and provide an accurate result.