Can not find Error in Shell_command

Hi,

i got the message on executing from ui by tap_action:

shell_command/shellcommand_add_la. No closing quotation

  shellcommand_add_la: >
    curl "https://subd.dom.tld" \
    -X POST \
    --header "Content-Type: application/json" \
    --header "X-K: xxx" \
    --header "Authorization: Basic xxx" \
    -d "{\"ad\" : \"{{ states('input_text.txt_la') }}\", \"active\": 1,\"comment\": \"\"}"

I tried a lot, so maybe my shell-command is damaged now.
I tried with and without the trailing “\”.

I have it in a packages yaml file.

Where is the error? Thanks.

What is {{ states('input_text.txt_la') }}? Does it contain quote characters? Perhaps try:

{{ states('input_text.txt_la')|escape }}

No, it contains simple plain alphanumeric text.

Does it run if you call it from Developer Tools / Services?

If it does, please post the dashboard YAML around the tap_action.

I do not think you can do the \ for next line.
Try to remove them and put all on one line.

I do not get any error in UI, the log says this, but the command didn’t work, I can not see the result as expected.

2023-02-21 12:24:18.379 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139867863637664] Received {'type': 'execute_script', 'sequence': [{'service': 'shell_command.shellcommand_add_la', 'data': {}}], 'id': 38}
2023-02-21 12:24:18.383 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=shellcommand_add_la, service_data=>
2023-02-21 12:24:18.386 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=shell_command, service=shellcommand_add_la, service_data=>)

2023-02-21 12:24:55.124 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139867863637664] Received {'type': 'execute_script', 'sequence': [{'service': 'shell_command.shellcommand_add_ch', 'data': {}}], 'id': 39}
2023-02-21 12:24:55.127 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=shellcommand_add_chri, service_data=>
2023-02-21 12:24:55.136 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=shell_command, service=shellcommand_add_ch, service_data=>)

2023-02-21 12:25:03.931 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139867863637664] Received {'type': 'execute_script', 'sequence': [{'service': 'shell_command.shellcommand_add_lu', 'data': {}}], 'id': 40}
2023-02-21 12:25:03.935 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=shellcommand_add_luc, service_data=>
2023-02-21 12:25:03.941 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=shell_command, service=shellcommand_add_lu, service_data=>)

2023-02-21 12:25:12.867 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139867863637664] Received {'type': 'execute_script', 'sequence': [{'service': 'shell_command.shellcommand_add_la_ttteeesssttt', 'data': {}}], 'id': 41}
2023-02-21 12:25:12.870 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=shellcommand_add_la_ttteeesssttt, service_data=>
2023-02-21 12:25:12.872 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=shell_command, service=shellcommand_add_la_ttteeesssttt, service_data=>)

I forgot, this is she ttteeesssttt:

  - shellcommand_add_la_ttteeesssttt: |
      "echo {{ states('input_text.txt_la')|escape }}"

As I said before, I tried those things with and without "\" in one line or in multiline.

Did you try all on one single line? Just looking at that log showing the > as the service_data

shellcommand_add_la: curl "https://subd.dom.tld" -X POST --header "Content-Type: application/json" --header "X-K: xxx" --header "Authorization: Basic xxx" -d "{\"ad\" : \"{{ states('input_text.txt_la') }}\", \"active\": 1,\"comment\": \"\"}"

Now I got:

Fehler beim Aufrufen des Diensts mqtt/reload. mapping values are not allowed here in "/config/packages/package/package_file.yaml", line 55, column 125

When trying to reload (I clicked on every link in developer tools, and this message appears by trying to reload “manual configured mqtt-entities” (translated from german).

Have a look at that file then. The “mapping values” error often means there’s a colon ( : ) where there shouldn’t be.

1 Like