Pass2PHP

Moderator: leecollings

User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

What timings did you use to have with lua or blockly?

Do you have opcache installed and enabled? That could give a huge speed improvement for PHP.

On my system there's a difference of 56%:

Code: Select all

//With opcache
2020-10-13 05:01:55.776 (ZWAVE) Light/Switch (pirkeuken)
2020-10-13 05:01:55.791 Status: User: Admin initiated a switch command (11/keuken/On)
2020-10-13 05:01:55.792 OpenZWave: Domoticz has send a Switch command! NodeID: 4 (0x04)
2020-10-13 05:01:55.792 (ZWAVE) Light/Switch (keuken)

Code: Select all

//Without opcache
2020-10-13 04:58:45.219 (ZWAVE) Light/Switch (pirkeuken)
2020-10-13 04:58:45.243 Status: User: Admin initiated a switch command (11/keuken/On)
2020-10-13 04:58:45.243 OpenZWave: Domoticz has send a Switch command! NodeID: 4 (0x04)
2020-10-13 04:58:45.244 (ZWAVE) Light/Switch (keuken)
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

Hi!

call the secure/opcache.php answer:

Code: Select all

Hits: 99% 47.212 hits / 537 misses
HitsMissesMemory: 9 MB of 128 MB
Wasted memoryUsed memoryFree memoryKeys: 18 of 16229
Used keysFree keys
Scripts (11) 
Options	Hits	Memory	Path
Invalidate	13894	4 kB	/config.php
Invalidate	13893	172 kB	/functions.php
Invalidate	10467	4 kB	/pass2php.php
Invalidate	3426	7 kB	/cron.php
Invalidate	2619	40 kB	/_TC_neutral.php
Invalidate	2619	680 bytes	/_cron10.php
Invalidate	271	4 kB	/_cron120.php
Invalidate	9	39 kB	/_cron3600.php
Invalidate	8	1 kB	/pass2php/E-I-Kapcsolo-Jobb.php
Invalidate	5	1 kB	/pass2php/E-I-Mozgas2-Home Security.php
Invalidate	2	18 kB	/opcache.php
Status
opcache_enabled	true	
cache_full	false	
restart_pending	false	
restart_in_progress	false	
used_memory	9 MB	
free_memory	119 MB	
wasted_memory	0 bytes	
current_wasted_percentage	0.00%	
buffer_size	6291032	
used_memory	337 kB	
free_memory	6 MB	
number_of_strings	7196	
num_cached_scripts	11	
num_cached_keys	18	
max_cached_keys	16229	
hits	47212	
start_time	1602540000	
last_restart_time	0	
oom_restarts	0	
hash_restarts	0	
manual_restarts	0	
misses	537	
blacklist_misses	0	
blacklist_miss_ratio	0.00	
opcache_hit_rate	98.88%	
Configuration
opcache.enable	true	
opcache.enable_cli	false	
opcache.use_cwd	true	
opcache.validate_timestamps	true	 If you are in a production environment you should disabled it
opcache.validate_permission	false	
opcache.validate_root	false	
opcache.dups_fix	false	
opcache.revalidate_path	false	
opcache.log_verbosity_level	1	
opcache.memory_consumption	128 MB	
opcache.interned_strings_buffer	8	
opcache.max_accelerated_files	10000	
opcache.max_wasted_percentage	0.05	
opcache.consistency_checks	0	
opcache.force_restart_timeout	180	
opcache.revalidate_freq	2	
opcache.preferred_memory_model		
opcache.blacklist_filename		
opcache.max_file_size	0	
opcache.error_log		
opcache.protect_memory	false	
opcache.save_comments	true	
opcache.enable_file_override	false	
opcache.optimization_level	2147401727	
opcache.lockfile_path	/tmp	
opcache.file_cache		
opcache.file_cache_only	false	
opcache.file_cache_consistency_checks	true	
opcache.file_update_protection	2	
opcache.opt_debug_level	0	
opcache.restrict_api		
opcache.huge_code_pages	false	
call the secure/phpinfo.php answer:
Spoiler: show

Code: Select all

Zend OPcache
Opcode Caching	Up and Running
Optimization	Enabled
SHM Cache	Enabled
File Cache	Disabled
Startup	OK
Shared memory model	mmap
Cache hits	47446
Cache misses	540
Used memory	9470448
Free memory	124747280
Wasted memory	0
Interned Strings Used memory	345192
Interned Strings Free memory	5945840
Cached scripts	13
Cached keys	20
Max keys	16229
OOM restarts	0
Hash keys restarts	0
Manual restarts	0
Directive	Local Value	Master Value
opcache.blacklist_filename	no value	no value
opcache.consistency_checks	0	0
opcache.dups_fix	Off	Off
opcache.enable	On	On
opcache.enable_cli	Off	Off
opcache.enable_file_override	Off	Off
opcache.error_log	no value	no value
opcache.file_cache	no value	no value
opcache.file_cache_consistency_checks	On	On
opcache.file_cache_only	Off	Off
opcache.file_update_protection	2	2
opcache.force_restart_timeout	180	180
opcache.huge_code_pages	Off	Off
opcache.interned_strings_buffer	8	8
opcache.lockfile_path	/tmp	/tmp
opcache.log_verbosity_level	1	1
opcache.max_accelerated_files	10000	10000
opcache.max_file_size	0	0
opcache.max_wasted_percentage	5	5
opcache.memory_consumption	128	128
opcache.opt_debug_level	0	0
opcache.optimization_level	0x7FFEBFFF	0x7FFEBFFF
opcache.preferred_memory_model	no value	no value
opcache.protect_memory	Off	Off
opcache.restrict_api	no value	no value
opcache.revalidate_freq	2	2
opcache.revalidate_path	Off	Off
opcache.save_comments	On	On
opcache.use_cwd	On	On
opcache.validate_permission	Off	Off
opcache.validate_root	Off	Off
opcache.validate_timestamps	On	On

With disabled Opcache in apach2/php.ini after php restart:

Code: Select all

[opcache]                                                                                                                                                                    
; Determines if Zend OPCache is enabled                                                                                                                                      
opcache.enable=0   
Spoiler: show

Code: Select all

2020-10-13 09:29:45.875 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 09:29:45.883 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 09:29:45.901 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 09:29:45.918 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 09:29:45.873 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-13 09:29:45.878 Status: LUA: Start of script device
2020-10-13 09:29:45.878 Status: LUA: End of script device
2020-10-13 09:29:45.883 Status: LUA: Curl ended
2020-10-13 09:29:45.887 Status: LUA: Start of script device
2020-10-13 09:29:45.887 Status: LUA: End of script device
2020-10-13 09:29:45.892 Status: LUA: Curl ended
2020-10-13 09:29:45.898 Status: LUA: Start of script device
2020-10-13 09:29:45.898 Status: LUA: End of script device
2020-10-13 09:29:45.903 Status: LUA: Curl ended
2020-10-13 09:29:45.921 Status: LUA: Start of script device
2020-10-13 09:29:45.921 Status: LUA: End of script device
2020-10-13 09:29:45.926 Status: LUA: Curl ended
2020-10-13 09:29:45.966 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-13 09:29:46.027 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 09:29:46.030 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 09:29:46.021 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-13 09:29:46.021 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-13 09:29:46.022 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-13 09:29:46.022 Status: => E-I-Mozgas2-Home Security = On
2020-10-13 09:29:46.025 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-13 09:29:46.026 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-13 09:29:46.033 Status: LUA: Start of script device
2020-10-13 09:29:46.033 Status: LUA: End of script device
2020-10-13 09:29:46.038 Status: LUA: Curl ended
2020-10-13 09:29:46.125 Status: => (STORE) => E-I-Kapcsolo-Jobb => On (Pass2PHP)
1. step: 2020-10-13 09:29:45.901 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2. step: 2020-10-13 09:29:45.898 Status: LUA: Start of script device
2020-10-13 09:29:45.898 Status: LUA: End of script device
2020-10-13 09:29:45.903 Status: LUA: Curl ended
3. step 2020-10-13 09:29:46.027 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1-> 3 : 126ms

With enabled Opcache in apach2/php.ini after php restart: ( it was turned on before)

Code: Select all

[opcache]                                                                                                                                                                    
; Determines if Zend OPCache is enabled                                                                                                                                      
opcache.enable=1   
firs run ( without /pass2php/E-I-Mozgas2-Home Security.php hit)
Spoiler: show

Code: Select all

2020-10-13 09:40:37.572 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 09:40:37.580 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 09:40:37.599 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 09:40:37.608 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 09:40:37.741 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 09:40:37.743 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 09:40:37.570 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-13 09:40:37.575 Status: LUA: Start of script device
2020-10-13 09:40:37.575 Status: LUA: End of script device
2020-10-13 09:40:37.581 Status: LUA: Curl ended
2020-10-13 09:40:37.585 Status: LUA: Start of script device
2020-10-13 09:40:37.585 Status: LUA: End of script device
2020-10-13 09:40:37.603 Status: LUA: Curl ended
2020-10-13 09:40:37.608 Status: LUA: Start of script device
2020-10-13 09:40:37.608 Status: LUA: End of script device
2020-10-13 09:40:37.613 Status: LUA: Curl ended
2020-10-13 09:40:37.617 Status: LUA: Start of script device
2020-10-13 09:40:37.617 Status: LUA: End of script device
2020-10-13 09:40:37.622 Status: LUA: Curl ended
2020-10-13 09:40:37.673 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-13 09:40:37.736 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-13 09:40:37.736 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-13 09:40:37.737 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-13 09:40:37.738 Status: => E-I-Mozgas2-Home Security = On
2020-10-13 09:40:37.739 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-13 09:40:37.740 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-13 09:40:37.746 Status: LUA: Start of script device
2020-10-13 09:40:37.746 Status: LUA: End of script device
2020-10-13 09:40:37.751 Status: LUA: Curl ended
2020-10-13 09:40:37.843 Status: => (STORE) => E-I-Kapcsolo-Jobb => On (Pass2PHP)

1 step: 2020-10-13 09:40:37.599 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 09:40:37.608 Status: LUA: Start of script device
2020-10-13 09:40:37.608 Status: LUA: End of script device
2020-10-13 09:40:37.613 Status: LUA: Curl ended
3 step: 2020-10-13 09:40:37.741 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1->3 : 142 ms

second run ( with /pass2php/E-I-Mozgas2-Home Security.php hit)
Spoiler: show

Code: Select all

2020-10-13 09:46:40.605 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 09:46:40.613 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 09:46:40.625 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 09:46:40.633 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 09:46:40.794 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 09:46:40.796 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 09:46:40.603 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-13 09:46:40.611 Status: LUA: Start of script device
2020-10-13 09:46:40.611 Status: LUA: End of script device
2020-10-13 09:46:40.616 Status: LUA: Curl ended
2020-10-13 09:46:40.621 Status: LUA: Start of script device
2020-10-13 09:46:40.621 Status: LUA: End of script device
2020-10-13 09:46:40.626 Status: LUA: Curl ended
2020-10-13 09:46:40.631 Status: LUA: Start of script device
2020-10-13 09:46:40.631 Status: LUA: End of script device
2020-10-13 09:46:40.644 Status: LUA: Curl ended
2020-10-13 09:46:40.649 Status: LUA: Start of script device
2020-10-13 09:46:40.649 Status: LUA: End of script device
2020-10-13 09:46:40.654 Status: LUA: Curl ended
2020-10-13 09:46:40.719 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-13 09:46:40.789 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-13 09:46:40.790 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-13 09:46:40.790 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-13 09:46:40.791 Status: => E-I-Mozgas2-Home Security = On
2020-10-13 09:46:40.792 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-13 09:46:40.793 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-13 09:46:40.799 Status: LUA: Start of script device
2020-10-13 09:46:40.800 Status: LUA: End of script device
2020-10-13 09:46:40.809 Status: LUA: Curl ended
2020-10-13 09:46:40.909 Status: => (STORE) => E-I-Kapcsolo-Jobb => On (Pass2PHP)
1 step: 2020-10-13 09:46:40.625 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 09:46:40.631 Status: LUA: Start of script device
2020-10-13 09:46:40.631 Status: LUA: End of script device
2020-10-13 09:46:40.644 Status: LUA: Curl ended
3 step: 2020-10-13 09:46:40.794 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1-> 3 : 169 ms

This is my opcache configuration:
Spoiler: show

Code: Select all

opcache.enable_cli	false	
opcache.use_cwd	true	
opcache.validate_timestamps	true	 If you are in a production environment you should disabled it
opcache.validate_permission	false	
opcache.validate_root	false	
opcache.dups_fix	false	
opcache.revalidate_path	false	
opcache.log_verbosity_level	1	
opcache.memory_consumption	128 MB	
opcache.interned_strings_buffer	8	
opcache.max_accelerated_files	10000	
opcache.max_wasted_percentage	0.05	
opcache.consistency_checks	0	
opcache.force_restart_timeout	180	
opcache.revalidate_freq	2	
opcache.preferred_memory_model		
opcache.blacklist_filename		
opcache.max_file_size	0	
opcache.error_log		
opcache.protect_memory	false	
opcache.save_comments	true	
opcache.enable_file_override	false	
opcache.optimization_level	2147401727	
opcache.lockfile_path	/tmp	
opcache.file_cache		
opcache.file_cache_only	false	
opcache.file_cache_consistency_checks	true	
opcache.file_update_protection	2	
opcache.opt_debug_level	0	
opcache.restrict_api		
opcache.huge_code_pages	false	
Can you send yours to compare?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

So strange that it's slower with opcache enabled. Almost unbelievable.
I didn't change much in the opcache config:

Code: Select all

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=40
opcache.validate_timestamps=0 //Change this to 1 when changing files, otherwise you need to flush the cache each time you change a php file.
I do have this in my apache virtual host file:

Code: Select all

<FilesMatch \.php$>
	SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

I took some measurements :)

With the proxmox configuration I managed to achieve a response time of 10 ms, but only with one LUA file.

With only 1 blockly (nothing else):
measurement 1:
Spoiler: show

Code: Select all

2020-10-13 13:35:54.579 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:35:54.583 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 13:35:54.587 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 13:35:54.611 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 13:35:54.614 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 13:35:54.625 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:35:54.954 (AEON) Current (E-GY-Klima-Aram)
2020-10-13 13:35:54.578 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
1 step: 2020-10-13 13:35:54.587 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 13:35:54.611 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a

1->2: 24 ms



measurement 2:
Spoiler: show

Code: Select all

2020-10-13 13:39:47.094 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:39:47.098 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 13:39:47.102 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 13:39:47.111 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:39:47.128 (AEON) Lux (E-I-Mozgas2-Illuminance)
2020-10-13 13:39:47.131 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 13:39:47.134 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 13:39:47.093 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
1 step: 2020-10-13 13:39:47.102 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 13:39:47.131 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1->2: 29 ms


with enabled dzvents ( delete blockly)

Code: Select all

 return {
   on = {
      devices = {         'E-I-Mozgas2-Home Security'      }   },
   execute = function(domoticz, switch)
      if (switch.state == 'On') then
         domoticz.devices('E-I-Kapcsolo-Jobb').switchOn()
     
      end
    end
}
measurement 1:
Spoiler: show

Code: Select all

2020-10-13 13:53:53.336 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:53:53.345 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 13:53:53.352 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 13:53:53.358 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:53:53.502 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 13:53:53.505 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 13:53:53.333 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
1 step: 2020-10-13 13:53:53.352 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 13:53:53.502 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1->2 150 ms

measurement 2:
Spoiler: show

Code: Select all

2020-10-13 13:55:18.403 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:55:18.411 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 13:55:18.418 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 13:55:18.424 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 13:55:18.563 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 13:55:18.567 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 13:55:18.400 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
1 step: 2020-10-13 13:55:18.418 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 13:55:18.563 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1→ 2 : 145 ms


With pass2php with ocache enabled ( delteted all blockly and dzVents script, disabled dzVents)

with this pass2php lua script:

Code: Select all

print("Start of script device");                                                                                                                                             
for d,s in pairs(devicechanged)                                                                                                                                              
do                                                                                                                                                                           
print("End of script device");                                                                                                                                               
os.execute('curl -X POST -d "d='..d.."&s="..s..'" http://127.0.0.1/secure/pass2php.php &')                                                                                   
end                                                                                                                                                                          
print("Curl ended");                                                                                                                                                         
commandArray={}   



Spoiler: show

Code: Select all

2020-10-13 14:02:57.158 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 14:02:57.166 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 14:02:57.174 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 14:02:57.185 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 14:02:57.269 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 14:02:57.271 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 14:02:57.157 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-13 14:02:57.162 Status: LUA: Start of script device
2020-10-13 14:02:57.162 Status: LUA: End of script device
2020-10-13 14:02:57.167 Status: LUA: Curl ended
2020-10-13 14:02:57.171 Status: LUA: Start of script device
2020-10-13 14:02:57.171 Status: LUA: End of script device
2020-10-13 14:02:57.176 Status: LUA: Curl ended
2020-10-13 14:02:57.180 Status: LUA: Start of script device
2020-10-13 14:02:57.180 Status: LUA: End of script device
2020-10-13 14:02:57.185 Status: LUA: Curl ended
2020-10-13 14:02:57.192 Status: LUA: Start of script device
2020-10-13 14:02:57.192 Status: LUA: End of script device
2020-10-13 14:02:57.197 Status: LUA: Curl ended
2020-10-13 14:02:57.228 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-13 14:02:57.266 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-13 14:02:57.266 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-13 14:02:57.266 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-13 14:02:57.267 Status: => E-I-Mozgas2-Home Security = On
2020-10-13 14:02:57.268 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-13 14:02:57.269 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-13 14:02:57.275 Status: LUA: Start of script device
2020-10-13 14:02:57.275 Status: LUA: End of script device
2020-10-13 14:02:57.280 Status: LUA: Curl ended

1 step: 2020-10-13 14:02:57.174 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 14:02:57.180 Status: LUA: Start of script device
2020-10-13 14:02:57.180 Status: LUA: End of script device
2020-10-13 14:02:57.185 Status: LUA: Curl ended
3 step: 2020-10-13 14:02:57.269 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1->3 : 95 ms


with this pass2php lua script:

Code: Select all

for d,s in pairs(devicechanged)                                                                                                                                              
do                                                                                                                                                                           
                                                                                                                           
os.execute('curl -X POST -d "d='..d.."&s="..s..'" http://127.0.0.1/secure/pass2php.php &')                                                                                   
end                                                                                                                                                            
                                                                                                                                              
commandArray={}   
   

Spoiler: show

Code: Select all

2020-10-13 14:09:05.449 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 14:09:05.457 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 14:09:05.474 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 14:09:05.489 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 14:09:05.495 (AEON) Lux (E-I-Mozgas2-Illuminance)
2020-10-13 14:09:05.601 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 14:09:05.609 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 14:09:05.448 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-13 14:09:05.540 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-13 14:09:05.595 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-13 14:09:05.595 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-13 14:09:05.596 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-13 14:09:05.596 Status: => (STORE) => E-I-Mozgas2-Illuminance => 0 (Pass2PHP)
2020-10-13 14:09:05.598 Status: => E-I-Mozgas2-Home Security = On
2020-10-13 14:09:05.599 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-13 14:09:05.601 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-13 14:09:05.695 Status: => (STORE) => E-I-Kapcsolo-Jobb => On (Pass2PHP)


1 step: 2020-10-13 14:09:05.474 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 14:09:05.601 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
1->2 : 127 ms



With only one Lua script:

Code: Select all

commandArray = {}                                                                                                                                                                                                                           
for devName,devValue in pairs(devicechanged) do                                                                                                                                                                                             
    if (devName=='E-I-Mozgas2-Home Security'and devValue=='On') then                                                                                                                                                                        
                commandArray['E-I-Kapcsolo-Jobb']='On'                                                                                                                                                                                      
    end                                                                                                                                                                                                                                     
end                                                                                                                                                                                                                                         
return commandArray   
Spoiler: show

Code: Select all

2020-10-13 14:37:00.839 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 14:37:00.843 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 14:37:00.848 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 14:37:00.856 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 14:37:00.858 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 14:37:00.863 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 14:37:00.837 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)


1 step: 2020-10-13 14:37:00.848 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 14:37:00.858 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
1->2 : 10 ms !! Wow

On Asrock Q1900DC IT board, on proxmox with one debian 10 buster VM, with 10 GB VM ram.

Blockly with one rule: 24 – 29 ms.
DzVents with one rule: 145 – 150 ms
Lua (file based) with one rule: 10 ms
Pass2PHP (best result) with one rule: 95 ms






Another comparation:
On my old core 2 quad Q8400 PC, with Windows 7 blocky and dzvents and Lua (db)


Blocky:
Spoiler: show

Code: Select all

2020-10-13 16:23:46.020 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 16:23:46.160 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 16:23:46.347 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 16:23:46.488 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 16:23:46.550 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 16:23:46.706 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
1 step: 2020-10-13 16:23:46.347 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 16:23:46.488 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1-2 : 141 ms



Dzvents:

Spoiler: show

Code: Select all

2020-10-13 16:12:59.893 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 16:12:59.752 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-13 16:13:00.064 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 16:13:00.314 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 16:13:00.548 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 16:13:00.595 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 16:13:00.751 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 16:13:02.747 (AEON) General/kWh (E-H-Klima-kWh Meter)
2020-10-13 16:13:03.652 (AEON) Usage (E-H-Klima-Watt)
2020-10-13 16:13:03.730 (AEON) General/kWh (E-H-Klima-kWh Meter)
2020-10-13 16:13:04.729 (AEON) General/Voltage (E-H-Klima-Voltage)

1 step: 2020-10-13 16:13:00.314 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 16:13:00.595 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1-2 > 281 ms


Lua ( db based)
Spoiler: show

Code: Select all

2020-10-13 16:17:43.135 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 16:17:43.401 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-13 16:17:43.884 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-13 16:17:44.056 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-13 16:17:44.118 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-13 16:17:44.196 (AEON) General/kWh (E-H-Klima-kWh Meter)
2020-10-13 16:17:44.274 (AEON) General/Voltage (E-K-Teafozo-Voltage)
2020-10-13 16:17:44.446 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-13 16:17:44.898 (AEON) Usage (E-H-Klima-Watt)
1 step: 2020-10-13 16:17:43.884 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2 step: 2020-10-13 16:17:44.056 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1→ 2 > 222 ms

old core 2 quad Q8400 PC, with Windows 7
Blockly with one rule: 141 ms
DzVents with one rule: 281 ms
Lua with one rule: 222 ms
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

You know that the blink of an eye takes between 100 and 400 msec?
Didn't know you had other stuff enabled. I only have 1 file based lua script. No blockly, other lua, dzvents, python, nothing.
I do have 609 entries in my devices table. They're mostly from 73 zwave nodes and some Xiaomi stuff.
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

Egregius wrote: Tuesday 13 October 2020 16:06 So strange that it's slower with opcache enabled. Almost unbelievable.
I didn't change much in the opcache config:

Code: Select all

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=40
opcache.validate_timestamps=0 //Change this to 1 when changing files, otherwise you need to flush the cache each time you change a php file.
I do have this in my apache virtual host file:

Code: Select all

<FilesMatch \.php$>
	SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
Well, let's just wait.
If I apply your line above ( Opcache optimalization) (with PHP 7.3) then nothing difference.
If I apply virtualhost modification the PHP call will not be executed, only the LUA call. Why?
My conf file:

root@domoticz:/etc/apache2/sites-available# ls -la
total 24
drwxr-xr-x 2 root root 4096 Oct 13 19:38 .
drwxr-xr-x 8 root root 4096 Oct 12 11:23 ..
-rw-r--r-- 1 root root 1440 Oct 13 19:38 000-default.conf
-rw-r--r-- 1 root root 6338 Aug 8 09:47 default-ssl.conf
-rw-r--r-- 1 root root 318 Oct 12 11:23 phpmyadmin.conf

Code: Select all

root@domoticz:/etc/apache2/sites-available# cat 000-default.conf 
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        <FilesMatch \.php$>
            SetHandler "proxy:unix:/run/php/php7.3-fpm.sock|fcgi://localhost"
        </FilesMatch>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
root@domoticz:/etc/apache2/sites-available# 


I use PHP7.3. How do you have 7.4?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

I recently upgraded from 7.3 to 7.4. 7.4 is the actual version.
Do you have php7.3-fpm installed? That's needed for the virtual host change.
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

And how?
My system is up to date, but cannot find newer PHP package.

Code: Select all

 cat /etc/apt/sources.list
# 

# deb cdrom:[Debian GNU/Linux 10.6.0 _Buster_ - Official amd64 NETINST 20200926-10:16]/ buster main

#deb cdrom:[Debian GNU/Linux 10.6.0 _Buster_ - Official amd64 NETINST 20200926-10:16]/ buster main

deb http://deb.debian.org/debian/ buster main
deb-src http://deb.debian.org/debian/ buster main

deb http://security.debian.org/debian-security buster/updates main
deb-src http://security.debian.org/debian-security buster/updates main

# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main
deb-src http://deb.debian.org/debian/ buster-updates main

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.


cat /etc/debian_version 
10.6

kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

Egregius wrote: Wednesday 14 October 2020 6:10 I recently upgraded from 7.3 to 7.4. 7.4 is the actual version.
Do you have php7.3-fpm installed?
That's needed for the virtual host change.
Yes, PHP 7.3-fpm was already installed.
Naturally. That's what I thought :)

That was the trick, it was still a must. Thus, it is no longer apache2 but PHP FPM / FastCGi:

Code: Select all

sudo a2enmod alias proxy proxy_fcgi
Response time now:
meseurement 1:

Code: Select all


[spoiler]2020-10-14 08:53:32.452 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-14 08:53:32.460 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-14 08:53:32.471 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-14 08:53:32.496 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-14 08:53:32.626 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-14 08:53:32.635 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-14 08:53:32.449 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-14 08:53:32.553 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-14 08:53:32.621 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-14 08:53:32.622 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-14 08:53:32.623 Status: => E-I-Mozgas2-Home Security = On
2020-10-14 08:53:32.625 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-14 08:53:32.625 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-14 08:53:32.691 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-14 08:53:32.763 Status: => (STORE) => E-I-Kapcsolo-Jobb => On (Pass2PHP)
[/spoiler]

step 1: 2020-10-14 08:53:32.471 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
step 2: 2020-10-14 08:53:32.626 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
1-> 2: 155 ms

meseurement 2:
Spoiler: show

Code: Select all

2020-10-14 08:57:58.065 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-14 08:57:58.073 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-14 08:57:58.090 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-14 08:57:58.107 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-14 08:57:58.119 (AEON) Lux (E-I-Mozgas2-Illuminance)
2020-10-14 08:57:58.181 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-14 08:57:58.187 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-14 08:57:58.062 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-14 08:57:58.137 Status: => (STORE) => E-I-Mozgas2-Sensor => Off (Pass2PHP)
2020-10-14 08:57:58.176 Status: => (STORE) => Alarm Type: Home Security 7 (0x07) => Motion Detected at Unknown Location (Pass2PHP)
2020-10-14 08:57:58.177 Status: => (STORE) => E-I-Mozgas2-Home Security => On (Pass2PHP)
2020-10-14 08:57:58.178 Status: => E-I-Mozgas2-Home Security = On
2020-10-14 08:57:58.179 Status: => (SWITCH) =>E-I-Kapcsolo-Jobb=>On ()
2020-10-14 08:57:58.180 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
2020-10-14 08:57:58.220 Status: => (STORE) => E-I-Mozgas2-Sensor => On (Pass2PHP)
2020-10-14 08:57:58.264 Status: => (STORE) => E-I-Mozgas2-Illuminance => 0 (Pass2PHP)
2020-10-14 08:57:58.311 Status: => (STORE) => E-I-Kapcsolo-Jobb => On (Pass2PHP)

step 1 : 2020-10-14 08:57:58.090 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
step 2: 2020-10-14 08:57:58.181 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

1->2 : 91 ms
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Isn't 91 msec fast enough?
User avatar
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: Pass2PHP

Post by sincze »

Wow great to read up on all the progress you guys made.

Domotica: I went for a Pi 8 GB with Geekworm Casing (including UPS) a 7 Watt killer machine with dockers spinning from Samsung EVO 850. My budget is not that big.
Changed my desktop machine for a NUC (WIndows 10) that I bought from my neighbour, wow great investement.
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.
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

Egregius wrote: Wednesday 14 October 2020 16:12 Isn't 91 msec fast enough?
You didn't stop earlier than 50 ms either. :)

91 ms is not 91 ms. :)

For example, in the last case, openzwave then means that there is motion:

1)

Code: Select all

2020-10-14 08:57:58.062 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2) For some reason, Domoticz first takes an Off signal from the PIR sensor (I can filter for that sooner anyway),

Code: Select all

2020-10-14 08:57:58.065 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
3) then senses a General / Alarm,

Code: Select all

2020-10-14 08:57:58.073 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
4) then senses Home Security,

Code: Select all

2020-10-14 08:57:58.090 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
5) then the message PIR = On arrives.:

Code: Select all

2020-10-14 08:57:58.107 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
6) and finish:

Code: Select all

2020-10-14 08:57:58.181 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
If we look at the response time from 4 -> 6 response time: 91 ms
"the real" response time: If we look at the response time from Openzwave detection already 1 -> 6 response time: 112 ms


Is there a way to start switching to the very first OpenZwave message?
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

sincze wrote: Wednesday 14 October 2020 16:22 Wow great to read up on all the progress you guys made.

Domotica: I went for a Pi 8 GB with Geekworm Casing (including UPS) a 7 Watt killer machine with dockers spinning from Samsung EVO 850. My budget is not that big.
Changed my desktop machine for a NUC (WIndows 10) that I bought from my neighbour, wow great investement.
What is your response time with PI now? Pi 4? Do you only use pass2php? With Mysql/Mariadb?
kispalsz
Posts: 31
Joined: Friday 13 October 2017 19:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Pass2PHP

Post by kispalsz »

I disabled all log. also the apache 2 logo.
DzVents Disabled.
Only one Lua script:

Code: Select all

for d,s in pairs(devicechanged)                                                                                                                                                                                                             
do                                                                                                                                                                                                                                          
--os.execute('curl -X POST -d "d='..d.."&s="..s..'" http://127.0.0.1/secure/pass2php2.php &')                                                                                                                                               
end                                                                                                                                                                                                                                         
commandArray={}   
The contents of new pass2php2.php only this: ( very very minimal :) )

Code: Select all

<?php                                                                                                                                                                                                    
$device=$_REQUEST['d'];                                                                                                                                                                                                                     
$status=$_REQUEST['s'];                                                                                                                                                                                                                     
                                                                                                                                                                                                   
if ($device == "E-I-Mozgas2-Sensor" && $status == "Off" )                                                                                                                                                                                   
{                                                                                                                                                                                                                                           
echo file_get_contents("http://192.168.42.23:8080/json.htm?type=command&param=switchlight&idx=59&switchcmd=On");                                       
}                                                                                                                                                                                                                                             
This turns on the lamp for the very first "Off" message from my PIR sernor. I don’t want to use it that way, but now I just try it because of it.
There is nothing but turning on the light. There is no function, mysql / mariadb call.

The LUA call runs, and then PHP runs.
The opcache cached the php file. The response time is amazing: ( without db connection, no query etc.)

Code: Select all

2020-10-14 13:04:23.900 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-14 13:04:23.913 (AEON) General/Alarm (Alarm Type: Home Security 7 (0x07))
2020-10-14 13:04:23.923 (AEON) Light/Switch (E-I-Mozgas2-Home Security)
2020-10-14 13:04:23.928 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)
2020-10-14 13:04:23.943 (AEON) Light/Switch (E-I-Mozgas2-Sensor)
2020-10-14 13:04:23.955 (AEON) Light/Switch (E-I-Kapcsolo-Jobb)
2020-10-14 13:04:23.892 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2020-10-14 13:04:23.927 Status: User: Admin initiated a switch command (59/E-I-Kapcsolo-Jobb/On)
1 step 2020-10-14 13:04:23.892 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 34 (0x22)
2 step: 2020-10-14 13:04:23.900 (AEON) Light/Switch (E-I-Mozgas2-Sensor) (SENSOR OFF message)
3 step: 2020-10-14 13:04:23.928 OpenZWave: Domoticz has send a Switch command! NodeID: 10 (0x0a)

"The real" response time: OpenZwave -> Switch on : 36 ms (previously using a database, with full pass2php script: 112 ms)
LUA+Pass2PHP response time: 28 ms :))))) (previously using a database, with full pass2php script: 91 ms)

Why is it so slow to build, query, and process a database connection when I use the full pass2php script? 63 ms
User avatar
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: Pass2PHP

Post by sincze »

Domoticz currently in production on a Pi 3B with PHP / MariaDB / NGINX

Xiaomi Motion Sensor triggers an 433 mhz light switch:

Code: Select all

2020-10-14 17:20:38.548 Status: {"cmd":"report","model":"motion","sid":"158d0001db34ce","short_id":30523,"data":"{\"status\":\"motion\"}"}

Code: Select all

2020-10-14 17:20:38.683 Status: --->> (Pass2PHP SWITCH) | Function Licht_WC_Boven On device: Motion Detector WC Boven with status: On
2020-10-14 17:20:38.686 Status: User: Admin initiated a switch command (1134/Lamp WC Boven/On)
Will be migrated to dedicated Pi 4 with same Geekworm casing that is currently serving 25 dockers without any issues.
docker.PNG
docker.PNG (9.1 KiB) Viewed 1888 times
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.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

You can of course keep this code in front of your pass2php file.

Code: Select all

<?php                                                                                                                                                                                                    
$device=$_REQUEST['d'];
$status=$_REQUEST['s'];
if ($device == "E-I-Mozgas2-Sensor" && $status == "Off" ) {                                                                                                                                                                                                                                           
	echo file_get_contents("http://192.168.42.23:8080/json.htm?type=command&param=switchlight&idx=59&switchcmd=On");
}
Then that will go very fast. I asume that the rest isn't that time critical?
ropske
Posts: 483
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi / ODroid
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: Pass2PHP

Post by ropske »

@Egrerius, i read that you also use some Xiaomi product. What controller you use for them?
User avatar
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: Pass2PHP

Post by sincze »

ropske wrote: Wednesday 21 October 2020 9:21 @Egrerius, i read that you also use some Xiaomi product. What controller you use for them?
Xiaomi Gateway in use and Sonoff Zigbee Gateway with Tasmota.
Sonoff.jpeg
Sonoff.jpeg (70.69 KiB) Viewed 1753 times
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.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

ropske wrote: Wednesday 21 October 2020 9:21 @Egrerius, i read that you also use some Xiaomi product. What controller you use for them?
I have the Xiaomi Gateway doorbell kind of thing. Some round thing sitting in the wall plug.
ropske
Posts: 483
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi / ODroid
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: Pass2PHP

Post by ropske »

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest