Hi,
Fairly new to Home Assistant, but trying my hand at some scripting.
I’m trying to devise a utility automation that automatically plays a scene from input_select dialogs on a room-by-room basis. Each input_select (dropdown) helper has a list of scenes in friendly language, which relates to a scene in a room, thus:
Off -> scene.back_garden_off
Moonlight -> scene.back_garden_moonlight
Warm Glow -> scene.back_garden_warm_glow
Off -> scene.kitchen_off
Blood Moon -> scene.kitchen_blood_moon
Bright -> scene.kitchen_bright
I was able to devise an automation that works for one room specifically, but rather than having a single automation for each room (much like below, which works for one specific “room” only), I’d like something that is more general. Note that I do not need a list of all scenes for each room; I prefer limiting them to the specific input_select helpers. I was thinking that trigger IDs might make it easier, but I can’t work out how to use them as a wildcard within states(). Could someone show me the syntax, assuming it’s possible, of automatically selecting the state option to match the trigger entity_id?
alias: Scene Selector
trigger:
- platform: state
entity_id: input_select.back_garden_scenes
id: back_garden_
- platform: state
entity_id: input_select.kitchen_scenes
id: kitchen_
action:
- target:
entity_id: >-
{{'scene.' + trigger.id +
states('input_select.back_garden_scenes').replace(" ", "_").lower()}}
action: scene.turn_on
mode: single
Also grateful for any other ideas people have for making this more elegant.
Thanks!