I got an error when i run the bash script below.
pi@raspberrypi:~/dev-domoticz/scripts $ ./dht_22.sh
21.2
48.2
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
Set-Cookie: SID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT
<html><head><title>Unauthorized</title></head><body><h1>
This script reads the DHT22 chip for temp and humidity dht_22.sh and communicate with the Domoticz server with json. So i can see the current temp/humi on my Domoticz server:
#!/bin/sh
# Domoticz server
SERVER="10.0.0.110:8080"
# DHT IDX
DHTIDX="4"
# DHTPIN
DHTPIN="4"
# TEMP FILE
TMPFILE="/var/tmp/temp.txt"
cpt=0
while [ $cpt -lt 6 ]
do
TEMP=""
sleep 5
sudo nice -20 /home/pi/dev-domoticz/scripts/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 $DHTPIN > /var/tmp/temp.t$
#TEMP=$(cat /var/tmp/temp.txt | grep "Temp" | awk '{ print $3 }')
#TEMP=$(cat /var/tmp/temp.txt | grep "Temp")
TEMP=$(awk ' /Temp/ {print substr ($0,6,4)}' /var/tmp/temp.txt)
HUM=$(awk ' /Humidity/ {print substr ($0,22,4)}' /var/tmp/temp.txt)
echo $TEMP
echo $HUM
# Send data
curl -s -i -H "Accept: application/json" "http://10.0.0.110:8080/json.htm?type=command¶m=udevice&idx=$DHTIDX&nv$
TEMP=""
HUM=""
exit 0
cpt=$(($cpt+1))
done
exit 1
When i just run the json line in a browser, i also receive a 401 Unauthorized error. I gues i have to enter some login information, so i also tryed something like this:
http://10.0.0.110:8080/json.htm?username=test=&password=test=&type=command¶m=udevice&idx=4&nvalue=0&svalue=21;40;2
But still the 401 error.
Can some one help me out?
Well, cost me some time but it work now. Your solution was correct Viktor Khilin but my Domoticz software gave me some problems.
The solution was this:
Thanks for helping me out.