Run Bash Script in Raspberry Pi via Ifttt

IFTTT & Raspberry pi: Assigning value from terminal to IFTTT web request

Expressions inside single quotes do not get expanded in the shell, they are taken as literal. That means, if you store your IP address in a variable called ip like this:

ip=$(dig +short myip.opendns.com @resolver1.opendns.com)

and you put that in single quotes, it won't get expanded:

echo '$ip'
$ip

whereas if you put it in double quotes, it will get expanded:

echo "$ip"
192.80.136.233

So, you need double quotes, but that will cause a problem because you need double quotes around your JSON strings, so you need to escape those by prefixing them with backslashes. So, you want:

curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$ip\"}"

IFTTT Applet Creation with maker

Unfortunately, the short answer (as far as I know) is no. It is possible to create an applet where you can say "alexa, trigger preset abc" and then, using the Maker applet, have that send a web request to a server/REST API, which you could have configured to connect to multiple different services through your own code.



Related Topics



Leave a reply



Submit