Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
laco wrote: ↑Sunday 04 November 2018 17:40
Current status: 0 (Normal)
Standard output/error:
/volume1/@appstore/domoticz/var/scripts/getTemp.sh: line 1: !/bin/bash: No such file or directory
cat: /volume1/@appstore/domoticz/var/scripts/ipx800.log
: No such file or directory
/volume1/@appstore/domoticz/var/scripts/getTemp.sh: line 15: bc: command not found
cat: /volume1/@appstore/domoticz/var/scripts/ipx800.log
: No such file or directory
/volume1/@appstore/domoticz/var/scripts/getTemp.sh: line 18: bc: command not found
/volume1/@appstore/domoticz/var/scripts/getTemp.sh: line 23: $'else\r': command not found
IPX800 not responding to ping, is it connected to LAN?
Did you ever installed IPKG / OPKG or Debian chroot on your NAS ?
You need at least one of these to be able to use this Shell and tools. If not I suggest you go to a Synology forum on how to do that as it not really domoticz related.
#!/bin/bash
IPX800=192.168.1.125
LOGFILE="/volume1/docker/domoticz/ipx800.log"
DOMOTICZSERVER=192.168.1.200
DOMOTICZPORT=8084
#Create virtual sensors in Domoticz and enter their IDX's here. For the sensor types
IDX_TEMP_1=16
IDX_TEMP_2=17
IDX_TEMP_3=
IDX_TEMP_4=
if ping -c 1 $IPX800 > /dev/null ; then # if host is online then
#Retrieve temperatures from IPX800
curl --silent http://$IPX800/status.xml > $LOGFILE
TEMP_1=$(cat $LOGFILE | grep "<an1>" | cut -d ">" -f 2 | cut -d "<" -f 1)
TEMP_1=$(echo 'scale=1;'"$TEMP_1*0.323-50.1" | bc | awk '{printf("%.1f\n", $1)}')
#echo $TEMP_1
TEMP_2=$(cat $LOGFILE | grep "<an2>" | cut -d ">" -f 2 | cut -d "<" -f 1)
TEMP_2=$(echo 'scale=1;'"$TEMP_2*0.323-50.1" | bc | awk '{printf("%.1f\n", $1)}')
#echo $TEMP_2
TEMP_3=$(cat $LOGFILE | grep "<an3>" | cut -d ">" -f 2 | cut -d "<" -f 1)
TEMP_3=$(echo 'scale=1;'"$TEMP_3*0.323-50.1" | bc | awk '{printf("%.1f\n", $1)}')
#echo $TEMP_3
for i in 1 2 3
do
#report Temperature
eval IDX='$'IDX_TEMP_$i
eval TEMP='$'TEMP_$i
curl --silent $DOMOTICZSERVER:$DOMOTICZPORT'/json.htm?type=command¶m=udevice&idx='$IDX'&svalue='$TEMP > /dev/null
done
else
echo "IPX800 not responding to ping, is it connected to LAN?"
fi
Now it writes an error:
/volume1/docker/domoticz/getTemp.sh: line 21: bc: command not found
/volume1/docker/domoticz/getTemp.sh: line 25: bc: command not found
/volume1/docker/domoticz/getTemp.sh: line 29: bc: command not found
If I delete the bc command in the script, the script runs without error and writes zero values to the IDX16 and IDX17 virtual temperature cores.
I do not know where the error is.
-- script time pour lire les valeurs analogique de l ipx
commandArray = {}
function arrondir(num, dec)
if num == 0 then
return 0
else
local mult = 10^(dec or 0)
return math.floor(num * mult + 0.5) / mult
end
end
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local config=assert(io.popen('curl "http://192.168.xx.xx/api/xdevices.json?cmd=30"'))
local Stringjson = config:read('*all')
config:close()
local jsonData = json:decode(Stringjson)
temp = jsonData.AN1
temp1 =arrondir(((temp* 0.00323) - 1.63) / 0.0326),2
lumiere = jsonData.AN2
lumiere1 = arrondir(lumiere/10)
humidite = jsonData.AN3
humidite1 =(((((humidite * 0.00323) / 3.3) - 0.1515)) / 0.00636)
ajust = (1.0546 - (0.00216 * temp1))
humidite2 = arrondir(humidite1/ajust),2
local m = os.date('%M')
if (m % 15 == 0) then
commandArray[1]={['OpenURL']='http://192.168.xx.xx:xxxx/json.htm?type=command¶m=udevice&idx=67&nvalue=0&svalue='.. temp1 }
commandArray[2]={['OpenURL']='http://192.168.xx.xx:xxxx/json.htm?type=command¶m=udevice&idx=68&nvalue=0&svalue='.. lumiere1 }
commandArray[3]={['OpenURL']='http://192.168.xx.xx:xxxx/json.htm?type=command¶m=udevice&idx=69&nvalue=0&svalue='.. humidite2 }
end
return commandArray