jazzyisj/unavailable-entities-sensor

Template will not exclude browser_mod domain

Closed this issue · 1 comments

All Im trying to do is create a sensor that will count the number of offline devices but I don't need many of them including browser_mod which has a ton of entities, I tried this code but still all the browser_mod sensors and media_players still show in the template sensor under developer tools test page, please help. Thanks.

Screenshot 2024-04-27 at 1 49 14 AM Screenshot 2024-04-27 at 1 49 25 AM
                {% 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','input_button','input_text','scene', 'binary_sensor', 'device_tracker', 'select', 'todo', 'browser_mod' ])
                    |rejectattr('entity_id','search','browser_')      
                    |rejectattr('entity_id','search','_alarm_volume|_next_alarm|_alarms')
                    |rejectattr('entity_id','contains','_memory_percent')
                    |rejectattr('entity_id','in', integration_entities('hassio'))
                    |rejectattr('entity_id', 'in', integration_entities('browser_mod'))
                    |rejectattr('last_changed','ge',ignore_ts) %}
                {% set entities =  entities|rejectattr('entity_id','in',ignored) if ignored != none else entities %}
                {{ entities|map(attribute='entity_id')|reject('has_value')|list|sort }}

I'm betting those are all orphaned entities that no longer belong to the browser_mod integration. After a while an integration drops unavailable entities. You can tell when this happens when you can delete the entity from the front end. If they don't belong to devices you normally use you just delete them.

image

In my own case, I've had browser_mod name all my devices so I can filter out entities for any of those devices. The side effect of that being that they aren't monitored at all by this template which is fine for me because they always go unknown/unavailable when the devices isn't on and I don't need to know about it.

| rejectattr('entity_id', 'search', 'jphone_app|jtablet_app|jlaptop_chrome|jwork_chrome)