Variable template being changed after saving

I am trying to add a variable to a automation im creating however whenever i save the automation home assistant changes the template i added to the variable to “[object Object]”: null

I have confirmed that my template in the variable works as a template.

has anyone got any ideas on how i can get this working?

Before Save

alias: Test
description: ""
triggers: []
conditions: []
actions:
  - variables:
      TS: {{now().strftime('%H:%M_%d-%m-%Y')}}
  - action: camera.snapshot
    metadata: {}
    data:
      filename: /media/local/snapshots/doorbell_person_{{TS}}.jpg
    target:
      entity_id: camera.reolink_video_doorbell_wifi_fluent
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - action: notify.mobile_app_iphone15
    metadata: {}
    data:
      title: Camera Detection
      message: Person Detected on Doorbell Camera
      data:
        image: /media/local/local/snapshots/doorbell_person{{TS}}.jpg
        actions:
          - action: URI
            title: Open Camera
            uri: /lovelace/family-cameras
mode: single

After saving

alias: Test
description: ""
triggers: []
conditions: []
actions:
  - variables:
      TS:
        "[object Object]": null
  - action: camera.snapshot
    metadata: {}
    data:
      filename: /media/local/snapshots/doorbell_person_{{TS}}.jpg
    target:
      entity_id: camera.reolink_video_doorbell_wifi_fluent
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - action: notify.mobile_app_iphone15
    metadata: {}
    data:
      title: Camera Detection
      message: Person Detected on Doorbell Camera
      data:
        image: /media/local/local/snapshots/doorbell_person{{TS}}.jpg
        actions:
          - action: URI
            title: Open Camera
            uri: /lovelace/family-cameras
mode: single

You’re missing quotes around the template. In your case, because your template is using single quotes inside it, you need to put double quotes around it.

Use this for a better readability and to avoid errors:


    variables:
      TS: >-
        {{now().strftime('%H:%M_%d-%m-%Y')}}