Need help with template

I can get the template to work on the template debugger, but it won’t work when I plug it in to my script.

I have a mqtt topic that works as a variable for the lux setting on my hue lamp. The template is supposed to change topic value based on the time or set the topic value to what ever the hue-hub lamp value was last.

lux_set:
    - service: mqtt.publish
      data:
        topic: "light"
        payload_template: >
          {% if states.sensor.time.state.split(":")[0] >= "20" %}
            25 
          {% elif states.sensor.time.state.split(":")[0] >= "08"  %}
            255
          {% else %}
            '{{states.sensor.hue_lvngrm_lamp_brightness.state }}'
          {% endif %}
        qos: 1

This is the error on the log

17-03-16 02:13:42 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [script]: expected a dictionary for dictionary value @ data[‘script’][‘lux_set’]. Got [OrderedDict([(‘service’, ‘mqtt.publish’), (‘data’, OrderedDict([(‘topic’, ‘light’), (‘payload_template’, ‘{% if states.sensor.time.state.split(“:”)[0] >= “20” %}\n 25 \n{% elif states.sensor.time.state.split(“:”)[0] >= “08” %}\n 255\n{% else %}\n '{{states.sensor.hue_lvngrm_lamp_brightness.state }}'\n{% endif %}\n’), (‘qos’, 1)]))])]. (See /home/homeassistant/.homeassistant/configuration.yaml, line 337). Please check the docs at Scripts - Home Assistant

I believe you’re missing sequence:

# Example script component containing script syntax
script:
  example_script:
    sequence:
      # This is written using the Script Syntax
      - service: light.turn_on
        entity_id: light.ceiling
      - service: notify.notify
        data:
          message: 'Turned on the ceiling light!'

I had a hunch it had to be something that simple. I just couldn’t see what was missing, thanks a lot.

No problem. Glad to assist.