Total Lights On

I’m very new to Home Assistant, only been tinkering a couple of weeks and still learning. The lights in my house are currently run from smart switches. I created a switch group named “All Lights”, so I have an entity switch.all_lights. I built the following based on posts I found on the forum and stuck it into my configuration.yaml, but the sensor always reads as “unavailable”. I’m sure I did something wrong here, but I don’t know what.

  - platform: template
        friendly_name: "# Lights on"
        unit_of_measurement: "on"
        value_template: "{{ switch.all_lights | selectattr('state', 'eq', 'on') | list | count }}"

I believe I just figured it out. I think I had to replace switch.all_lights with expand(‘switch.all_lights’).

The new groups also have an attribute that lists all the group members.

1 Like

Do you happen to recall what that attribute is named? That would be good to know for the future.

Have a look at one of your groups in Developer Tools / States.

Ah right, thank you. I’m still learning. For anyone curious that runs across this thread, the attribute is entity_id.