klogg
(Klogg)
1
Is it possible to template the snapshot_entities
in scene.create
?
I think not but I hope I am wrong.
e.g. (which don’t work hence the question)
service: scene.create
data:
scene_id: my_scene
snapshot_entities: >
{% for boolean in states.input_boolean if 'some_identifier' in boolean.object_id %}
{{ boolean.entity_id }},
{%- endfor %}
or
snapshot_entities: >
{{ states | selectattr('domain', 'eq', 'input_boolean ')
| selectattr('entity_id', 'search', 'some_identifier')
| map(attribute = 'entity_id')
| list }}
Troon
(Troon)
2
Yes, but your template needs to supply a list object (like your second option, added after I posted this), not build a text list.
I haven’t used scenes before, but just called:
service: scene.create
data:
scene_id: test_scene_2
snapshot_entities: >
{{ states.sensor | selectattr('entity_id','contains','outside') |
map(attribute='entity_id') |list }}
and that scene’s state summary looks like this:
<template TemplateState(<state scene.test_scene_2=unknown; entity_id=['sensor.outside_temperature', 'sensor.outside_illuminance', 'sensor.outside_temperature_2', 'sensor.outside_temperature_1'], friendly_name=test_scene_2 @ 2024-01-19T14:13:55.206038+00:00>)>
klogg
(Klogg)
3
Thanks I’ll look at that but straightaway I learnt contains
!
I didn’t know that was an option.