Hello community!
I have an automation that calls a script to produce a light notification in the room specified by a variable that is being passed (the area) Based upon this variable (room_focus) there forms a list of entities that are being snapshot into a scene before actual light notification is being performed (flashing). After that the initial states of the lights are being restored by activating the previously created scene.
I pass the variable (room_focus) and it seems to go well. I’ve put a test notification that runs smoothly. However, after that the script stops giving the following error in the trace:
My automation and script codes are as follows:
alias: TEST
description: ""
trigger: []
condition: []
action:
- service: script.turn_on
target:
entity_id: script.1662922347981
data:
variables:
room_focus: salon
mode: single
alias: Light Notification
sequence:
- service: notify.service_ng
data:
message: "{{room_focus}}"
- service: scene.create
data:
scene_id: initial_scene
snapshot_entities: |-
{{ (states.light
| selectattr('domain','eq','light')
| selectattr('entity_id', 'in', area_entities('{{room_focus}}'))
| rejectattr("entity_id", "search", "dnd")
| rejectattr('attributes.entity_id', 'defined')
| map(attribute='entity_id')
|list)
|join(', \n') }}
- service: light.turn_on
data:
brightness_step_pct: -50
target:
entity_id: light.dim_salon
- repeat:
count: "3"
sequence:
#
# OMITED NOT TO OCUPY TOO MUCH SPACE HERE
#
- service: scene.turn_on
data:
transition: 3
target:
entity_id: scene.initial_scene
mode: single
icon: mdi:washing-machine
Also, if I put “salon” instead of the variable here | selectattr(‘entity_id’, ‘in’, area_entities(’{{room_focus}}’)) it works fine.
Could someone give me a hint why forming the list of entities is producing an error.