A sensor to list unavailable devices

Add a rejectattr line, for example:

{{ states
| selectattr('domain','in',['binary_sensor', 'climate', 'light', 'sensor', 'switch'])
| selectattr('state', 'in', ['unavailable'])
| rejectattr('entity_id', 'in', 'your_entity_id_here') 
| map(attribute='entity_id')
| map('device_attr', 'name_by_user') 
| reject('match', 'None')
| unique
| list 
| sort 
| join('\n')
}}

Thank you for the code!

How can I select specific entities to monitor?

I get that to exclude entities we can use “rejectattr(‘entity_id’, ‘in’, ‘your_entity_id_here’)”.

I only want to monitor a list of ~10 entities.

I guess there a few ways, but I would define the list of entities (here I called the list “unavail”) and then use this list the way we have in this post. I have five listed entities here, just change them to what you want:

{% set unavail = [
states.light.ollys_beam,
states.media_player.denon_amp,
states.sensor.thermpro_office_battery,
states.light.office_1,
states.light.office_lamp,
] %}
{{ unavail
| selectattr('state','eq','unavailable') 
| map(attribute='entity_id')
| map('device_attr', 'name_by_user') 
| reject('match', 'None')
| unique
| list 
| sort 
| join('\n')
}}