MQTT publis payload_template

Hello!

I have an automation with this action:

  action:
    - service: mqtt.publish
      data:
        topic: "SERVER-oldip"
        payload_template: "{{states.sensor.wan_ip.state.split("=")[0]}}"

The error:
expected <block end>, but found '<scalar>'

The cool part is, sometimes it works and HA boots up fine, but other times it doesn’t.

I may add, it works in the “HA template debugger”

Edit: I’m still experimenting. Results are varying…

Edit 2: I may have found a working result_
"{{states.sensor.wan_ip.state.split("=")[0]}}"
to
'{{states.sensor.wan_ip.state.split("=")[0]}}'