List of entities that are unavailable

Home Assistant keeps randomly desecrating Zigbee devices from the network (even after weeks of being stable, they are gone overnight).

I’ve found somewhere a template to show the unavailable entities, but it is only a number:

> {{ states
>         | selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
>         | selectattr('state', 'in', ['unavailable'])
>         | map(attribute='entity_id')
>         | unique
>         | list 
>         | count
>         }}

Is it possible to have the names of those entities visible? So I can re-pair them quicker?

Entity ids:

{{ states
        | selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
        | selectattr('state', 'in', ['unavailable'])
        | map(attribute='entity_id')
        | unique
        | list 
        | join(', ')
        }}

Names:

{{ states
        | selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
        | selectattr('state', 'in', ['unavailable'])
        | map(attribute='name')
        | unique
        | list 
        | join(', ')
        }}

Perhaps I don’t get it what this exactly does. How do I present it, because it is now showing as:
image.

Did you reload or restart after changing the template?

I only have one unavailable entity at the moment, but it is working in the template editor:

It works in the template editor. I had hoped I could have this list presented on my dashboard! :slight_smile:

Other question, is there a way to have a new line for each entity? I am not sure how to add that in the join(‘,’) section.

| join('\n')

Try another card.

Markdown card would be a good one for a long list.

type: markdown
content: |-
  # Unknown Entities
  {{ states('sensor.unavailable_entities') }}

Thanks. I should learn more about this script

The markdown card show only the number, not the list.
image

And when I paste

{{ states
        | selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
        | selectattr('state', 'in', ['unavailable'])
        | map(attribute='name')
        | unique
        | list 
        | join('\n')
        }}

into the sensor template, there is a warning and no result.
image

Not really an answer to your issue and I have occasionally also a battery powered sensor that falls from the mesh, so I know the feeling.

Tip: If this happens regularly and if you haven’t seen it yet, you might have a look at this useful guide regarding zigbee Zigbee network optimization: a how-to guide for avoiding radio frequency interference

I have done everything on that list. ZHA is really sensitive for anything as it seems. I have also plenty of routers. But I think there was a small power outage last night, and ZHA cannot handle that very well.

This is the current situation.

But anyway, that is why I want a list of unavailable sensors and lights, so I can fix things like hallways and toilets asap.

Then you have not updated the template sensor. Or you have not restarted home assistant after updating the sensor. Post the full sensor config. Not just the template.

You mean, like this? And yes, there is a typo in the name :wink:


just adding another perspective, coming from a setup with all kinds of templates showing me what and what not… both in template entities, and in markdown cards:

You are aware that you can set filters in the entities dashboard at /config/entities ? It made me do away with all of those templates (that get reevaluated all the time if you dont limit them…)

1 glimpse at this gives you all you need, and you can click your way through the options,

even add an additional filter for Integration for example

to narrow it down to 24

I use the auto-entities card to report low-battery devices on my network. I’ve also told it to include unavailable entities which has the added benefit of showing me anything battery-powered that has dropped off. If you want this to work for all Zigbee devices rather than battery-powered, there may be another entity you can filter by, like LQI.

type: custom:auto-entities
card:
  type: entities
  state_color: true
filter:
  include:
    - name: /Batter/
      domain: sensor
  exclude:
    - name: /[vV]oltage/
    - name: /[Pp]ower/
    - name: /[sS]tate/
    - name: /[Tt]emp/
    - name: /[Hh]ealth/
    - state: "> 40"
    - state: unknown
sort:
  method: state
  reverse: false
  count: 5
show_empty: false

you mean this:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - state: unavailable
      integration: zha

mind you those cards in the end are costly…

Yeah that big red/pink error means the sensor did not change.

Remove the unit of measurement and try reloading again.

You can’t have a unit for non-numeric sensors. Only for numbers.

Edit: remove the state class too.