Is there anyway to set the initial state and correct the state of a utility meter or integration sensor manually?
When I add a utility meter it starts counting now and so the daily, monthly and yearly consumption starts at zero. Waiting a year to have a correct consumption for yearly energy use seems a waste when you have a “smart” home.
My heat pump energy meter is currently at about 3200 kWh and I whould like my HA energy sensor to start there. The I could correct it monthly if there readings are slightly off and there’s a difference between the sensor and the meter
I feel I have searched everywhere and tried every component I can find but have not found a solution. Setting the sensors state in developer tools gets overridden on next sensor update from my esphome pulse counter sensor.
I could do that, but in my experience these power sensors are not 100% accurate so to do a manual reading for correction later I would have to calculate the difference between the meter and the energy sensor and update the 3200 offset in configuration.yaml and reboot HA. Or I could make the offset an input number to avoid reboot, but I would still have to calculate the offset manually or via a script.
I really hope I missed something easy or that somebody made a custom component that allows manual state changes after initialisation.
Yes, I’ve also shut down the db as I’d rather avoid issues, but in theory, a db like mysql can accept simultaneous writes from thousands of sources in high performance environments…
Changing the db is not changing the value. Maybe we should also change the persistent value in the .storage core persistent file.
EDIT: Did it. First stop HA instance. Change the last state value of the sensor in the database. Then open config/.storage/core.restore_state file and find the relevant sensor. Change the state value to the same value you did in the db. Then start HA again…