Automation - template - issue

Hi!
Have problems using the template feature. I want to set the correct Hue scene for a group of Hue lights. The automation bellow does not work.

  • alias: “Slå på lys loftet”
    trigger:
    • platform: state
      entity_id: input_boolean.hue_motion_loftet
      from: ‘off’
      to: ‘on’
      condition:
    • condition: state
      entity_id: input_boolean.night_mode
      state: ‘off’
      action:
    • service: hue.hue_activate_scene
      data_template: >
      {% if is_state(‘input_boolean.night_mode’, ‘off’) %}
      group_name: ‘Loftet’
      scene_name: ‘Energize’
      {% else %}
      group_name: ‘Loftet’
      scene_name: ‘Energize’

After doing some googling I found a script that worked(bellow), but I still cant understand why the automation does not work…

set_hue_scene:
alias: Set Hue scene
sequence:
- service: hue.hue_activate_scene
data_template:
group_name: ‘{{ states.input_select.hue_groups.state }}’
scene_name: ‘{{ states.input_select.hue_scenes.state }}’

Any suggestions:)?

Please format your code when posting it. Also I think data_templates can’t work that way with multiple attributes. try this:

data_template:
  group_name: {% if is_state(‘input_boolean.night_mode’, ‘off’) %}
                 Loftet
                {% else %} 
                energize
                {% endif %}

something like that