last_changed value should be preserved after a restart (or new attribute added) #215
Replies: 1 comment 2 replies
-
|
One contextual comment: I've heard the devs didn't want to preserve the value across restarts because HA has no knowledge if the sensor state may have changed during the restart . Therefore I'd suggest creating a new attribute called last_known_changed to make it a bit clearer that this is only want HA is aware of. P.S. TBH I would push back a bit on the thinking of the devs on this because if say HA cannot make guarantees of knowledge while it is down about the state of the sensor, if we are being pedantic then, it is also equally false to set the "last_changed" to the HA restart time because that's also inaccurate. The sensor likely did not change when HA restart (that's only HA's best option). So if we are fully pedantic, the sensor should stay "UNKNOWN" upon restart UNTIL the first state change is detected. Of course, that would be even less useful. So, being deeply pedantic about this doesn't really help either way IMHO :). But if the devs are really set on not changing the behavior of "last_changed" then introducing a "last_known_changed" is a nice compromise. BTW nice to see this perennial request resurrected in the new feature request area 👍🏻. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe your core improvement
Make last_changed preserve value after restart or make other last_known_value (or similiar) that would allow to be enabled and that would ignore HA restart event.
I understand that moment when HA restarts is 'unkown' and sensor update itself to new state after HA is started, but in real world scenario I have tons of entities (all windows, doors and other rarely used stuff) that I can't simply keep a track of.
I have windows that are opened only when I go to roof, I have technical doors that I open only when changing filters. I have movement sensors in rooms showing "last movement 4 hours ago" where no one has been since week - it's just a HA restart.
Making templates/helpers and workarounds is simply not the easiest way to be, yet this "issue" with last_changed is top-voted every WTH year there was.
Current limitations
last_changed is changed when HA restarts.
Sensors are showing 'last_update' value since last HA restart/update, not when they really changed the state.
Technical benefits
Dashboards could finally show real "last_changed" without need to any workarounds, additionals sensors or wondering if it was restart of HA.
Additional context
In terms of discussions with less-technical people, it's even encouraging not to update HA and not loose 'state'. It's kind of non-logic to have such an advanced home automation system that's missing key feature - preserving "last known" changed moment for an entity.
Beta Was this translation helpful? Give feedback.
All reactions