I am trying to display number of entities that are in the state of unknown, unavailable or none. Here is my sensor config:
- platform: template
sensors:
unavailable_entities:
entity_id: sensor.time # updates sensor every minute
friendly_name: Unavailable Entities
unit_of_measurement: entities
icon_template: "{{ 'mdi:check-circle' if states('sensor.unavailable_entities')|int == 0 else 'mdi:alert-circle' }}"
value_template: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])
|rejectattr('entity_id','in',state_attr('group.ignored_entities', 'entity_id'))
|rejectattr('domain','eq','group')|list|length }}
attribute_templates:
entities: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])
|rejectattr('entity_id', 'in', state_attr('group.ignored_entities', 'entity_id'))
|rejectattr('domain','eq','group')|map(attribute='entity_id')|list|join(', ') }}
names: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])
|rejectattr('entity_id', 'in', state_attr('group.ignored_entities', 'entity_id'))
|rejectattr('domain','eq','group')|map(attribute='name')|list|join(', ') }}
If I put this code in the template tool under development tools I get correct data:
- platform: template
sensors:
unavailable_entities:
entity_id: sensor.time # updates sensor every minute
friendly_name: Unavailable Entities
unit_of_measurement: entities
icon_template: "mdi:alert-circle"
value_template: >
3
attribute_templates:
entities: >
binary_sensor.lumi_lumi_sensor_magnet_aq2_cd122a04_on_off, light.sidbord, sensor.tradfri_remote_control_3
names: >
Köksfönster 2, Sidbord, TRADFRI remote control 3
But, when I check the state of the sensor in development tools it returns a 207 and lists all my sensors (same as in lovelace).
What am I doing wrong here?
/Carl