I never did get around to resolving the duplicates. However, it looks like procrastination paid off because 0.104 has obviated the need for it. Nevertheless, I don’t wish to appear as a slacker so I offer you some minor streamlining.
According to my tests, you can replace this:
|rejectattr('entity_id', 'in', state_attr('group.entity_blacklist', 'entity_id'))
|rejectattr('entity_id', 'eq' , 'group.entity_blacklist')
with this:
|reject('in', expand('group.entity_blacklist'))
|reject('eq', states.group.entity_blacklist)
You can also remove this filter from the value_template
:
map(attribute='entity_id')
Here’s the streamlined version:
sensor:
- platform: template
sensors:
unavailable_entities:
friendly_name: Unavailable Entities
value_template: >
{{states|selectattr('state', 'in', ['unavailable', 'unknown', 'none'])
|reject('in', expand('group.entity_blacklist'))
|reject('eq', states.group.entity_blacklist)
|list|length}}
attribute_templates:
entities: >
{{states|selectattr('state', 'in', ['unavailable', 'unknown', 'none'])
|reject('in', expand('group.entity_blacklist'))
|reject('eq' , states.group.entity_blacklist)
|map(attribute='entity_id')|list|join(', ')}}
unit_of_measurement: items