[SOLVED]Passing variable to a script, can't get it to work

Hey guys,
I’ve red almost every similar post but it doesn’t seem to work for me.
Here is my script:

script:
  test_notification_persistant:
    sequence:
      - service: persistent_notification.create
        data_template:
          message: "{{message}}"
          title: "{{message}}"

And here is the service i call:
image

And here’s what i get:
image

It’s an over-simplified example, im actually trying to pass a camera name in order to run the camera.snapshot service but i can’t get either to work.

Any clues? because it seems to work for everyone but me :stuck_out_tongue:

Remove variables: from your service call data.

Just use:

data:
  message: "test"

image
Tried with and without quotes, same result:

Did you try making the service call from an automation? I’m not sure if you can pass variables through a service call like this.

1 Like

That was it.

I actually tried it before i came here asking but i added 'data: ’ inside the data box of the automation editor. This resulted in having data: twice and it wouldn’t work.
I saw the mistake once i went to automations.yaml to paste my code here and corrected it.

It worked.
Thanks guys :slight_smile:

On a further thought, is this a bug?
Shouldn’t variables be passed through such service calls?
Should i report it somehwere?

I have no clue to be honest.

I think it’s either a bug or lack of info in docs so please open a new issue.

I don’t use the UI much. Do other services that use extra data require there to be a data: key in that box?

I’m guessing not. That way it’s hard coded for data so there is no option for data_template. Which AFAIK isn’t supported.

templates are not supported but we are talking about passing data to a script, and there is no templates in the data, right? TS points out that data is just not passed to the script.

Not in this case (or in the example from the other day where someone was incorrectly passing templates instead of results). I was just trying to justify why it had possibly been coded that way.