Pass2PHP
Moderator: leecollings
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
I forgot what is on line 29
So strange that functions respond so different on different systems. Did you refreshed the page like 20 times to see if the result is stable?
So strange that functions respond so different on different systems. Did you refreshed the page like 20 times to see if the result is stable?
- sincze
- Posts: 1300
- 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: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.
Morning, maybe I am missing your clues, normally Ifigure them out eventually it regards line 29
Code: Select all
// LINE 29 oF EGREGIUS
//28: foreach($c as $device=>$status)
//29: if(!empty($status))
//30: if(false!==stream_resolve_include_path('pass2php/'.$device.'.php')) include 'pass2php/'.$device.'.php';
//31: include 'pass2php/__CRON.php';
foreach($c as $device=>$status)
lg('Step 2: Changed device = '.$device);
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');
lg((stream_resolve_include_path('pass2php/'.$device.'.php'));
lg((stream_resolve_include_path('pass2php/'.$devicer.'.php'));
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';
}
}
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: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Yes it was quite a refreshment... Pressing F5Egregius wrote:I forgot what is on line 29
So strange that functions respond so different on different systems. Did you refreshed the page like 20 times to see if the result is stable?
Code: Select all
0.06914 absolute stream_resolve_include_path OK
0.05889 relative stream_resolve_include_path OK
0.20790 absolute file_exists OK
0.07200 relative file_exists OK
0.05221 absolute is_file OK
0.03195 relative is_file OK
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: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
And for the empty thing:
I don't even check if the file exists anymore, the @ suppresses the errormessage. If the include was succesfull I store the timestamp in cache and set the $dev variable.
Then later is $dev is not set just die() without message.
edit: that'll be it for this year concerning speed improvements, spent enough time this week on it...
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
And for the empty thing:
Code: Select all
$c=ex($_REQUEST['c']);$s=ex($_REQUEST['s']);
foreach($c as $device=>$status)
if(@include '/volume1/web/secure/pass2php/'.$device.'.php'){apcu_store('t'.$device,time);$dev=$device;}
if(!isset($dev))die();
Then later is $dev is not set just die() without message.
edit: that'll be it for this year concerning speed improvements, spent enough time this week on it...
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Damn. I just rewrote the thing to 'define'.Egregius wrote:I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
How am I gonna sell this for christmas.
Okay so I have to install ACPU now. Let me google what it does first
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: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
No, you don't HAVE to, you might.
If you don't use cset and cget (or not much) don't bother.
I have for the moment 286 temporary variables in cache, then it starts to cound.
You don't HAVE to adopt all changes I do. You can use whatever version you feel good with.
If you don't use cset and cget (or not much) don't bother.
I have for the moment 286 temporary variables in cache, then it starts to cound.
You don't HAVE to adopt all changes I do. You can use whatever version you feel good with.
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Let starts with replace curl by file_get_contents. that sounds reasonable and keeping variables in functions where you actually use themEgregius wrote:No, you don't HAVE to, you might.
If you don't use cset and cget (or not much) don't bother.
I have for the moment 286 temporary variables in cache, then it starts to cound.
You don't HAVE to adopt all changes I do. You can use whatever version you feel good with.
don't have that much variables anyway. Just the [Zon] thing to switch things off after 3 minutes or so
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: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
If you only store 1 value in cache don't bother changing it. Will you notice a difference between 0.1 and 0.05 milliseconds?
In my last version I store all idx's and lastupdate times in cache, so I make a lot more use of it. APCu stats show me about 10 cache request / second, that's even more than on my webserver...
In my last version I store all idx's and lastupdate times in cache, so I make a lot more use of it. APCu stats show me about 10 cache request / second, that's even more than on my webserver...
-
- Posts: 58
- Joined: Saturday 17 December 2016 13:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
Hi there all,
I'm new on domoticz portal and I like so much
I also want to try your script cause I think is wonderful the story of less time for all reads.
But I still don't understand witch web server is used in domoticz...
I just install the nginx web server ... then I stoped it, but domoticz is still run
I think to install php also ... but I don't know if I need nginx modules or apache modules.
I prefer nginx + php, cause I read that is smaller and uses a lot less memory.
So ... how domoticz answer via web if all webserver is stoped ? and where is the webserver cong file of domoticz ?
Thanks in advance
Denis
I'm new on domoticz portal and I like so much
I also want to try your script cause I think is wonderful the story of less time for all reads.
But I still don't understand witch web server is used in domoticz...
I just install the nginx web server ... then I stoped it, but domoticz is still run
I think to install php also ... but I don't know if I need nginx modules or apache modules.
I prefer nginx + php, cause I read that is smaller and uses a lot less memory.
So ... how domoticz answer via web if all webserver is stoped ? and where is the webserver cong file of domoticz ?
Thanks in advance
Denis
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Domoticz has his own webserver for the gui.
For this you either need just php-cli
Or host the page on a php enabled sebserver like Apache2, Nginx,...
With a webserver you could take advantage of opcode caching in Apache2 = >double speed.
For this you either need just php-cli
Or host the page on a php enabled sebserver like Apache2, Nginx,...
With a webserver you could take advantage of opcode caching in Apache2 = >double speed.
-
- Posts: 58
- Joined: Saturday 17 December 2016 13:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
I just installed nginx+php and it's work
Now I'll put the reverse proxy of 80 and 443 ports versus 8080 of domotics.
First I must eat something
Thanks for the help
Denis
Now I'll put the reverse proxy of 80 and 443 ports versus 8080 of domotics.
First I must eat something
Thanks for the help
Denis
-
- Posts: 58
- Joined: Saturday 17 December 2016 13:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
If I make an alone page out of domoticz www folder, it's work
But if I make a page phpinfo inside www folder of domoticz I take an error: "501 Not Implemented"
I must find the configuration file of domoticz internal web server.
Thanks again
Denis
But if I make a page phpinfo inside www folder of domoticz I take an error: "501 Not Implemented"
I must find the configuration file of domoticz internal web server.
Thanks again
Denis
-
- Posts: 1
- Joined: Sunday 25 December 2016 13:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
I wanted to try your script but i can't seem to get it working, looks like the same problem 1 page back with Sincze. I tried debugging it with your comment here:
viewtopic.php?f=23&t=12343&start=160#p110324
But step 1 won't show in the log. With the new check-in running the curl manually or via browser I also receive
Which seems okay and looks like the pass2php file is not called? Any ideas what i've done wrong?
viewtopic.php?f=23&t=12343&start=160#p110324
But step 1 won't show in the log. With the new check-in running the curl manually or via browser I also receive
Code: Select all
Notice: Undefined index: c in /var/www/html/secure/pass2php.php on line 3
Notice: Undefined index: s in /var/www/html/secure/pass2php.php on line 3
-
- Posts: 111
- Joined: Monday 18 January 2016 9:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
About curl versus file_get_contents, have you tried:Egregius wrote:I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
Code: Select all
curl_setopt($ch,CURLOPT_TIMEOUT,1);
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: LUA Pass2php
Squeezing the last ms out of the response (waiting) times, nice. Keep up the good work.Sneezydevil wrote:About curl versus file_get_contents, have you tried:Egregius wrote:I did several other tests of functions and variables and changed quite a lot in the pass2php script.
Each change had about one-tenth of a millisecond improvement giving me a total of almost 2 msec...
https://github.com/Egregius/LUA-Pass2PH ... 10c85c0a16
replaced curl by file_get_contents
renamed all cset and cget calls to the apcu equivalents (apcu is way faster than memcached, will update my post about that later).
replaced lots of define... by normal variables in the function so they're only set when needed.
I did the same but then did a benchmark. In that benchmark curl with the timeout was the fastest, but have not been able to try it in the script, to see if everything still works as aspected.Code: Select all
curl_setopt($ch,CURLOPT_TIMEOUT,1);
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: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Nope, don't think I had that option.Sneezydevil wrote: About curl versus file_get_contents, have you tried:
I did the same but then did a benchmark. In that benchmark curl with the timeout was the fastest, but have not been able to try it in the script, to see if everything still works as aspected.Code: Select all
curl_setopt($ch,CURLOPT_TIMEOUT,1);
On the other hand, that's for the actions that need to return to domoticz, don't know if it effectivily makes a difference. On my Syno the file_get_contents finished about 1,5msec faster than curl. Hard to mesure if the command is then also 1,5 msec faster as in the logfile from domoticz I only have milliseconds and not microseconds.
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
The script can only be called by the lua script as that one passes the c and s array.mitchellengelage wrote:I wanted to try your script but i can't seem to get it working, looks like the same problem 1 page back with Sincze. I tried debugging it with your comment here:
viewtopic.php?f=23&t=12343&start=160#p110324
But step 1 won't show in the log. With the new check-in running the curl manually or via browser I also receiveWhich seems okay and looks like the pass2php file is not called? Any ideas what i've done wrong?Code: Select all
Notice: Undefined index: c in /var/www/html/secure/pass2php.php on line 3 Notice: Undefined index: s in /var/www/html/secure/pass2php.php on line 3
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
You need to use the www folder of apache2/nginx for the php page.denisj wrote:If I make an alone page out of domoticz www folder, it's work
But if I make a page phpinfo inside www folder of domoticz I take an error: "501 Not Implemented"
I must find the configuration file of domoticz internal web server.
Thanks again
Denis
-
- Posts: 58
- Joined: Saturday 17 December 2016 13:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
I just post a new thread here:
viewtopic.php?f=6&t=15055
I installed nginx with php support and if I use a php page outside of domoticz it's work
If I make a phpinfo page in the www folder of domoticz it's not work
I begin to think to instal apache2 also and give it a try
Denis
viewtopic.php?f=6&t=15055
I installed nginx with php support and if I use a php page outside of domoticz it's work
If I make a phpinfo page in the www folder of domoticz it's not work
I begin to think to instal apache2 also and give it a try
Denis
-
- Posts: 58
- Joined: Saturday 17 December 2016 13:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: LUA Pass2php
Egregius do you use the apache via reverse proxy or you use it without webserver inside domoticz ?
I mean you use apache2 by root dir in www folder of domoticz ?
Thanks again
Denis
I mean you use apache2 by root dir in www folder of domoticz ?
Thanks again
Denis
Who is online
Users browsing this forum: Bing [Bot] and 0 guests