I try to call a curl with the shell command but get the error “mapping values are not allowed here”. What’s wrong with these lines.I swapped ’ for " with the same result
#to run shell commands
shell_command: !include_dir_named shell/
pvoutput_generation: "curl -d 'd={{now().strftime('%Y%m%d')}}' -d 't={{now().strftime('%H:%M')}}' -d 'v2={{sensor.sp14_energy_apparentpower|round(0)}}' -H 'X-Pvoutput-Apikey: {{states.sensor.pvoutput_api_key.state}}' -H 'X-Pvoutput-SystemId: {{states.sensor.pvoutput_system_id.state}}' https://pvoutput.org/service/r2/addstatus.jsp"
disuye
(disuye)
February 23, 2024, 10:22am
2
I’ve stumbled into the same error, with this – anyone have any clues?
shell_command:
umbrel_getblockcount: curl -k "http://username:[email protected] :8332/" -d '{"jsonrpc": "1.0", "id": "homeassistant", "method": "getblockcount", "params": []}'
I think it might have something to do with the {
character.
RoadkillUK
(Roadkill Uk)
February 23, 2024, 10:55am
3
disuye:
umbrel_getblockcount: curl -k "http://username:[email protected] :8332/" -d '{"jsonrpc": "1.0", "id": "homeassistant", "method": "getblockcount", "params": []}'
Just out of interest, could it be the quotes? Should have single inside double quotes maybe?
umbrel_getblockcount: curl -k "http://username:[email protected] :8332/" -d "{'jsonrpc': '1.0', 'id': 'homeassistant', 'method': 'getblockcount', 'params': []}"
I’m just guessing here.
1 Like
disuye
(disuye)
February 23, 2024, 11:16am
4
Tried that, still the same error…
Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/configuration.yaml”, line 60, column 127
Column 127 I think is the {
so there must be a way to escape that for Home Assistant / yaml which I’m missing.
RoadkillUK
(Roadkill Uk)
February 23, 2024, 11:29am
5
OK, I spent 2 days trying to POST
to traccar server. I finally found a solution and wondering if you could use the same technique ?
1 Like
disuye
(disuye)
February 23, 2024, 5:51pm
6
Solution: Remove all spaces from the JSON payload. Dumb but true.
shell_command:
umbrel_getblockcount: curl -k "http://username:[email protected] :8332/" -d '{"jsonrpc":"1.0","id":"homeassistant","method":"getblockcount","params":[]}'
The above code successfully passes Dev Tools yaml validation. Whereas…
shell_command:
umbrel_getblockcount: curl -k "http://username:[email protected] :8332/" -d '{"jsonrpc": "1.0", "id": "homeassistant", "method": "getblockcount", "params": []}'
… fails.
1 Like
wtf; I’d never have considered this
thanks a lot
1 Like
disuye
(disuye)
February 23, 2024, 7:54pm
8
I might be an idiot but I am a persistent idiot
Glad to have helped (in a 3 year old thread lol!)