How to detected when ZigBee entity is offline or timeout'ed

One place I found where “last seen” can be taken is a file /config/.storage/zha.storage
e.g.:

{
    "version": 1,
    "key": "zha.storage",
    "data": {
        "devices": [
            {
                "name": "Silicon Labs EZSP",
                "ieee": "60:a4:23:ff:ff:ff:ff:ff",
                "last_seen": 1624646040.4617698
            }, 
           [...]

So I am reading this file with a Node-RED ‘function’ node, parsing the data with a small Javascript code (e.g. converting the UNIX timestamp to a human readable) and doing actions like sending notifications, etc.

Frankly, I am not sure if this is the optimal way to do it, but after searching for info how to fetch “last seen” timestamp I did not find any alternatives.

Watching this parameter is important, as I have seen cases when “last UPDATED” attribute of a Zigbee entity has been refreshed (e.g. after HASS restart), but “last seen” of the Zigbee device has not, whereas actually the device became offline and needed attention.

1 Like