tnx, Some testing to do for me tonight, will report the resultsEgregius wrote:Correct, by just concatenating all statusses in to a csv string I avoided the need of json and base64 wich seems to save about 10msec of response time.
Currently I'm at 21msec by just sending devicechanged and otherdevices but that requires quite some recoding of scripts to store all idx's and lastupdate times in APCu cache.
For the switches with a space in them, probably this will do:Code: Select all
foreach($c as $device=>$status) if(!empty($status)){ $devicer=str_replace(" ","_",$device); if(false!==stream_resolve_include_path('pass2php/'.$device.'.php'))include 'pass2php/'.$device.'.php'; elseif(false!==stream_resolve_include_path('pass2php/'.$devicer.'.php'))include 'pass2php/'.$devicer.'.php'; } include 'pass2php/__CRON.php';
Pass2PHP
Moderator: leecollings
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Mmm so I modified my pass2php.php to:
and the device.lua to:
The only thing that shows up in the domoticz log is:
No .php is executed. It seems something is wrong with the pass2php.php file I would say?
Calling the pass2php.php from a webbrowser ends according to my expectations:
Any idea? I also added function ex() to my php code, that one I was missing as well.
Code: Select all
$c=ex($_REQUEST['c']);
$s=ex($_REQUEST['s']);
$i=ex($_REQUEST['i']);
$t=ex($_REQUEST['t']);
foreach($c as $device=>$status)
if(!empty($status)){
$devicer=str_replace(" ","_",$device);
lg('Step 1: Pass2PHP de functie is: '.key($device));
lg('Step 2: Pass2PHP de functie REVEERSED is: '.key($devicer));
if(false!==stream_resolve_include_path('pass2php/'.$device.'.php'))include 'pass2php/'.$device.'.php';
elseif(false!==stream_resolve_include_path('pass2php/'.$devicer.'.php'))include 'pass2php/'.$devicer.'.php';
}
//include 'pass2php/__CRON.php';
include 'pass2php/Solar_PHP.php'; Code: Select all
print("Start of script device");
c = ''
s = ''
i = ''
t = ''
for k,v in pairs(devicechanged) do c = c..k.."|"..v.."#" end
for k,v in pairs(otherdevices) do s = s..k.."|"..v.."#" end
for k,v in pairs(otherdevices_idx) do i = i..k.."|"..v.."#" end
for k,v in pairs(otherdevices_lastupdate) do t = t..k.."|"..v.."#" end
print("End of script device");
os.execute('curl -s --data "c='..c..'&s='..s..'&i='..i..'&t='..t..'" http://192.168.2.10/php/pass2php.php &')
commandArray={}
return commandArray
Code: Select all
2016-12-23 14:44:45.590 LUA: Start of script device
2016-12-23 14:44:45.602 LUA: End of script device
Calling the pass2php.php from a webbrowser ends according to my expectations:
Code: Select all
Notice: Undefined index: c in /var/www/php/pass2php.php on line 19
Notice: Undefined index: s in /var/www/php/pass2php.php on line 20
Notice: Undefined index: i in /var/www/php/pass2php.php on line 21
Notice: Undefined index: t in /var/www/php/pass2php.php on line 22Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
the ip address is good? Better to use 127.0.0.1 if the webserver is on the same server as domoticz.
If you want to log what function is executed I would do it like this:
By adding multiple lg's (or even ordanary print/echo lines) it's easier to debug where it goes wrong.
Another nice one herefore is:
lg(__LINE__);
Wich will print the linenumber where you called the lg function (had this morning a script that failed and needed to ad about 40 of them to find out where it crashed...).
Put a double // before the lg lines ones it works to avoid unnescessary calls.
If you want to log what function is executed I would do it like this:
Code: Select all
lg('Step 1: Started');
$c=ex($_REQUEST['c']);
$s=ex($_REQUEST['s']);
$i=ex($_REQUEST['i']);
$t=ex($_REQUEST['t']);
foreach($c as $device=>$status)
lg('Step 2: Changed device = '.$device);
if(!empty($status)){
$devicer=str_replace(" ","_",$device);
if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')){
lg('Step 3: executing file '.$device.'.php');
include 'pass2php/'.$device.'.php';
}elseif(false!==stream_resolve_include_path('pass2php/'.$devicer.'.php')){
lg('Step 3: executing file '.$devicer.'.php');
include 'pass2php/'.$devicer.'.php';
}
}
//include 'pass2php/__CRON.php';
include 'pass2php/Solar_PHP.php';
lg('Step 4: Ready!');
Another nice one herefore is:
lg(__LINE__);
Wich will print the linenumber where you called the lg function (had this morning a script that failed and needed to ad about 40 of them to find out where it crashed...).
Put a double // before the lg lines ones it works to avoid unnescessary calls.
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Something must be wrong.
I don't even receive the :
"lg('Step 1: Started');" in my log...
127,0,0,1 <> 192.168.2.10 does not seem to make a difference, both are the same machine indeed.
The code above will show me if something went wrong when executing the pass2php... unfortunately the output is empty so no severe errors...
I created a spare pass3php.php with your latest GITHUB code in it and that seems to work. There must be an error somewhere in my pass2php..... however if I remove your code revert back to.. JSON /LUA eg.. my pass2php works just fine.
I don't even receive the :
"lg('Step 1: Started');" in my log...
127,0,0,1 <> 192.168.2.10 does not seem to make a difference, both are the same machine indeed.
Code: Select all
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
print("Start of script device");
c = ''
s = ''
i = ''
t = ''
for k,v in pairs(devicechanged) do c = c..k.."|"..v.."#" end
for k,v in pairs(otherdevices) do s = s..k.."|"..v.."#" end
for k,v in pairs(otherdevices_idx) do i = i..k.."|"..v.."#" end
for k,v in pairs(otherdevices_lastupdate) do t = t..k.."|"..v.."#" end
print("End of script device");
-- os.execute('curl -s --data "c='..c..'&s='..s..'&i='..i..'&t='..t..'" http://192.168.2.10/php/pass2php.php &')
-- os.execute('curl -s --data "c='..c..'&s='..s..'&i='..i..'&t='..t..'" http://127.0.0.1/php/pass2php.php &')
print(os.capture('curl -s --data "c='..c..'&s='..s..'&i='..i..'&t='..t..'" http://127.0.0.1/php/pass2php.php &'));
print("Curl ended");
commandArray={}
return commandArrayI created a spare pass3php.php with your latest GITHUB code in it and that seems to work.
Code: Select all
2016-12-23 15:59:58.421 --->> Step 1: Started
2016-12-23 15:59:58.430 --->> Step 2: Changed device = TH7_Slaapkamer_Humidity
2016-12-23 15:59:58.433 --->> Step 2: Changed device = TH7_Slaapkamer
2016-12-23 15:59:58.435 --->> Step 2: Changed device = TH7_Slaapkamer_Dewpoint
2016-12-23 15:59:58.438 --->> Step 2: Changed device = TH7_Slaapkamer_Temperature
2016-12-23 15:59:58.440 --->> Step 2: Changed device =
2016-12-23 15:59:58.443 --->> Step 4: Ready!
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
And in ssh curl -s http://127.0.0.1/php/pass2php.php?
I don't see anything wrong in the code you posted.
But if the step 1 isn't printed it must be in the lua, no?
Btw, how do you look at your domoticz logfile? There's a difference between in browser and with tail -f domoticz.log... Browser doesn't show everything.
I don't see anything wrong in the code you posted.
But if the step 1 isn't printed it must be in the lua, no?
Btw, how do you look at your domoticz logfile? There's a difference between in browser and with tail -f domoticz.log... Browser doesn't show everything.
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
curl-s results
<br />
<b>Notice</b>: Undefined index: c in <b>/var/www/php/pass2php.php</b> on line <b>23</b><br />
<br />
<b>Notice</b>: Undefined index: s in <b>/var/www/php/pass2php.php</b> on line <b>24</b><br />
<br />
<b>Notice</b>: Undefined index: i in <b>/var/www/php/pass2php.php</b> on line <b>25</b><br />
<br />
<b>Notice</b>: Undefined index: t in <b>/var/www/php/pass2php.php</b> on line <b>26</b><br />
<br />
<b>Notice</b>: Undefined index: c in <b>/var/www/php/pass2php.php</b> on line <b>23</b><br />
<br />
<b>Notice</b>: Undefined index: s in <b>/var/www/php/pass2php.php</b> on line <b>24</b><br />
<br />
<b>Notice</b>: Undefined index: i in <b>/var/www/php/pass2php.php</b> on line <b>25</b><br />
<br />
<b>Notice</b>: Undefined index: t in <b>/var/www/php/pass2php.php</b> on line <b>26</b><br />
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
And also no step 1 in the logfiles?
Looked at the logfile in SSH?
I always have the logfile open in ssh, even created a alias in.profile for it so I only need to type dm
alias dm="tail -f -n 250 /volume1/appstore/domoticz/var/domoticz.log -s 0.1"
Looked at the logfile in SSH?
I always have the logfile open in ssh, even created a alias in.profile for it so I only need to type dm
alias dm="tail -f -n 250 /volume1/appstore/domoticz/var/domoticz.log -s 0.1"
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
I quited debugging
I just started over... with your latest git production in pass4php.php
Step 3 is missing so now we have to figure out why... it is not seeing the file..
I just started over... with your latest git production in pass4php.php
Code: Select all
2016-12-23 16:54:13.999 User: Admin initiated a switch command (621/ZonweringAuto/On)
2016-12-23 16:54:14.054 LUA: End of script device
2016-12-23 16:54:14.065 LUA: Curl ended
2016-12-23 16:54:14.000 (Virtual Device) Light/Switch (ZonweringAuto)
2016-12-23 16:54:14.146 --->> Step 1: Started
2016-12-23 16:54:14.155 --->> Step 2: Changed device = ZonweringAuto
2016-12-23 16:54:14.158 --->> Step 2: Changed device =
2016-12-23 16:54:14.160 --->> Step 4: Ready!Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
The file pass2php/ZonweringAuto.php exists?
Were you already at PHP7 or PHP5.6?
Maybe if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')) doesn't work in PHP5.6 and you need to previous if(file_exists('pass2php/'.$device.'.php'))
Were you already at PHP7 or PHP5.6?
Maybe if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')) doesn't work in PHP5.6 and you need to previous if(file_exists('pass2php/'.$device.'.php'))
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
still at 5.6 on my ARM based machine 
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Does it work with file_exists?
Hmm, according to http://php.net/manual/en/function.strea ... e-path.php it should work.
Hmm, according to http://php.net/manual/en/function.strea ... e-path.php it should work.
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Function should be supportedEgregius wrote:The file pass2php/ZonweringAuto.php exists?
Were you already at PHP7 or PHP5.6?
Maybe if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')) doesn't work in PHP5.6 and you need to previous if(file_exists('pass2php/'.$device.'.php'))
http://php.net/manual/en/function.strea ... e-path.php
Code: Select all
<?php
var_dump(stream_resolve_include_path("pass2php.php"));
var_dump(stream_resolve_include_path("pass2php/ZonweringAuto.php"));
?>Code: Select all
string(25) "/var/www/php/pass2php.php" string(39) "/var/www/php/pass2php/ZonweringAuto.php"Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Code: Select all
lg('Step 1: Started');
$c=ex($_REQUEST['c']);
$s=ex($_REQUEST['s']);
$i=ex($_REQUEST['i']);
$t=ex($_REQUEST['t']);
foreach($c as $device=>$status)
lg('Step 2: Changed device = '.$device);
$sresult0=stream_resolve_include_path('pass2php/'.$device.'.php');
lg('the result is: '.$sresult0);
if(!empty($status))
{
$devicer=str_replace(" ","_",$device);
//lg('Step 2a: File to look for is: pass2php'.$device.'.php');
// lg('Step 2b: File to look for is: pass2php/'.$devicer.'.php');
$sresult1=stream_resolve_include_path('pass2php/'.$device.'.php');
$sresult2=stream_resolve_include_path('pass2php/'.$devicer.'.php');
lg('the result is: '.$sresult1);
lg('the result is: '.$sresult2);
if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')){
lg('Step 3: executing file '.$device.'.php');
include 'pass2php/'.$device.'.php';
}elseif(false!==stream_resolve_include_path('pass2php/'.$devicer.'.php')){
lg('Step 3: executing file '.$devicer.'.php');
include 'pass2php/'.$devicer.'.php';
}
}
//include 'pass2php/__CRON.php';
include 'pass2php/Solar_PHP.php';
lg('Step 4: Ready!'); Code: Select all
2016-12-23 18:56:26.942 User: Admin initiated a switch command (621/ZonweringAuto/On)
2016-12-23 18:56:26.943 (Virtual Device) Light/Switch (ZonweringAuto)
2016-12-23 18:56:27.101 --->> Step 1: Started
2016-12-23 18:56:27.110 --->> Step 2: Changed device = ZonweringAuto
2016-12-23 18:56:27.113 --->> Step 2: Changed device =
2016-12-23 18:56:27.116 --->> the result is:
2016-12-23 18:56:27.119 --->> Step 4: Ready!
The result = is also empty... at least I would have expected "false" as a return from : stream_resolve_include_path
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
You forgot line 29 of https://github.com/Egregius/LUA-Pass2PH ... ss2php.php wich checks if result is filled.
This is because there's nothing in the lua file to check if it was the last item in the devicechanged table. Therefor the passed string always ends with # resulting in an empty value in the $c array.
The foreach $c was added because devicechanged sometimes holds multiple devices.
But, there's smething else wrong. Maybe try with a absolute path? Maybe I have that folder in the include path of php.ini.
This is because there's nothing in the lua file to check if it was the last item in the devicechanged table. Therefor the passed string always ends with # resulting in an empty value in the $c array.
The foreach $c was added because devicechanged sometimes holds multiple devices.
But, there's smething else wrong. Maybe try with a absolute path? Maybe I have that folder in the include path of php.ini.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
http://stackoverflow.com/questions/1932 ... rms-better
Indicates that stream_resolve... is slower, my test showed otherwise. Same page says is_file should be faster, will test that one later.
Indicates that stream_resolve... is slower, my test showed otherwise. Same page says is_file should be faster, will test that one later.
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Egregius wrote: But, there's smething else wrong. Maybe try with a absolute path? Maybe I have that folder in the include path of php.ini.
Code: Select all
if(file_exists('pass2php/'.key($c).'.php')) // Added this function to have individual files ;-) .php directory
{ include 'pass2php/'.key($c).'.php';
$c2();
if($debug3=="true")
{
lg('Step 4: Pass2PHP running de file bestaat: '.key($c));
lg('Step 5: Pass2PHP running echo file functie is: '.$c2);
}
}
elseif(file_exists('pass2php/'.($r).'.php')) // Added this function to have individual files ;-) .php directory
{ include 'pass2php/'.($r).'.php';
$r();
if($debug3=="true")
{
lg('Step 6: Pass2PHP running echo file functie is REVERSED: '.$r);
}
} Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Couldn't wait 
Did a small test again with this code:
Output should be this:
0.03386 absolute stream_resolve_include_path OK
0.03219 relative stream_resolve_include_path OK
0.17405 absolute file_exists OK
0.17095 relative file_exists OK
0.35405 absolute is_file OK
0.32997 relative is_file OK
I used 6 different existing files to avoid file caching OS things.
Personnally I find it strange that relative files are in each function a little bit faster but that's no noticable number.
The difference between the functions... Clearly in my case the stream_resolve... is the fastest.
Test in on your system, check if each line ends with OK, telling you the function works and the file is found. Use the fastest of them.
Wichever you choose, this will not be the biggest change, we're talking about 0,3 milliseconds here.
Did a small test again with this code:
Code: Select all
<?php
$start=microtime(true);
if(false!==stream_resolve_include_path('/volume1/web/secure/pass2php/pirinkom.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' absolute stream_resolve_include_path '.$result.'<br>';
$start=microtime(true);
if(false!==stream_resolve_include_path('pass2php/pirkeuken.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' relative stream_resolve_include_path '.$result.'<br>';
$start=microtime(true);
if(file_exists('/volume1/web/secure/pass2php/pirliving.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' absolute file_exists '.$result.'<br>';
$start=microtime(true);
if(file_exists('pass2php/pirgarage.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' relative file_exists '.$result.'<br>';
$start=microtime(true);
if(is_file('/volume1/web/secure/pass2php/raamtobi.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' absolute is_file '.$result.'<br>';
$start=microtime(true);
if(is_file('pass2php/pirhall.php')) $result='OK';else $result='NOK';
$total=microtime(true)-$start;
echo number_format(($total*1000),5) .' relative is_file '.$result.'<br>';
0.03386 absolute stream_resolve_include_path OK
0.03219 relative stream_resolve_include_path OK
0.17405 absolute file_exists OK
0.17095 relative file_exists OK
0.35405 absolute is_file OK
0.32997 relative is_file OK
I used 6 different existing files to avoid file caching OS things.
Personnally I find it strange that relative files are in each function a little bit faster but that's no noticable number.
The difference between the functions... Clearly in my case the stream_resolve... is the fastest.
Test in on your system, check if each line ends with OK, telling you the function works and the file is found. Use the fastest of them.
Wichever you choose, this will not be the biggest change, we're talking about 0,3 milliseconds here.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Not sure, different function could handle files differently.sincze wrote:As this is working just fine It should not be a path issue right??
Still doing research for other ways to Rome...
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Learned something new, sharing and discussing is good for knowledge 
adding a @ in front of the function silently ignores the error.
Result is that we can just include the file without checking it's existance.
0.00906 absolute @include existing. OK
0.01216 relative @include existing. OK
0.25487 @include non existing. OK
Without the @:
Warning: include(/volume1/web/secure/pass2php/tobiZ.php): failed
Warning: include(/volume1/web/secure/pass2php/tobiZ_Utility.php): failed
Warning: include(/volume1/web/secure/pass2php/.php): failed
With the @ no error at all with this file selector:
adding a @ in front of the function silently ignores the error.
Result is that we can just include the file without checking it's existance.
0.00906 absolute @include existing. OK
0.01216 relative @include existing. OK
0.25487 @include non existing. OK
Without the @:
Warning: include(/volume1/web/secure/pass2php/tobiZ.php): failed
Warning: include(/volume1/web/secure/pass2php/tobiZ_Utility.php): failed
Warning: include(/volume1/web/secure/pass2php/.php): failed
With the @ no error at all with this file selector:
Code: Select all
foreach($c as $device=>$status){
@include '/volume1/web/secure/pass2php/'.$device.'.php';
cset('t'.$device,time);
}
- sincze
- Posts: 1302
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
And the numbers are in of the 6 lookups of different .php files.
So last resort will be to look at the row 29 ... as all seems to be working just fine with php 5.6
is_file relative seems to be the fastest.
Code: Select all
0.13304 absolute stream_resolve_include_path OK
0.08202 relative stream_resolve_include_path OK
0.03505 absolute file_exists OK
0.02694 relative file_exists OK
0.12684 absolute is_file OK
0.02098 relative is_file OK
is_file relative seems to be the fastest.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Who is online
Users browsing this forum: No registered users and 1 guest