Script with fields have error due to wrong indentation

Hi all,

At the moment I have for each and every notification a script, for example;

action: notify.pushover_alarm
data:
  title: HA Alarm System -
  data:
    priority: 0
    sound: vibrate
    ttl: 600
  message: Alarm deactivated

I want to reduce the number of similar scripts, using fields.
So I created this script.

sequence:
  - action: notify.pushover_alarm
    data:
      title:
        "[object Object]": null
      data:
        priority:
          "[object Object]": null
        sound:
          "[object Object]": null
        ttl:
          "[object Object]": null
      message:
        "[object Object]": null
alias: Alarm Pushover notification - Alarm **template**
description: ""
fields:
  title:
    selector:
      text: null
    name: title
    required: true
    description: your title
  priority:
    selector:
      number:
        min: -1
        max: 2
        step: 1
    name: priority
    required: true
    description: prio
  sound:
    selector:
      text:
        multiple: false
        multiline: false
    name: sound
  ttl:
    selector:
      number:
        min: 1
        max: 100
    name: ttl
    required: true
  message:
    selector:
      text: null
    name: message
    required: true```

If I go to the developer tool / actions
And I put some test data in and view the output in YAML, I see this;

action: script.alarm_pushover_notification_alarm_template
data:
title: test
priority: 1
sound: echo
ttl: 100
message: test

so basically the indentations and 2x data are gone. See how it was/works w/o fields at start of this topic. If I try to run it, I get this error.

Failed to perform the action script.alarm_pushover_notification_alarm_template. value should be a string for dictionary value @ data['message']. Got None value should be a string for dictionary value @ data['title']. Got None

How can I fix this?

Thanks for tips!

Regards
Jules

What happens if in developer tools action you construct the proper YAML to call the script?

When you see that, it usually means you didn’t properly enclosed your template with quotes or you messed up the delimiters.

Thanks, I had my fields in curly brackets but no quote.

So
{{ field }} >> wrong
Instead of
“{{ field }}” >> right

It now works!!

:blush: