Looking for a way to gather all devices that haven’t been seen in a certain amount of time (12 hours for example). The end goal is to ensure all devices are still connected/communicating, because battery readings are not always the best and sometimes devices disconnect regardless of batteries as well. I already have automation for “unavailable” so I guess “last seen” is the most optimal target? That should work at least for Z-Wave and Zigbee devices.
I actually had the exact same goal for the exact same reason today, as the battery in one of my leak sensors died 2 days before a leak hit it, and the last check-in still showed the battery at like 30%. Since this question was the first Google result I got, and no one had answered it yet, I did some further digging. The following code uses the Auto-Entities card from HACS to render a list of all leak sensors with a last_seen of more than 12 hours, sorted from oldest to most recent:
Note that this assumes you have entities suitably named to match the wildcard example above, where it will match names such as sensor.kitchen_sink_leak_last_seen