As I found this thread by Googling for a slightly different question, I’d just like to add my $0.02 here in case this helps someone else.
Yes, it is correct that static, saved scenes in HomeAssistant do not support templates. This, I’d imagine, could lead to unpredictability if not used carefully. Changes to entities requiring scene updates should be a rare occurrence and something that a user would be conscious of anyway, so it’s not a huge issue to be lacking any dynamics within a scene record.
However, when creating an on-the-fly scene, you actually CAN use templates - this is because service calls do accept templates (although, as of this writing, the visual editor will complain about using templates and force you into YAML mode, but that’s OK).
I have an “On Air” scene that I activate when I am on a call. For this scene, I want certain lights in the house to turn red and hold red until I de-activate the On Air mode (which I track with a boolean helper). If I alter the scene, I do not want to also remember to alter the automation which calls scene.create
each time. It’s rare that I might want to change this, but I also want to make it simple when I do (and it has come up before!).
So, let’s use HomeAssistant to automate maintainence of HomeAssistant My service call to scene.create
looks like this:
service: scene.create
data:
scene_id: on_air_restore_state
snapshot_entities: "{{ state_attr('scene.on_air', 'entity_id') }}"
When this automation is triggered, it will always snapshot whatever entites are in my scene.on_air
. I have a separate automation set up for when i deactivate On Air mode which simply sets the scene scene.on_air_restore_state
(although I really should combine these and use Trigger IDs to make the whole thing more modular!)
So, as you can see, if you are trying to create a scene on the fly from a list of entities, you can do it using templating in the service call rather than trying to define the scene with templates in it. This does have the caveat that if the list changes after the scene has been defined, it will not update within the scene; but for 99% of use cases this probably isn’t going to be an issue.