Selecting light entities that don't have a specific label

Hi!

I’m trying write a script which will turn off all lights except those with a particular label set against them.

I’ve googled a whole bunch, but can’t quite nail down the syntax. I think rejectattr is the key, but I’m not sure how to match against one of (n) labels that a light entity may have.

Any help greatly appreciated!

{{
states.light|
rejectattr('entity_id','in',label_entities('xxxx'))|
map(attribute='entity_id')|
list
}}

Perfect! Thank you very much indeed!

1 Like