Zigbee Unavailable Device Count

Im wanting to create a sensor that counts how many of zigbee devices become unavailable just to keep on them.

I have done light counts using templates, but not something using an Integration? Any idea??

{{ expand(["entity_device1", "entity_device2", "..."]) | selectattr("state", "eq", "unavailable") | list | length }}

Alternatively, you can use integration:

{{ expand(integration_entities('hue') )
|selectattr( 'state', 'eq', 'unavailable')

1 Like

perfect! thank you, still learning templates!

In this case, I recommend using some kind of filtering.

For example, I currently have 28 devices with zha, but it returns 68 entities.
That is because there are many entities for the same device.
When an entity restores its value, all entities of the same device restore too.
So I recommend counting devices.

My example uses filters. Or am I misunderstanding you?

I meant filtering for switches, binary_sensors, covers, … for example.

If it’s filtered by domains you count the entities, too. Do you have an example to illustrated how you would filter by devices (and not entities)?

Just add a single entity (the most important) for each device. At least, that is how I do.

For example, I have a contact sensor that have the following entities:

  • contact sensor (that is the entity that I use most in automations, so it is most important to me)
  • temperature
  • accelerometer
  • humidity
  • power
  • lqi
  • rssi
  • identity

Then I create a set with only one important entity for each device.
Sometimes, a device has a lot of sensors and a single binary_sensor or cover, for example.

FYI, more advanced Zigbee stuff can be achieved via ZHA Toolkit:




might check this out, nfi but we could be interesting to see what i can learn