But it’s not working, where did I mess up?
Currently {{ (states.switch | rejectattr('attributes.light.lamp_left', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.light.lamp_right', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.light.hall', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.switch.bedroom', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.switch.kitchen', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.switch.lounge', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.switch.bath_left', 'defined') | selectattr('state', 'eq', 'on') | list | count)+(states.switch | rejectattr('attributes.switch.bath_right', 'defined') | selectattr('state', 'eq', 'on') | list | count) }}
lights are on!
I found a blog, https://www.devwithimagination.com/2023/01/21/counting-sensors-in-home-assistant/ , which pointed me in the right direction and subsequently I ended up with this working code
Currently {{ (states.light | selectattr('entity_id', 'in', ['light.0xa4c138643f553454', 'light.0xa4c138d8db3aa654', 'light.0xa4c138df3493b345', 'light.frontroom_lamp']) | selectattr('state', 'eq', 'on') | list | count)+(states.switch | selectattr('entity_id', 'in', ['switch.0xa4c1382764f5a877', 'switch.0xa4c1387c75807865', 'switch.0xa4c138a638208375', 'switch.0xa4c138bfbbe76454_left', 'switch.0xa4c138bfbbe76454_right']) | selectattr('state', 'eq', 'on') | list | count) }}
lights are on!
You must log in or # to comment.