I installed a LDR sensor at the GPIO pins on my raspberry pi.
I would like to insert the data at domoticz, so I created a dummy lux sensor.
I found a python script from Adafruit for reading the LDR sensor data.
I modified a dht22 .sh script for reading the LDR sensor (starting python script from reading the data), store the data in a tmp file, and send it to domoticz.
The first steps worked very well, the script reads the data and store it in the tmp file. But it doesn't send the data to domoticz.
Is somebody prepared to help me create the last step from sending the data to domoticz?
Code: Select all
#!/bin/bash
# Domoticz server
SERVER="192.168.0.7:80"
# IDX DHT
# The number of the IDX in the list of peripherals
DHTIDX="24"
#DHTPIN
# THE GPIO or connects DHT11
DHTPIN="27"
TMPFILE="/var/tmp/lux.txt"
cpt=0
while [ $cpt -lt 6 ]
do
TEMP=""
sleep 5
sudo nice -20 /home/pi/ldr.py > $TMPFILE
TEMP=$(cat $TMPFILE|grep Temp |awk '{print $1}')
if [ $TEMP ]
then
TEMP=$(cat $TMPFILE|grep Temp |awk '{print $1}' |sed -r 's/^.*=//' | sed -r 's/\*//')
echo "TEMP: $TEMP"
# send data
curl -s -i -H "Accept: application/json" "http://$SERVER/json.htm?type=devices&rid=24value=$TEMP"
TEMP=""
#rm $TMPFILE
exit 0
fi
echo "CPT: $cpt"
cpt=$(($cpt+1))
done
exit 1