Hi everyone! I’m trying to set up some smart home automation using scene names, but I’m running into an issue that’s a bit puzzling. I created an input_select helper with a few scene names like ‘Hall On’ and ‘Hall Off’. The idea is to cycle through these scenes using a button press. Here’s the automation I set up:
yaml
alias: Cycle Hall Lights
trigger:
- platform: device
domain: mqtt
device_id: 2b24f3b1d52a410cb9e53ac5227e4dc4
type: action
subtype: single
action: - service: input_select.select_next
data: {}
entity_id: input_select.hall_scenes
alias: Activate Hall Scene
trigger:
- platform: state
entity_id: input_select.hall_scenes
action: - service: scene.turn_on
data_template:
entity_id: ‘scene.{{trigger.to_state.state|lower|replace(’’ ‘’,‘’_‘’)}}’
The problem is that when the scene name is templated, it always includes a leading space, resulting in ‘scene._hall_on’ instead of ‘scene.hall_on’. This causes the scene to fail. I’ve tried various combinations of lower and replace, but I can’t seem to strip that initial space. Does anyone have a solution or workaround for this? I’d really appreciate any help!
Thanks in advance!