pcace
(Johannes Frölich)
April 7, 2023, 8:18am
1
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
Troon
(Troon)
April 7, 2023, 8:31am
2
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
pcace
(Johannes Frölich)
April 7, 2023, 2:25pm
3
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
Thanks a lot!
mcarty
(Arturo)
April 7, 2023, 2:41pm
4
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.
mcarty
(Arturo)
April 7, 2023, 2:45pm
5
Take a look at developer tools, services and check that the shell command works. You can invoke it from there.
Also check the logs.
pcace
(Johannes Frölich)
April 9, 2023, 7:43am
6
Hi, thanks a lot! I was just missing that it is not a post command but a put command
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
The Logs do not show anything related to scripts
Thanks a lot!!