Passing system temp to Domoticz using a bash script
Posted: Saturday 22 August 2020 11:31
I am trying to read the system temperature from my RPi and send it to Domoticz, using the following bash script:
Lines 3 and 5 are only there for testing if the values passed on to the url are correct.
However, this does not work; curl answers (3) URL using bad/illegal format or missing URL, because it apparently expects double quotes arount the url (if I directly type in something like: curl "http://192.168.1.52:8080/json.htm?type= ... &svalue=77" in the cli, the value is passed on to Domoticz without problems).
Changing line 4 to:
does not work either, because the url string will get a leading double quote, but the double quote at the end of the string still gets lost for some reason.
I tried the same with wget in stead of curl, with the same results...
Is there another way to pass such a value from bash to Domoticz or should I switch to PHP or Python for this relatively simple task?
Code: Select all
#! /bin/sh
temp=$(vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*')
echo "System temperature: $temp"
url="http://192.168.1.52:8080/json.htm?type=command¶m=udevice&idx=571&nvalue=0&svalue=$temp"
echo "$curl"
curl "$url"
However, this does not work; curl answers (3) URL using bad/illegal format or missing URL, because it apparently expects double quotes arount the url (if I directly type in something like: curl "http://192.168.1.52:8080/json.htm?type= ... &svalue=77" in the cli, the value is passed on to Domoticz without problems).
Changing line 4 to:
Code: Select all
url="\"http://192.168.1.56:8088/json.htm?type=command¶m=udevice&idx=571&nvalue=0&svalue=$temp\""
I tried the same with wget in stead of curl, with the same results...
Is there another way to pass such a value from bash to Domoticz or should I switch to PHP or Python for this relatively simple task?