Command line quote escaping

Hi

I’m trying to send a curl command via command line sensor, but it’s dropping the double quotes " around the URL and Authorization.

This is the command: -

command: 'curl -s "https://my.tado.com/api/v1/me" -H "Authorization: Bearer {{ state_attr(''sensor.tado_auth'', ''access_token'') }}" ' 

For clarity, these are double quotes “https… …me” “Authorization… … }}”
and these are two lots of single quotes ‘‘sensor.tado_auth’’, ‘‘access_token’’
and there is a single quote at the beginning and end.

I’ve tried doubling up the double quotes, just in case, but that didn’t work.

I have another call, surrounded by single quotes, and with the url in double quotes, that works perfectly, but it doesn’t need an Authorization token

The log shows: -

Command failed: curl -s https://my.tado.com/api/v1/me -H Authorization: Bearer eyJhbGciOZD7JfPdL1V4vY526ZY-UCGg

Whereas if I use a terminal, and manually add back in the quotes it works perfectly: -

curl -s "https://my.tado.com/api/v1/me" -H "Authorization: Bearer eyJhbGciOZD7JfPdL1V4vY526ZY-UCGg" 

(I’ve shortened the token significantly)

Thanks in advance for any help

Jonathan

To answer my own question, I’ve discovered that standard escaping with \ does the trick, not doubling up of quotes

command: 'curl -s \"https://my.tado.com/api/v1/me\" -H \"Authorization: Bearer {{ state_attr(''sensor.tado_auth'', ''access_token'') }}\" ' 
2 Likes