Call-Service error. extra keys not allowed

I have been trying to figure out how to trigger a home assistant automation that takes in a variable. I can trigger an automation that just triggers with no extra data options but once I try to add a variable in the data section, I get the error:

"Call-service error. extra keys not allowed @ data['url']"

I cannot figure out what is wrong with the message or how to get this to work

What am I doing wrong?

Use "turn_on" rather than "trigger" in the service call.

turn_on has no effect, same error.

I'm not sure if this is a node-red or HA configuration issue so for completeness, here is the HA automation I am trying to pass in the url to for review:

alias: NodeRedPlayVideo
description: ""
trigger: []
condition: []
action:
  - service: androidtv.adb_command
    data_template:
      entity_id: media_player.android_tv
      command: >
        am start -a android.intent.action.VIEW -c
        android.intent.category.BROWSABLE -d "{{ url }}"
    alias: Play Video
mode: single

My bad - "automation.turn_on" just enables an automation, I was getting confused with "script.turn_on". Any reason why you're using an automation rather than a script? But yes, it should be "automation.trigger", but you pass the variables like this:

service: automation.trigger
data:
  variables:
    new_value: 13
target:
  entity_id: automation.bump

Where my "bump" automation is defined like this:

alias: Bump
description: ""
trigger: []
condition: []
action:
  - service: input_number.set_value
    data:
      value: "{{ new_value }}"
    target:
      entity_id: input_number.mb_test_number_1
mode: single

I'm not using scripts for any reason other than i'm very new to HA and trying to pick through all the documentation and yaml is not easy to figure out.

I'm trying to understand what you're even doing with these and I can't seem to figure out what is happening or where one even would put these scripts and how to call them form node-red.

Are you showing two versions of the same solution? Are these interlinked somehow? I can't seem to see any way these two are associated with the variables so i'm definitely missing something in the core of this process.

After a lot of trial and error, I think I finally figured out what was wrong. I at least got node-red to be able to send calls with variables. I did use your example as my starting point so thanks for getting me pointed in the right direction.

At the end of the day, the entire problem stemmed from just having to encode the variables in json from node-red like this:

{
"variables": {
"new_value": "13"
}
}

I didn't get that from any docs or other forum post, just randomly tried it after I got it working in HA first so I knew that the rest was something wrong on node-red.

You'd probably be better off asking HA-related questions on the HA forum, even if using Node Red. Automations in HA are normally for when you want something to happen automatically (eg. reacting to switching on a light), whereas scripts are for when the want to run things 'manually'. Having said that, if you're using NR, you would not generally need to use HA automations or scripts, as it can be done in NR. I use NR with HA and have no active HA automations or scripts - it's all in NR. There are some things that are more straightforward to code in an HA automation, but I prefer to have everything in one place.

I agree but in this case, my original HA automation actually was fine and the whole problem I was experiencing was with the NR json format in the call service block. Not a syntax I could find documented anywhere so this did appear to be the right place for it.

Maybe I'll eventually find a way to get the same functionality out of NR for ADB commands but for now, it seemed simpler just to move my complex logic out of HA and let NR just send my final result to HA to deal with the ADB side.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.