Pass2PHP
Moderator: leecollings
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Can you check settings > more > events > show current states?
- 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
Oh nooo.Egregius wrote:Can you check settings > more > events > show current states?
Code: Select all
222 Woonkamer Off 2016-12-17 00:29:25
223 Keuken Off 2016-12-17 00:17:18
224 Slaapkamer Off 2016-12-17 00:17:17
225 Studeerkamer On 2016-12-17 00:29:53

Code: Select all
if(pingDomain('192.168.2.11',9090)==1)
{
lg('Kodi Media Center Slaapkamer ON');
}
else
{
lg('Kodi Media Center Slaapkamer OFF');
}
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: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
If those devices are created by the Kodi hardware plugin you can report it in the bugs forum.
If they're are custom devices with a own script you'll have to fix it yourself.
But, why do you want to log if the Kodi is on or off?
If the purpose is to kill the power after the Kodi has shutdown you can use this:
Oh yess, I changed the pingdomain function
Another thing I like about PHP is that it doesn't care mcuh for spaces or linebreaks. If you like compact code you can remove them (almost) all:
Thanks to that change I could replace 94 lines of code by just this:
If they're are custom devices with a own script you'll have to fix it yourself.
But, why do you want to log if the Kodi is on or off?
If the purpose is to kill the power after the Kodi has shutdown you can use this:
Code: Select all
if($s['kodi']=='On'&&strtotime($t['kodi'])<time-298){
if(pingport('192.168.2.7',1597)==1){
$prevcheck=cget('check192.168.2.57:1597');
if($prevcheck>0)cset('check192.168.2.57:1597',0);
}else{
$check=cget('check192.168.2.57:1597')+1;
if($check>0)cset('check192.168.2.57:1597',$check);
if($check>=5)sw($i['kodi'],'Off','kodi');
}
}

Code: Select all
function checkport($ip,$port){
if(pingport($ip,$port)==1){
$prevcheck=cget('check'.$ip.':'.$port);
if($prevcheck>=3)telegram($ip.':'.$port.' online',true);
if($prevcheck>0)cset('check'.$ip.':'.$port,0);
}else{
$check=cget('check'.$ip.':'.$port)+1;
if($check>0)cset('check'.$ip.':'.$port,$check);
if($check==3)telegram($ip.':'.$port.' Offline',true);
if($check%100==0)telegram($ip.':'.$port.' still Offline',true);
}
}
function pingport($ip,$port){
$file=fsockopen($ip,$port,$errno,$errstr,10);
$status=0;
if(!$file)$status=-1;
else{
fclose($file);
$status=1;
}
return $status;
}
Code: Select all
function checkport($ip,$port){if(pingport($ip,$port)==1){$prevcheck=cget('check'.$ip.':'.$port);if($prevcheck>=3)telegram($ip.':'.$port.' online',true);if($prevcheck>0)cset('check'.$ip.':'.$port,0);}else{$check=cget('check'.$ip.':'.$port)+1;if($check>0)cset('check'.$ip.':'.$port,$check);if($check==3)telegram($ip.':'.$port.' Offline',true);if($check%100==0)telegram($ip.':'.$port.' nog steeds Offline',true);}}
function pingport($ip,$port){$file=fsockopen($ip,$port,$errno,$errstr,10);$status=0;if(!$file)$status=-1;else{fclose($file);$status=1;}return $status;}
Code: Select all
checkport('192.168.2.11',80);checkport('192.168.2.12',80);checkport('192.168.2.13',80);checkport('192.168.2.2',53);checkport('192.168.2.2',80);
- 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
ah more home work for me to investigate into.
I want it to convert to your doorbell php.
idea is.. when the doorbell is pressed. Only send the "start IP Camera plugin" to the KODI machines that are actually running.
No need to send a request to a machine that is not running

The came from a .sh script that is currently being called when the doorbell is pressed.If those devices are created by the Kodi hardware plugin you can report it in the bugs forum.
If they're are custom devices with a own script you'll have to fix it yourself.
But, why do you want to log if the Kodi is on or off?
I want it to convert to your doorbell php.
idea is.. when the doorbell is pressed. Only send the "start IP Camera plugin" to the KODI machines that are actually running.
No need to send a request to a machine that is not running

These are indeed KODI created devices. Let me first update to the latest BETA, maybe somebody already fixed it in between.If those devices are created by the Kodi hardware plugin you can report it in the bugs forum.
If they're are custom devices with a own script you'll have to fix it yourself.

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: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
There's a door ell example on my site with a curl, just change the url.
I do use 2 devices, one for the doorbell button, and one for the doorbell self. That way I can decide weither or not the sound must go on.
I do use 2 devices, one for the doorbell button, and one for the doorbell self. That way I can decide weither or not the sound must go on.
- 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
A yes that doorbell example I was modifyingEgregius wrote:There's a door ell example on my site with a curl, just change the url.
I do use 2 devices, one for the doorbell button, and one for the doorbell self. That way I can decide weither or not the sound must go on.

Just updated domoticz to v3.6179
Code: Select all
223 Keuken On 2016-12-17 10:48:50
224 Slaapkamer Off 2016-12-17 00:36:52
225 Studeerkamer Video 2016-12-17 10:54:38 The Big Bang Theory [S1E2] - The Big Bra


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
I took the liberty to modify the sms function to my own provider.
Slightly better coverage with my ported number
https://register.cmtelecom.com/en
Slightly better coverage with my ported number

https://register.cmtelecom.com/en
Code: Select all
function sms($msg)
{
{
$producttoken='XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
$to="003112345678";
$from="Domotica"; // Max 11 alfanumeric characters
curl('https://sgw01.cm.nl/gateway.ashx?producttoken='.$producttoken.'&body='.urlencode($msg).'&to='.$to.'&from='.$from);
usleep(500000);
}
}
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: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Nice, you're one a good way 
You're free to change/add anything you like. I just share my stuff because I'm convinced it's a great way of handling Domoticz and so others can benefit from it.

You're free to change/add anything you like. I just share my stuff because I'm convinced it's a great way of handling Domoticz and so others can benefit from it.
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Busy with pass2PHP 3.0 
Plan is to create a file for each device that needs to do something, instead of creating the functions.
That way it will be easier to keep a settings and functions file so it will be more shareable and updateable.

Plan is to create a file for each device that needs to do something, instead of creating the functions.
That way it will be easier to keep a settings and functions file so it will be more shareable and updateable.
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
New code is available at a new Github repository https://github.com/Egregius/LUA-Pass2PHP-for-Domoticz
Only the files for pass2php and no clutter from my floorplan and other stuff.
Only the files for pass2php and no clutter from my floorplan and other stuff.
- 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
Needed to modify the first bit, with your old trick, to have it working with my sensors that have spaces in the name.Egregius wrote:New code is available at a new Github repository https://github.com/Egregius/LUA-Pass2PHP-for-Domoticz
Only the files for pass2php and no clutter from my floorplan and other stuff.

Code: Select all
<your $c,$s,$i code here>
$r=str_replace(" ","_",key($c));
$c2=key($c);
if(file_exists('pass2php/'.key($c).'.php')) include 'pass2php/'.key($c).'.php';
elseif(file_exists('pass2php/'.($r).'.php')) include 'pass2php/'.($r).'.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.
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Yes, you can add that. I never use spaces in computer related stuff.
Easier this way? With seperate file for each device?
You don't need to use function and global stuff anymore.
There's almost no difference in speed, maybe a small millisecond faster. But I guess better memory friendly as you only load what is nescessary instead of everything.
You could also consider activating opcache. Then the parsed php code is stored in memory and not read from disk.
Easier this way? With seperate file for each device?
You don't need to use function and global stuff anymore.
There's almost no difference in speed, maybe a small millisecond faster. But I guess better memory friendly as you only load what is nescessary instead of everything.
You could also consider activating opcache. Then the parsed php code is stored in memory and not read from disk.
- 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
Easier: Yes, everything just in a separate file, no more scrolling and searching. Your functions are even more compact as I use multiple lines. To keep a bit of a NOOB overview.Egregius wrote:Yes, you can add that. I never use spaces in computer related stuff.
Easier this way? With seperate file for each device?
You don't need to use function and global stuff anymore.
There's almost no difference in speed, maybe a small millisecond faster. But I guess better memory friendly as you only load what is nescessary instead of everything.
You could also consider activating opcache. Then the parsed php code is stored in memory and not read from disk.
Global: Okay.. mmm have to look into that one again, Did not work first time. Did see it indeed in your php files indeed. I just copied my whole function to a new file (including the global things) and the system came back to life.
Speed: A yes I do have 0.5 sec faster light in my room that has a door 433 mhz door&motion sensor + 433 mhz kaku light switch, controlled by Domoticz via pass2php now. Before splitting it into separate files the advantage was not noticable.
opache: Well last week I did not even know what php could do for me and what memcached was

A well must say learned a lot from your examples. Thank you very much. Looking forward to pass2php3.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: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
There are multiple ways of defining variables in PHP.
'normal way': simple, just say $var='test'; but you need to 'import' it when needed inside a function with global $var;
using global: variable can be used just by its name, without a $ sign and doesn't need to be 'imported' in the function.
PHP Doesn't care much about spaces and newlines etc.
These 3 functions work exactly the same. One compact, one fully opened, one in between. You can use it just like you like it.
Before, when everything was in one file I liked the most compact way because I otherwise had to scroll thru 1500 lines of code.
Now with all the seperate files I guess I will open them up as they are mostly just some lines.
That 0,5 sec is that between lua/blockly and pass2php or between pass2php 2.0 and 3.0?
Unless I find a way to avoid the base64 en json encode in the lua script I don't think there will be big updates in the near future. Everything I need is in it (for now, you never now...). Of course you can add anything you like, I'll be more than happy to help if needed.
Opcache: see how fast it can go. Only been running for 5 hours today. On my webserver I'm hitting 20 million hits/week!

'normal way': simple, just say $var='test'; but you need to 'import' it when needed inside a function with global $var;
Code: Select all
$domoticz='http://127.0.0.1:8084/';
function sl($idx,$level,$info=''){
global $domoticz; //Without this $domoticz is unknon
lg('SETLEVEL '.$level.' '.$info);
curl($domoticz.'json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd=Set%20Level&level='.$level);
}
Code: Select all
define('domoticz','http://127.0.0.1:8084/');
function sl($idx,$level,$info=''){
lg('SETLEVEL '.$level.' '.$info);
curl(domoticz.'json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd=Set%20Level&level='.$level);
}
These 3 functions work exactly the same. One compact, one fully opened, one in between. You can use it just like you like it.
Before, when everything was in one file I liked the most compact way because I otherwise had to scroll thru 1500 lines of code.
Now with all the seperate files I guess I will open them up as they are mostly just some lines.
Code: Select all
function sl($idx,$level,$info=''){lg('SETLEVEL '.$level.' '.$info);curl(domoticz.'json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd=Set%20Level&level='.$level);}
function sl($idx,$level,$info=''){
lg('SETLEVEL '.$level.' '.$info);
curl(domoticz.'json.htm?type=command¶m=switchlight&idx='.$idx.'&switchcmd=Set%20Level&level='.$level);
}
function sl( $idx, $level, $info = '' )
{
lg( 'SETLEVEL ' . $level . ' ' . $info );
curl ( domoticz . ' json.htm?type=command¶m=switchlight&idx=' . $idx . '&switchcmd=Set%20Level&level=' . $level );
}
Unless I find a way to avoid the base64 en json encode in the lua script I don't think there will be big updates in the near future. Everything I need is in it (for now, you never now...). Of course you can add anything you like, I'll be more than happy to help if needed.
Opcache: see how fast it can go. Only been running for 5 hours today. On my webserver I'm hitting 20 million hits/week!

- 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
All running from your synology 213??Egregius wrote:There are multiple ways of defining variables in PHP.
That 0,5 sec is that between lua/blockly and pass2php or between pass2php 2.0 and 3.0?
Opcache: see how fast it can go. Only been running for 5 hours today. On my webserver I'm hitting 20 million hits/week!

Well
LUA/BASH/PYTHON/PERL os.execute vs Pass2PHP saves me at least 5 SECONDS per action.
Pass2Php2.0 vs Pass2Php3.0 saves me 0,5 seconds when switching the lights (door open/closed) on 433 mhz devices.
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: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: LUA Pass2php
Nonono, Syno is just for private stuff. Webserver is at a VPS of course.
Wow, incredible numbers!
I don't see the difference between 2.0 and 3.0. Response time was 9/10 42msec and 1/10 43msec. Now with v3.0 it's 9/10 42msec and 1/10 41msec.
But hey, good for you. Half a seconds is noticable. Guess that I'm hitting the limits of my setup now.
Did find something else today... While looking at the opcache/memcached I noticed that I could easily use apcu cache also on my Syno.
Of course I quickly did some tests and it seems that apcu is approx 100 times faster than memcached.
Wow, incredible numbers!
I don't see the difference between 2.0 and 3.0. Response time was 9/10 42msec and 1/10 43msec. Now with v3.0 it's 9/10 42msec and 1/10 41msec.
But hey, good for you. Half a seconds is noticable. Guess that I'm hitting the limits of my setup now.
Did find something else today... While looking at the opcache/memcached I noticed that I could easily use apcu cache also on my Syno.
Of course I quickly did some tests and it seems that apcu is approx 100 times faster than memcached.
Code: Select all
define('cache','apcu');//apcu apc memcached
function cset($key,$value){
if(cache=='apcu'){
apcu_store($key,$value);
}elseif(cache=='apc'){
apc_store($key,$value);
}elseif(cache=='memcached'){
if(!$m=xsMemcached::Connect('127.0.0.1',11211)){return;}$m->Set($key,$value);
}
}
function cget($key){
if(cache=='apcu'){
return apcu_fetch($key);
}elseif(cache=='apc'){
return apc_fetch($key);
}elseif(cache=='memcached'){
if(!$m=xsMemcached::Connect('127.0.0.1',11211)){return 0;}return $m->Get($key);
}
}
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: LUA Pass2php
Details pleasesincze wrote: LUA/BASH/PYTHON/PERL os.execute vs Pass2PHP saves me at least 5 SECONDS per action.
Pass2Php2.0 vs Pass2Php3.0 saves me 0,5 seconds when switching the lights (door open/closed) on 433 mhz devices.

I think the common results discussed in a few different threads here with Raspberry (2/3) are that if one uses LUA (action in commandArray) to act on device change the delay for triggering the action is up to a full second but if you call the json api from the LUA script (with curl) the delay is less that 50ms. In essence, this what pass2php is also doing, reacting to device changed event (from Domoticz / LUA) and then calling the json api. Not saying it couldn't be a bit faster in any case with pass2php but difference should be very very small. Now that you mention you are seeing results of 5 seconds improvement and even half a second with different type of pass2php implementation it leaves me wondering if something is very off with your setup

But then again, might as well be that I've misunderstood something...

- 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
A detailsNautilus wrote:Details pleasesincze wrote: LUA/BASH/PYTHON/PERL os.execute vs Pass2PHP saves me at least 5 SECONDS per action.
Pass2Php2.0 vs Pass2Php3.0 saves me 0,5 seconds when switching the lights (door open/closed) on 433 mhz devices.What took 5 seconds longer earlier? The reaction time to "device change" in Domoticz or the full time to run the script (LUA/BASH/PYTHON etc.)? This sounds pretty strange if it was just the device change. If the whole script, then I guess you found a way to incorporate everything to the php script. Or is this platform (Synology) issue?
I think the common results discussed in a few different threads here with Raspberry (2/3) are that if one uses LUA (action in commandArray) to act on device change the delay for triggering the action is up to a full second but if you call the json api from the LUA script (with curl) the delay is less that 50ms. In essence, this what pass2php is also doing, reacting to device changed event (from Domoticz / LUA) and then calling the json api. Not saying it couldn't be a bit faster in any case with pass2php but difference should be very very small. Now that you mention you are seeing results of 5 seconds improvement and even half a second with different type of pass2php implementation it leaves me wondering if something is very off with your setup
But then again, might as well be that I've misunderstood something...

Well. First of all let me say I am very happy with Domoticz.
And pretty much implemented a lot of hardware/services as described on the forum.
One of the biggest issues is range on 433 mhz. Solved that with separate RFLINK as the budget did not allow second rfxcom.
The Primary RFXCom was already equiped with 10db gain antenna.
Now for the speed updates.
If somebody rings the doorbell or opens the mailbox I receive telegram notifications + images.
For the doorbell If I am at home in addition to telegram notifcations + images domoticz would send the video feed to KODI
(domoticz starts kodi plugin basically.)
Starting the Kodi feed and sending the telegram notifications (+ images) was done via a lua script that checked which kodi machines were on and executed a separate BASH file to grab images
2 things basically.
- Grab images from 2 cameras and send via Telegram
- Kick the addon in all kodi machines that are switched on to start showing the video feed.
Honestly before I had to wait 5 seconds for a video feed turned up on my TV within KODI. (not ideal WAF).
Now... I receive the feed AND the telegram messages at the same time using the pass2php solution. (WAF approved)
The domoticz log would always mention... script has been running for over 10 seconds... now those days are over.
Second thing I noticed now if I open a door a specific door the light switches on 0,5 seconds faster.
Nothing lua can do about that devicechanged["Door"]=Open. Pretty straight forward code, hower I dit notice it.
For the rest no additional speed up changes noticed.
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.
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: LUA Pass2php
Ok, this makes a bit more sense now
The door opening and light switching on -> as expected if you were using LUA and passing the switch on command through the commandArray and not json. Still I think it is a bit strange that it took 5+ seconds before to execute everything and now instant but hey - all the better! 
I'm using similar setup but without Kodi so when doorbell rings it puts correct input (RPi) to receiver, turns TV on if off and sends a Telegram message with image. The only real delay there is, is that my 433Mhz signals pass through Telldus Net's Live service (1-2sec) and if TV is off it takes a few seconds for the image to come up (even if it is on, the RPi loads the page that is showing the camera images for a second or so). But Telegram messages arrive as soon as the device changes in Domoticz and also the AV equipment start doing what they need to do right away so there is no delay there. Therefore I doubt I could make it noticeably faster with the help of php or anything else - a bit maybe. I've now ordered a RFLink and hope to be able to react to and execute a lot faster all 433Mzh stuff (and also better integrate MiLights)


I'm using similar setup but without Kodi so when doorbell rings it puts correct input (RPi) to receiver, turns TV on if off and sends a Telegram message with image. The only real delay there is, is that my 433Mhz signals pass through Telldus Net's Live service (1-2sec) and if TV is off it takes a few seconds for the image to come up (even if it is on, the RPi loads the page that is showing the camera images for a second or so). But Telegram messages arrive as soon as the device changes in Domoticz and also the AV equipment start doing what they need to do right away so there is no delay there. Therefore I doubt I could make it noticeably faster with the help of php or anything else - a bit maybe. I've now ordered a RFLink and hope to be able to react to and execute a lot faster all 433Mzh stuff (and also better integrate MiLights)

- 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
Hang on to your seat. Milight will be as fast as blink of an eye. 
Triggered by 433mhz motion sensor.
I can post the bash script for review

Triggered by 433mhz motion sensor.
I can post the bash script for review

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