Scene-turn_on inserts space at beginning of scene name

Hi. I had this working a while back and I can’t for the life of me work out what i’m doing wrong.
I’ve created a input_select helper with a few scene names in it like:

“Hall On”
“Hall Off”
(btw I can’t find the code for this helper as it appears to be hidden away somewhere)

Then I have a cycle automation triggered by a button press:

alias: Cycle Hall Lights
description: ''
trigger:
  - platform: device
    domain: mqtt
    device_id: 2b24f3b1d52a410cb9e53ac5227e4dc4
    type: action
    subtype: single
    discovery_id: 0x00158d0003614c8f action_single
condition: []
action:
  - service: input_select.select_next
    data: {}
    entity_id: input_select.hall_scenes
mode: single

alias: Activate Hall Scene
description: ''
trigger:
  - platform: state
    entity_id: input_select.hall_scenes
condition: []
action:
  - service: scene.turn_on
    data_template:
      entity_id: 'scene.{{trigger.to_state.state|lower|replace('' '',''_'')}}'
mode: single

See that i’ve templated the scene to include the trigger parameter to lower case and replace spaces.

The problem is that the above logic always evaluates the name of the scene entity as:
“scene._hall_on”
i.e. it puts a leading space into the scene name and therefore fails.

I can’t work out how to strip this space.
Any ideas?

Thanks