It changes value in real time and you can watch it update the time since the last update of the sensor (sensor you are monitoring). Since it is an entity you can add it to the front end but it is not necessary. I was just watched it from the Dev tools-> states page. If I forced the speedtest sensor to update then the template sensor went back to 0 and started counting up again. It appeared to update every minute.
it gives the time gone by as 00:00:00 (but it is a string)
to lose the seconds change [11:19] to [11:16]
to see the amount of seconds gone by as int replace |timestamp_utc with .seconds and lose the [11:16] part
The thread is very interesting. Monitoring for stale data from a sensor looks to be very useful. I am trying another approach, however. I am attempting, with mixed sucess to use device_tracker to determine if a sensor is transmitting. NMAP performs the needed function for showing on the UI status (Home or Away) for the sensor. However, NMAP causes my rpi3 wifi to lockup after a short run time. Still trying to sort out the cause of that. NOTE: edited original post to correct error citing nodemcu wifi issue instead of rpi3 wifi issue.
As of 0.53, there’s a new counter component that might be used to check if something isn’t working. For example, setting a counter at 24, and decreasing it by one every hour (resetting it at 24 whenever an event arrives), you could set an automation triggered by the counter reaching 0 that would let you know it’s been 24h since last update.
I have the same problem with my tellstick sensors, however their value does not say “undefined” it just stays the same temperature as the last reading. I assume your solution wont work for this case?
Just want to make sure that you actually have the sensor say “undefined” as a value when its battery died
i never had any battery operated sensors in HA.
and my solution was something i figured out for someone else, 4 years ago!
i doubt if it still would work with the amount of changes that HA made in those 4 years.