That did the trick Reverted back to the os.execute and now it's working fine.Egregius wrote:Did you revert the lua script to the original os.execute?
At least the other command showed me the dl error
Moderator: leecollings
That did the trick Reverted back to the os.execute and now it's working fine.Egregius wrote:Did you revert the lua script to the original os.execute?
Code: Select all
2016-11-30 06:19:04.585 User: Admin initiated a switch command (162/brander/On)
2016-11-30 06:19:04.585 OpenZWave: Domoticz has send a Switch command! NodeID: 22 (0x16)
2016-11-30 06:19:04.585 (ZWAVE) Light/Switch (brander)
2016-11-30 06:19:00.538 --- SWITCH On brander dif = -0.8 in , was off for 1:56
2016-11-30 06:19:04.584 --- SWITCH On brander dif = -0.8 in , was off for 1:56 repeat
2016-11-30 06:19:14.506 (ZWAVE) Temp (badkamer_temp)
2016-11-30 06:19:14.861 (ZWAVE) Light/Switch (pirinkom)
2016-11-30 06:19:24.278 (ZWAVE) Temp (living_temp)
2016-11-30 06:19:25.500 (ZWAVE) Thermostat (livingZE)
2016-11-30 06:19:30.573 (ZWAVE) Light/Switch (pirliving)
Warning: file_get_contents(http://192.168.2.4/goform/formMainZone_MainZoneXml.xml?_=1480483126): failed to open stream: No route to host in /volume1/web/secure/pass2php.php on line 66
Warning: file_get_contents(http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON&cmd1=aspMainZone_WebUpdateStatus%2F): failed to open stream: No route to host in /volume1/web/secure/pass2php.php on line 68
Warning: file_get_contents(http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_InputFunction/TUNER): failed to open stream: No route to host in /volume1/web/secure/pass2php.php on line 69
Warning: file_get_contents(http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON&cmd1=aspMainZone_WebUpdateStatus%2F&ZoneName=ZONE2): failed to open stream: No route to host in /volume1/web/secure/pass2php.php on line 70
Warning: file_get_contents(http://192.168.2.4/goform/formMainZone_MainZoneXml.xml?_=1480483139): failed to open stream: No route to host in /volume1/web/secure/pass2php.php on line 66
Warning: file_get_contents(http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON&cmd1=aspMainZone_WebUpdateStatus%2F): failed to open stream: No route to host in /volume1/web/secure/pass2php.php on line 68
Warning: file_get_contents(http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_InputFunction/TUNER): failed to open stream: Connection refused in /volume1/web/secure/pass2php.php on line 69
Warning: file_get_contents(http://192.168.2.4/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON&cmd1=aspMainZone_WebUpdateStatus%2F&ZoneName=ZONE2): failed to open stream: HTTP request failed! in /volume1/web/secure/pass2php.php on line 70
2016-11-30 06:19:42.686 (ZWAVE) Light/Switch (pirliving)
2016-11-30 06:19:46.452 (ZWAVE) Temp (zolder_temp)
2016-11-30 06:19:54.609 (ZWAVE) Temp (badkamer_temp)
2016-11-30 06:20:13.850 (ZWAVE) Light/Switch (pirliving)
2016-11-30 06:20:14.655 (ZWAVE) Temp (badkamer_temp)
2016-11-30 06:20:22.630 (ZWAVE) Thermostat (alexZ)
2016-11-30 06:20:29.864 (ZWAVE) Thermostat (livingZZ)
2016-11-30 06:20:34.687 (ZWAVE) Temp (badkamer_temp)
2016-11-30 06:20:43.773 (ZWAVE) Light/Switch (pirliving)
2016-11-30 06:20:54.726 (ZWAVE) Temp (badkamer_temp)
2016-11-30 06:21:00.575 wunderground -5.0 -4.6 1.0 1.9 Newtemp=-4.2
2016-11-30 06:21:04.746 (ZWAVE) Temp (badkamer_temp)
2016-11-30 06:21:18.377 (ZWAVE) Light/Switch (pirkeuken)
Code: Select all
os.execute('curl -s --data "c='..c..'&s='..s..'&i='..i..'&t='..t..'" http://127.0.0.1/secure/pass2php.php >> /var/log/pass2php.log &')
Code: Select all
$events=array(266=>'pirliving',268=>'pirliving',272=>'pirkeuken',276=>'pirgarage',280=>'pirinkom',284=>'pirhall');
Code: Select all
function PIRkitchen(){
global $a,$s,$i,$t;
if($a=='On'){
//do your stuff
sw($i['LightKitchen'],'On');
}
}
Code: Select all
Array
(
[living_temp] => 20.7
[living_temp_Temperature] => 20.700000762939
)
Don't understand what you mean by this exactly.Westcott wrote:and had a listener for Lua event data, then it could hold any state data as well?
Code: Select all
error_reporting(E_ALL);
ini_set("display_errors","on");
date_default_timezone_set('Europe/Brussels');
define('time',$_SERVER['REQUEST_TIME']);
$c=json_decode(base64_decode($_REQUEST['c']),true);
$s=json_decode(base64_decode($_REQUEST['s']),true);
$i=json_decode(base64_decode($_REQUEST['i']),true);
$t=json_decode(base64_decode($_REQUEST['t']),true);
if(function_exists(key($c)))key($c)();
//START USERFUNCTIONS
function devicename(){
if($s['devicename']=='On')sw($i['light'],'On');
}
Code: Select all
function alex_set(){verwarming();}
function alex_temp(){verwarming();}
function kamer_set(){verwarming();}
function kamer_temp(){verwarming();}
function living_set(){verwarming();}
function living_temp(){verwarming();}
function tobi_set(){verwarming();}
function tobi_temp(){verwarming();}
function verwarming(){
//.....
}
I just didn't got the DL error message in the log, other messages are written to the log, so that's working fine.Egregius wrote:That I don't understand because I get all output generated by the script directly in the domoticz logfile.
Code: Select all
2016-11-30 22:51:24.592 User: Admin initiated a switch command
2016-11-30 22:51:24.592 Dummy: Lighting 1 | Test_switch
2016-11-30 22:51:24.649 => SWITCH On 1
2016-11-30 22:51:24.649 User: Admin initiated a switch command
2016-11-30 22:51:24.649 RFXCOM: Lighting 2 | Ledlampen zolder
Code: Select all
if(strtotime($t['pirkeuken'])<time-118&&strtotime($t['wasbak'])<time-118&&$s['pirkeuken']=='Off'&&$s['wasbak']=='On'&&$s['werkblad']=='Off'&&$s['keuken']=='Off'&&$s['kookplaat']=='Off')
sw($i['wasbak'],'Off');
Code: Select all
if(strtotime($t['pirkeuken'])<time-118&&$s['wasbak']=='On')
sw($i['wasbak'],'Off');
Code: Select all
function belknop()
{
global $s,$i;
if($s['belknop']=="On"&&$s['meldingen']=='On')
{
if(cget('timetelegramdeurbel')<time-57)
{
cset('timetelegramdeurbel',time);
if($s['weg']=='Off'&&$s['slapen']=='Off')
sw($i['deurbel'],'On','deurbel');
if($s['slapen']=='Off')
{
telegram('Deurbel',false,'Kirby');
ios('Deurbel');
}
else
telegram('Deurbel',true,'Kirby');
$ctx=stream_context_create(array('http'=>array('timeout'=>3)));
file_get_contents('http://192.168.2.11/telegram.php?snapshot=true',false,$ctx);
file_get_contents('http://192.168.2.11/fifo_command.php?cmd=record%20on%205%2055',false,$ctx);
if($s['zon']<=10)
sw($i['voordeur'],'On');
}
}
}
Egregius wrote:Oh, forgot to mention:
My way is better than ON FOR X
On for X WILL switch off the switch after that time, no mather what.
My way has the possibility to check multiple stuff before switching of.
Code: Select all
sudo apt-get install php5
sudo apt-get install php5-cli
Code: Select all
JSON=loadfile('/home/linaro/domoticz/scripts/lua/JSON.lua')()
base64=loadfile('/home/linaro/domoticz/scripts/lua/ee5_base64.lua')()
changed=base64.encode(JSON:encode(devicechanged))
devices=base64.encode(JSON:encode(otherdevices))
idx=base64.encode(JSON:encode(otherdevices_idx))
lastupdate=base64.encode(JSON:encode(otherdevices_lastupdate))
os.execute( '/home/linaro/domoticz/scripts/php/pass2php.php "'..changed..'" "'..devices..'" "'..idx..'" "'..lastupdate..'" &')
commandArray = {}
return commandArray
Code: Select all
#!/usr/bin/php
<?php
$c=json_decode(base64_decode($_REQUEST['c']),true);
$s=json_decode(base64_decode($_REQUEST['s']),true);
$i=json_decode(base64_decode($_REQUEST['i']),true);
$t=json_decode(base64_decode($_REQUEST['t']),true);
$a=$s[key($c)];$devidx=$i[key($c)];
$events=array(
226=>'motion_keuken',
672=>'motion_trap_boven',
524=>'motion_trap',
366=>'motion_kastenkamer'
);
if(isset($events[$devidx]))$events[$devidx]();
//START USERFUNCTIONS
function motion_kastenkamer(){
global $a,$s,$i,$t;
if($a=="On"){
// sw($i['Lamp (Kastenkamer)'],'On');
sw(62,'On'); // 62 = Lamp Kastenkamer
}
}
//END USERFUNCTIONS. Only change IP:PORT and ios,sms account details below
function sw($idx,$action="",$info="",$Usleep=600000){lg("SWITCH ".$action." ".$info);if(empty($action))curl("http://192.168.2.10:8080/json.htm?type=command¶m=switchlight&idx=".$idx."&switchcmd=Toggle");else curl("http://192.168.2.10:8080/json.htm?type=command¶m=switchlight&idx=".$idx."&switchcmd=".$action);usleep($Usleep);}
function sl($idx,$level,$info="",$Usleep=600000){lg("SETLEVEL ".$level." ".$info);curl("http://192.168.2.10:8080/json.htm?type=command¶m=switchlight&idx=".$idx."&switchcmd=Set%20Level&level=".$level);usleep($Usleep);}
function ud($idx,$nvalue,$svalue,$info="",$Usleep=600000){if(!in_array($idx, array(395,532,534)))lg("UPDATE ".$nvalue." ".$svalue." ".$info);curl('http://192.168.2.10:8080/json.htm?type=command¶m=udevice&idx='.$idx.'&nvalue='.$nvalue.'&svalue='.$svalue);usleep($Usleep);}
function double($idx,$action,$comment='',$wait=4000000){sw($idx,$action,$comment,$wait);sw($idx,$action,$comment.' repeat',0);}
function lg($msg){curl('http://192.168.2.10:8080/json.htm?type=command¶m=addlogmessage&message='.urlencode('=> '.$msg));}
function curl($url){$headers=array('Content-Type: application/json');$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE);curl_setopt($ch,CURLOPT_TIMEOUT,5);$data=curl_exec($ch);curl_close($ch);return $data;}
Code: Select all
sw(62,'On'); // 62 = Lamp Kastenkamer
Code: Select all
<?php
error_reporting(E_ALL);
ini_set("display_errors","on");
date_default_timezone_set('Europe/Brussels');
define('time',$_SERVER['REQUEST_TIME']);
$c=json_decode(base64_decode($_REQUEST['c']),true);
$s=json_decode(base64_decode($_REQUEST['s']),true);
$i=json_decode(base64_decode($_REQUEST['i']),true);
$t=json_decode(base64_decode($_REQUEST['t']),true);
$r=str_replace(" ","_",key($c));
lg('Pass2PHP triggered by '.key($c));
if(function_exists(key($c)))
key($c)();
elseif(function_exists($r))
$r();
//START USER FUNCTIONS
function motion_kastenkamer()
{
lg('Executing function motion_kastenkamer');
global $s,$i,$t;
if($s['motion_kastenkamer'=="On")
{
sw(62,'On');
}
}
Will post results tomorrow Tnx already for your help. I want 40ms responsiveness too!Egregius wrote:Try the newest version 2.2.
Then you don't need the array anymore.
Your function name is the trigger then. That has to be exactly as the device that triggers the event.
So in your case motion_kastenkamer
Don't know about the ( and ) in the name, not sure if php accepts that as a variable name.
For debugging, add some print statements, or if you have version 2.2 you can use the lg function to log to domoticz.All lg or print statements should come in the Domoticz log. Use tail -f domoticz.log to see it in realtime.Code: Select all
<?php error_reporting(E_ALL); ini_set("display_errors","on"); date_default_timezone_set('Europe/Brussels'); define('time',$_SERVER['REQUEST_TIME']); $c=json_decode(base64_decode($_REQUEST['c']),true); $s=json_decode(base64_decode($_REQUEST['s']),true); $i=json_decode(base64_decode($_REQUEST['i']),true); $t=json_decode(base64_decode($_REQUEST['t']),true); $r=str_replace(" ","_",key($c)); lg('Pass2PHP triggered by '.key($c)); if(function_exists(key($c))) key($c)(); elseif(function_exists($r)) $r(); //START USER FUNCTIONS function motion_kastenkamer() { lg('Executing function motion_kastenkamer'); global $s,$i,$t; if($s['motion_kastenkamer'=="On") { sw(62,'On'); } }
Users browsing this forum: No registered users and 1 guest