Templating question. Generate list of lights with specific attribute

I would like to generate a list of all lights in an Area which are “on” and which have a particular attribute, for example hs_color.

Does anyone know how I might go about this?

Thanks

The following template lists the entity_ids of all lights that are on in the Dining area and have an hs_color attribute.

{{ expand(area_entities('Dining') | select('match', 'light')) 
  | selectattr('state', 'eq', 'on')
  | selectattr('attributes.hs_color', 'defined')
  | map(attribute='entity_id')
  | list }}
2 Likes

Thanks, that worked a treat.

1 Like