I tried appdaemon/ench to detect stales, unfortunately there’s too much false positive as it only check entities, not devices as a whole.
This is a problem especially with bluetooth devices that only report values once in a while when it changes.
Any ideas?
You could continue to do it based on entity, but then use a template to get all other entities for the device to see if they’re all unavailable.
As per Templating:
-
device_id(entity_id)
returns the device ID for a given entity ID or device name. Can also be used as a filter. -
device_entities(device_id)
returns a list of entities that are associated with a given device ID. Can also be used as a filter.
I monitor unavailability, but only for longer than 30 minutes, so doing it at an entity level generally works for me. However, there are some seasonal devices like xmas lights that mess things up. For these I have put the following in customize_glob.yaml
:
"*xmas*":
ignore_unavailability: true
All of my xmas entities have ‘xmas’ in the entity_id, so this creates an attribute on each one that I can also test to ignore unavailability. Note that the state needs to change for the attribute to be set, even after you have reloaded customizations. Although I think you can call update_entity
(have not tested).
I didn’t say entities where unavailable, that’s another problem.
As an example, I have Xiaomi flower care bluetooth sensors.
It exposes several entities like battery, light, temp, etc.
But values are only updated when changed, dunno if it’s a device problem, a bluetooth integration problem or a HA problem.
Of course they can be temporary unavailable on restart, but that’s a special case.
So to detect a dead device, you have a better chance when none of its entities have changed for a while.