Page 2 of 2
Re: Add support for IPX800, a standalone relay webserver
Posted: Sunday 04 November 2018 22:31
by waaren
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.
Re: Add support for IPX800, a standalone relay webserver
Posted: Monday 05 November 2018 7:03
by laco
I installed it from webpage:
http://www.jadahl.com/
Re: Add support for IPX800, a standalone relay webserver
Posted: Friday 18 January 2019 18:42
by laco
Can you help me again?
The created temp file is OK.
Examples and script:
Code: Select all
#!/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
Re: Add support for IPX800, a standalone relay webserver
Posted: Saturday 19 January 2019 19:44
by laco
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.
Re: Add support for IPX800, a standalone relay webserver
Posted: Monday 28 January 2019 16:28
by laco
PHP script for server synology transfer analog signal to domoticz
cron run every 5 minutes
wget
http://localhost/...../getTemp.php
CODE the file getTemp.php
Code: Select all
<?php
$url_ipx_800 = "192.168.1.125/status.xml"; //IP adress IPX800
$url_domiticzserver = "192.168.1.200"; // IP adress DOMOTICZ
$domiticzport = "8084" ; // 8084
$domiticz_login = "login"; //enter login from domoticz
$domiticz_password = "password"; //enter password from domoticz
$temp0_url1 ="http://" . $url_ipx_800;
$IDX_TEMP_1 = 16; //virtual temp IDX16 DOMOTICZ
$IDX_TEMP_2 = 17; //virtual temp IDX17 DOMOTICZ
$IDX_TEMP_3= 0;
$IDX_TEMP_4= 0;
$xml = simplexml_load_file($temp0_url1);
// IPX800 V2, PRO
$temp0_led0 = (string) $xml->led0;
$temp0_led1 = (string) $xml->led1;
$temp0_led2 = (string) $xml->led2;
$temp0_led3 = (string) $xml->led3;
$temp0_led4 = (string) $xml->led4;
$temp0_led5 = (string) $xml->led5;
$temp0_led6 = (string) $xml->led6;
$temp0_led7 = (string) $xml->led7;
$temp0_btn0 = (string) $xml->btn0;
$temp0_btn1 = (string) $xml->btn1;
$temp0_btn2 = (string) $xml->btn2;
$temp0_btn3 = (string) $xml->btn3;
$temp0_an1 = (string) $xml->an1; //sonde LM35Z
$temp0_an2 = (string) $xml->an2;
$temp0_time0 = (string) $xml->time0;
$float_temp0_an1 = floatval($temp0_an1);
// $float_temp0_an2 = floatval($temp0_an2);
$vt_temp0_an1 = round(($float_temp0_an1 * 0.323), 1, PHP_ROUND_HALF_UP) ; //Rounded to 1 decimal places
// $vt_temp0_an2 = round(($float_temp0_an2 * 0.323), 1, PHP_ROUND_HALF_UP) ;
$go_to_address0 = "http://" . $domiticz_login . ":" . $domiticz_password . "@" . $url_domiticzserver . ":" . $domiticzport . "/json.htm?type=command¶m=udevice&idx=" . $IDX_TEMP_1 . "&svalue=" . $vt_temp0_an1 . "\n" ;
// $go_to_address1 = urlencode($go_to_address0);
// $go_to_address2 = "http://" . $domiticz_login . ":" . $domiticz_password . "@" . $url_domiticzserver . ":" . $domiticzport . "/json.htm?type=command¶m=udevice&idx=" . $IDX_TEMP_2 . "&svalue=" . $vt_temp0_an2 . "\n" ;
// $go_to_address3 = urlencode($go_to_address2);
header('Location: ' . $go_to_address0);
// header('Location: ' . $go_to_address2);
exit;
?>
Produced by
https://www.salling.sk/
Re: Add support for IPX800, a standalone relay webserver
Posted: Tuesday 02 April 2019 8:07
by laco
Does anyone have created a LUA script for IPX800?
Re: Add support for IPX800, a standalone relay webserver
Posted: Thursday 04 April 2019 8:04
by xaxa
in LUA I found that, but I had a problem with the password
Code: Select all
-- 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
Re: Add support for IPX800, a standalone relay webserver
Posted: Thursday 04 April 2019 12:04
by laco
It works on Synology server.
I also give examples:
Electricity Current/Ampere 3 Phase
Code: Select all
-- Odber 3 fázy
--time=os.date("*t")
IDX=44 --virtual CM113, Electrisave
json = (loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")() -- For Synology Linux
local config=assert(io.popen('/usr/bin/curl "http://login:[email protected]/api/xdevices.json?cmd=30"'))
local blocjson = config:read('*all')
config:close()
-- print (blocjson)
local jsonValeur = json:decode(blocjson)
commandArray = {}
-- if time.min%2==0 then --[2min test]--
faza1=(tonumber(jsonValeur.AN6)/310) --Three-phase energy meter EM-3PH on IPX800V3
faza2=(tonumber(jsonValeur.AN7)/310) --Three-phase energy meter EM-3PH on IPX800V3
faza3=(tonumber(jsonValeur.AN8)/310) --Three-phase energy meter EM-3PH on IPX800V3
print ('faza1 : ' .. faza1) --prints a value.
print ('faza2 : ' .. faza2) --prints a value.
print ('faza3 : ' .. faza3) --prints a value.
commandArray['UpdateDevice'] = IDX .."|0|"..faza1..";"..faza2..";"..faza3..";"
--end
return commandArray
Script LUA other analog
Code: Select all
-- script lua analog z IPX800 V3
time=os.date("*t")
-- zariadenia v DOMOTICZ čísla IDX
IDX1=39 --svetlo
IDX2=23 --terasa
IDX3=17 --vojnany
IDX4=12 --izba
json = (loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")() -- For Synology linux
local config=assert(io.popen('/usr/bin/curl "http://login:[email protected]/api/xdevices.json?cmd=30"'))
local blocjson = config:read('*all')
config:close()
-- print (blocjson)
local jsonValeur = json:decode(blocjson)
commandArray = {}
if time.min%2==0 then --[Dal som 2min na test]--
analog1=(tonumber(jsonValeur.AN1)*0.09775),1 --Light-LS100 Intenzita svetla
analog2=(tonumber(jsonValeur.AN2)*0.323),1 --Lm35 teplota terasa
analog3=(tonumber(jsonValeur.AN3)*0.323-50),1 --T4012 teplota Vojnany
analog4=(tonumber(jsonValeur.AN4)*0.323),1 --Lm35 teplota izba
print ('analog1 : ' .. analog1) -- zobrazenie AN1.
print ('analog2 : ' .. analog2) -- zobrazenie AN2.
print ('analog3 : ' .. analog3) -- zobrazenie AN3.
print ('analog4 : ' .. analog4) -- zobrazenie AN4.
commandArray[1]={['UpdateDevice'] = IDX1 .. '|0|' .. tostring(analog1) }
commandArray[2]={['UpdateDevice'] = IDX2 .. '|0|' .. tostring(analog2) }
commandArray[3]={['UpdateDevice'] = IDX3 .. '|0|' .. tostring(analog3) }
commandArray[4]={['UpdateDevice'] = IDX4 .. '|0|' .. tostring(analog4) }
end
return commandArray
Re: Add support for IPX800, a standalone relay webserver
Posted: Friday 05 April 2019 19:34
by laco
I get the resulting values to 3 decimal places.
How can I round it to 1 decimal place?