Open jezzaaa opened 1 month ago
Hello,
Energy sensor is persistant and is restored at restart. I can't do more than this on my own. Did you stop and restart HA properly ? I guess on a hard restart, the db have not the time to be updated and you may have some delta is not persisted correctly.
The other point you could check, the persistance delay, named commit_interval
. This is in the recorder.yaml
file.
The value in my env:
That mean I can loose up to 10 sec of data in case of haard stop.
I can't find a file called recorder.yaml, sorry. Is it part of VT or HA? Reducing commit_interval would probably reduce the chances of negative consumption but not eliminate it - this seems to be more of a work-around than a solution.
I'm fairly sure my HA restarts were graceful (via the GUI), as part of HA or integration upgrades.
I'm wondering if a better solution might be to reset the energy accumulator to zero every time VT starts up. I believe this is what happens with smart plugs providing their own energy counters, when they are power cycled, and Home Assistant seems to recognise this special case and handle it correctly - that is, power usage doesn't suddenly go negative when a smart plug is disconnected and re-connected.
In my configuration.yaml, I have this:
# Recorder and purge config
recorder: !include recorder.yaml
may be the recorder specification is directly in your configuration.yaml and not in the recorder.yaml which is included in the configuration.yaml
I have no recorder specification in configuration.yaml.
Perhaps I need to create it in configuration.yaml (or add "recorder: !include recorder.yaml" and create recorder.yaml). I'll give that a try.
Reading the documentation, the commit_interval default is 5 seconds. As I don't have any "recorder:" settings in my configuration.yaml or included files, my commit interval must be 5. Increasing to 10 (as you have it) would increase the likelihood of lost data samples during a reboot, so I don't think that is advisable.
If a commit_interval delay were causing this issue, then I would expect to see a negative energy consumption value that is around 5 seconds of consumption. Instead, I see several hours of samples before the value reverts. It's as if the total consumed energy goes back 8 or more hours in time. Certainly not 5 or 10 seconds.
So I believe that the commit_interval value is unrelated to the problem, and changing its value is not going to make things better or worse by the quantity of error that I'm seeing.
I use VT with two electric heaters powered by smart plugs. When Home Assistant is restarted, the "Energy" sensor sometimes goes back to a previous value, causing the Energy dashboard to show negative consumption.
Version of the custom_component
6.2.9 -->
Configuration
My VTherm attributes are the following:
If it is releveant to regulation performance or optimisation some curves are needed
Describe the bug
I have two virtual thermostats setup using VT. Both are using a smart plug to switch off/on electric heaters via ZigBee temperature sensors. The VT energy sensors are used in the Energy dashboard to show consumption over time. The Energy dashboard sometimes shows negative usage.
Energy sensors are supposed to be be ever-increasing, or reset to zero in some situations. However I have found that the energy sensors sometimes revert to a previous value around the time of restarting Home Assistant.
I'm trying to: have accurate graphs in the Energy dashboard, that show only non-negative power consumption.
And I expect: the energy accumulators provided by VT to always increase, or reset to zero when required, but to not go "back in time" to a previous non-zero value.
But I observe this .... the energy accumulators sometimes reduce to a positive value, when Home Assistant is restarted.
I read the documentation on the README.md file and I don't find any relevant information about this issue.
Debug log
I no longer have the logs from the last time this happened. If it would be helpful, I can try to reproduce the behaviour by restarting Home Assistant (or VT) while the heaters are consuming energy.