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.
The consequence of this problem was discussed in : https://community.home-assistant.io/t/custom-component-iotawatt-energy-monitor-integration/254110 in which I noticed an issue when calculating the integration of a power sensor in order to get the energy accumulated since the last read. I also opened that bug: https://github.com/home-assistant/core/issues/55130
What we see is that when integrating the power sensor some datas were ignored, causing the integration to return invalid result.
However, 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.