Entities from area in template

NB Extremely new to Hassio!!

I’m trying to use a script to get all the entities from an area. I think I want something like the following, but can’t work out the template syntax:

alias: Pulse bulb
sequence:
  - service: scene.create
    data:
      scene_id: pulse_before
      snapshot_entities: '{{expand('group.livingroom') | list}}'

Background: I have a Tradfri 5 button remote which I want to use like this:

  1. The on/off and lights fade up and down to work as expected across a range of living room lights (two main lights, and a group of lights in a freestanding lamp)
  2. if you press left or right, I want the next bulb in the sequence to blink (so you know which is selected) and then be able to be individually faded with the fade up/down keys. You can loop round each of these lights as customise the lights as required

Not really interested in existing blueprints as I’m mainly trying to see what I can do, e.g. I have already found this one :wink: : ZHA - IKEA five button remote for lights

TIA

I know it’s a bit late but better than never. Anyway, I found your post while looking for a similar solution that you were looking for, and here’s the working template that I used.

Example 1

{{ 
  expand(states.binary_sensor) 
  |selectattr(('state', 'eq', 'on') and 'entity_id', 'in', area_entities('Monitored Doors'))
  |map(attribute='entity_id')
  |join(',')
}}

Result:

binary_sensor.patio_door_contact,binary_sensor.front_door_contact

Example 2

{{ 
  expand(states.binary_sensor) 
  |selectattr(('state', 'eq', 'on') and 'entity_id', 'in', area_entities('Monitored Doors'))
  |map(attribute='entity_id')
  |list
}}

Result:

['binary_sensor.patio_door_contact', 'binary_sensor.front_door_contact']

In your case I would change expand(states.binary_sensor) to expand(states.light) and I hope this help.

1 Like