chunk
(Daniel Lindsay)
May 16, 2022, 1:53pm
1
Hey all,
I have set up a nice sensor to let me know what lights I have on
- type: template
double_tap_action:
action: none
icon_color: |-
{% if is_state('sensor.count_lights_on', '0') %}
disabled
{% else %}
amber
{% endif %}
icon: mdi:lightbulb
entity: sensor.count_lights_on
tap_action:
action: none
content: '{{ states(''sensor.count_lights_on'') }}'
0 lights on: null
What do i need to do to exclude a light from this sensor?
TIA
Update:
- platform: template
sensors:
count_lights_on:
friendly_name: "# Lights on"
unit_of_measurement: "on"
value_template: "{{ states.light | selectattr('state', 'eq', 'on') | rejectattr('attributes.is_hue_group', 'eq', true) | rejectattr('attributes.entity_id', 'defined') | list | count }}"
1 Like
tom_l
May 16, 2022, 1:59pm
2
It might help if you show the sensor rather than the card used to display it.
chunk
(Daniel Lindsay)
May 16, 2022, 4:13pm
3
That would be a great help, wouldn’t it…updated OG message. Thanks
Add this line of code into you value_template and of course put your entity there.
| rejectattr('entity_id', 'search', 'YOUR_ENTITY')
1 Like
gado
July 22, 2023, 4:35pm
5
Im trying to configure the same thing but my config brokes when adding | rejectattr(‘entity_id’, ‘search’, ‘YOUR_ENTITY’) to the value template. the entitiy Im trying to exclude is id: light.time_brightness
this is my value template:
value_template: “{{ states.light | selectattr(‘state’, ‘eq’, ‘on’) | list | count | rejectattr(‘entity_id’, ‘search’, ‘light.time_brightness’) }}”
what am I missing?
Try
value_template: “{{ states.light | selectattr(‘state’, ‘eq’, ‘on’) | rejectattr(‘entity_id’, ‘search’, ‘light.time_brightness’) | list | count}}”