Shellscript in Homeassistant getting error

Hi there, i am trying to fire up curl within a script in homeassistant, but keep geeting this error:

Message malformed: extra keys not allowed @ data['shell_command']

this is the script i am trying to run:

alias: Send Staubsauger to kitchen
sequence:
shell_command:
  sendit: "curl -X POST http://staubsauger/api/v2/robot/capabilities/GoToLocationCapability -d '{\"action\": \"goto\",\"coordinates\": {\"x\": 2982,\"y\": 2058}}'"
mode: single

it does not show any yaml typing errors, but still does not want to run.

what am i missing here?

thank you so much for help,

pcace

You need to define the shell_command (docs), then call it in the sequence.

So somewhere in your config you’d have:

shell_command:
  sendit: "curl -X POST http://staubsauger/api/v2/robot/capabilities/GoToLocationCapability -d '{\"action\": \"goto\",\"coordinates\": {\"x\": 2982,\"y\": 2058}}'"

then your script would be:

alias: Send Staubsauger to kitchen
sequence:
  - service: shell_command.sendit
mode: single

Hi there, thanks for your qick reply! i am very new to homeassistant, what do you mean with config? The script?

i tried to edit this file to look like this, and restarted homeassistant:


root@raspiHome:/PATH_TO_YOUR_CONFIG# cat configuration.yaml 

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
shell_command:
  sendit: "curl -X POST http://staubsauger/api/v2/robot/capabilities/GoToLocationCapability -d '{\"action\": \"goto\",\"coordinates\": {\"x\": 2982,\"y\": 2058}}'"

root@raspiHome:/PATH_TO_YOUR_CONFIG#

with no luck - at least it is not showing any kind of life :confused:

Thanks a lot!

I guess he means that you cant define a shell command straight in a script, you should first define the shell command and then call it.
Take a look at the docs link he posted.

Take a look at developer tools, services and check that the shell command works. You can invoke it from there.
Also check the logs.

Hi, thanks a lot! I was just missing that it is not a post command but a put command :confused:

the problem now is, that i cannot figure out how to add another script. is this syntax correct?

Or is the second one wrong escaped?

shell_command:
  sendit: "curl -X PUT http://staubsauger/api/v2/robot/capabilities/GoToLocationCapability -H 'Content-Type: application/json' -d '{\"action\": \"goto\",\"coordinates\": {\"x\": 2982,\"y\": 2058}}'"
  vacit: "curl -X PUT http://staubsauger/api/v2/robot/capabilities/MapSegmentationCapability -H 'Content-Type: application/json' -d '{\"action\": \"start_segment_action\",\"segment_ids\":[\"1\"],\"iterations\": 1,\"customOrder\": true}'"

first one works, second one does not do anything, but firing it from a shell directly works :frowning:

The Logs do not show anything related to scripts
Thanks a lot!!