I’m right now switching from openhab to home assistant, an I’m trying to migrate some of my automations/rules.
While doing so I encountered a question: If I have a input_select called “bedroom_light” and some options in it like “On”. “Off”, “Night” is there a way to take the name of the input_select and the name of the selected option to then build the scene name out of it like “bedroom_light_on”?
If when you created the scenes you named them scene.bedroom_light_on and scene.bedroom_light_off, and scene.bedroom_light_night and the options in the input select were, On, Off, and Night, (not case sensitive) then yes it would. The slugify filter changes the option to lower case and replaces spaces and special characters with underscores. So make sure your scene names match what that filter does to your options and you’re good. In this case you can simplify the template a bit too:
trigger:
platform: state
entity_id: input_select.bedroom_light # triggers on any change of state
action:
service: scene.turn_on
target:
entity_id: "{{ 'scene.bedroom_light_' ~ states('input_select.bedroom_light')|slugify}}"
It’s a great idea. I might use it to simplify my scene input selects. Though I have a mixture of scenes and scripts the input select automation calls, so that will need some fixing.