jazzyisj/unavailable-entities-sensor

How to list only unavailable entities and/or devices?

Opened this issue ยท 2 comments

  1. Thank you SO MUCH for this - I've been looking for this for a long time :-)
  2. I'm beginning to customize it, and the first thing I noticed was that a lot of these unavailable entities all have to do with a few devices. How would I list the devices only, instead of all the entities?
  3. This also list all entities that have a state of unknown. Would it be possible to omit these, thus only listing the unavailable ones? I've tried to look for an "unknown" keyword, but I can't find any...
  1. My pleasure.
  2. Not really. The attribute is a list of entity id's. I suppose one could write a template which tries to identifies any devices that is unavailable, list those devices but not it's entities, and then list any remaining entities that don't belong to a device. But that is well beyond the scope of this sensor. I'll leave this issue open for now and maybe if I get a little time I'll try to put something together for you. You might get a quicker response in the forum. Also see the example detailed notification automation it sorts entities by device and names the device.
  3. Make the same changes I made to the base template here to yours to only select entities with a state of unavailable.
            {% set ignore_seconds = 60 %}
            {% set ignored = state_attr('group.ignored_unavailable_entities', 'entity_id') %}
            {% set ignore_ts = (now().timestamp() - ignore_seconds)|as_datetime %}
            {% set entities = states
                | rejectattr('domain','in',['button', 'event', 'group', 'image', 'input_button', 'input_text', 'remote', 'tts', 'scene', 'stt'])
                | rejectattr('last_changed', 'ge', ignore_ts) 
                | selectattr('state','eq','unavailable') %}
            {% set entities =  entities | rejectattr('entity_id', 'in', ignored) if ignored != none else entities %}
            {{ entities | map(attribute='entity_id') | list | sort }}

I came here today for point 3 and I find both question and answer! Thank you! ๐Ÿ˜