I know what you mean - I only need it on a few entities for automations to work properly, but I would much prefer it to work with every entity for informational purposes (especially lights, motion detection, etc).
Here for example I make extensive use of last-changed state for my lights - I restarted HA an hour ago but they certainly didn’t turn on/off at that time which is annoying. Whilst I don’t need it here for HA to function, I would very much prefer them to have correct values.
This has been my number one annoyance with HA since I started using it a couple of years ago. I restart now and again for HACS updates and it’s extremely annoying to see all my last-changed statuses reset on the dashboard. Especially for some of the security sensors which throw me off now and again.
I know I could create workarounds but it just adds a lot more complexity and convoluted code. It would be great to either set the current last-changed to not reset on startup in the settings (not sure if technically possible) or to have a new last-changed attribute that persists through restarts.
Every new release I hope something is done to combat this, hopefully one day it will as I’d imagine this is quite a common use case for a lot of consumers! I don’t believe in the “This isn’t too much of an issue if you don’t restart” argument as to the average consumer/user you’d look at an attribute called “last-changed” and would expect it to be the last time that sensor changed, not that it changed due to a restart. Finding a solution to that seems better than just hoping people don’t need to restart often imo.
Maybe introduction of new “Discussioncs” regarding Feature requests will trigger some recognition regarding this topic? As it is 2nd top-voted WhatTheHack idea…
But it does not just magically appear . So far there is no agreed solution (that I am aware of), so no related changes as a result in the upcoming release.
from discussion on github one could have feeling that core devs have no interest in that improvement until some other person puts ready to use solution onto the table.
Stumbled across this WTH, as I was looking for a solution to also save some timestamps from varoius sensors during restart/reboot.
Voted for this, too…
For some reason due to some architecture / design that has been around for a while makes the last changed / last updated properties of an entity to be handled differently from all other properties. And it seems like some made som spaghetti coding to make it really impossible to change as those are foundation that actually makes home assistant not fall into pieces
All software projects have similar “things” in them. Something that stinks, was introduced when someone had a bad day at the office, but is connected to everything in an undocumented spaghetti way. And no one dares to touch it and/or fix it as who knows what might happen or break elsewhere.
That is why i proposed adding another spaghetti layer on top. An attribute with the name of persisted_last_changed or similar, for the last_changed property. And only update it when a value change, not on restart, and treat it like any other attribute that gets recalled to the last known state after reboot.
1000 upvotes will not change anything, it stinks and no one still wants to touch it
The lack of persistence for states is a big problem for what I want to do with HA.
I have a server that I can work out if it’s on, but it’s independent direct attached storage unit is a switch (for on/off), it must be shutdown AFTER the main server. I have a script that will check states and all that.
But updating HA 10 times a day, crashes, etc, I will loose my states which can potentially lead to my server turning off incorrectly causing data corruption.
Not to mention it’s annoying to have to tell it my lights are on…
(I have an automation that will not turn on lights if it’s already set to on, which you know, makes sense…)