First solution didn’t work as ReneTode rightly points out
My best solution is a bit hacky so happy for any one to suggest a better solution. I have created a new input boolean and an automation which switches it off 1 minute after home assistant_start. The new template sensor is:
The next problem is that the value of this sensor is a string, i.e. 7 seconds or 1 minute so I cannot set up an automation that triggers if value is great than x. I also tried manually calculating the time since last change but this gives you another string e.g 00:00:07.85775. I would ideally like a float/int of how many seconds (or minutes) it has been since it last updated but cannot workout how to do it
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.