Update Entitiy not updating entity?

I am probably doing something wrong here, but I cannot figure out what it is.
Maybe one of you can spot my mistake.

I go to the Dev-Tools under Services and call the Update entitiy Service with the Entitiy UPS Battery adc:

When I click on “CALL SERVICE” and then check the entity under “STATES”, nothing changed:

I would expect the “Last updated” Field to change to some seconds ago.

Last updated will only change if there is a state change. If you run the update service and nothing changes in the state object, last updated will not show a new value.

OK how do I “refresh” the Sensor then?
My statistics go stale because it is not updated frequently enough.
So I want to update it with the current (and still correct) value.

Is there any way to force an Update, such as with the Variable Extension?

That is how you get a new state. But the device isn’t reporting a new state, so you won’t get a new ‘last updated’. There is no way to work around this without getting ‘inventive’ by changing the state via a template sensor.

In general, home assistant is designed to reduce the number of state changes so that it doesn’t bloat your database. So it will only produce state change events when the states actually change.

I see…

I solved this by a variable that I update every 30 seconds via an automation.
I need to update many entities regularly anyway as otherwise they revert to unknown if they havent been changed in a certain time range. Absolutely anoying.

For this usecase the stunt with the var.update would not be neccessary if there would be an option in the statistics sensor to keep the last value if there are no further updates.

It already does this. Maybe you can elaborate on your problem? You’ve only posted that you want to update your entity.


I calculate the Fill Level of my Batteries by taking the Voltage and Temperature reported from a Shelly UNI.
The Temperature is very steady… unless charging it changes very little if at all. So long times without any Update to the Entitiy.
Same is true for the Voltage.
However when running on Battery, the Voltage jumps a lot up and down, throwing of any calculations.
So I figured a 3 Minute average accross the Voltage gives a nice steady measurement, that is in line with what I measure with a Multimeter directly at the batteries.

But obviously, when the Voltage is not jumping around madly, aka if I neither charge nor discharge the batterys there is no change in voltage for many minutes up to hours… so the 3 minute linear_average statistics sensor runs dry and goes unknown.

Using the last 100 or so measurements instead of measurements from the last 180 seconds does not work either, because then the statistics sensor is not nearing the actual values even after hours as the majority of measurements in the calculation are still from a time when the value changed a lot, despite this beeing hours ago.
Any smaller numbers lead to large fluctuations in the average… so 3 minutes or ~100 measurements turned out to be a good compromise between responsiveness and steadiness.

If you have any Ideas how to solve this without having to run an automation that refreshes the values every couple of seconds to keep the statistics sensor happy please let me know.

Use an SQL sensor and perform the calculation yourself in the template.

Had to look up what that is.
Oh how very interesting…

That sounds like the solution to so many of my struggles…