Excluding lights from sensor

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

It might help if you show the sensor rather than the card used to display it.

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

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?