I tried to make it work based on the descriptions, Trigun 12-8-2019 TXT.
My system is Domoticz 2020.2 stable branch.
HW: Raspbery Pi 3+. with Raspbian Buster.
I Use Zwave hardware with AEON Gen5 Stick, and Zigbee hardware with DeConz stick.
When I copy the script_device_pass2php.lua file that contains the PIR switch to the Domoticz / scripts / lua folder, the PIR switch works for one switch, but then the system slows down completely. When I remove the script_device_pass2php.lua file it is in all OK.
This is script_device_pass2php.lua
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={}
Top command before copy script_device_pass2php.lua
Code: Select all
top - 21:25:58 up 21:54, 1 user, load average: 0.38, 0.58, 0.76
Tasks: 121 total, 1 running, 120 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.3 us, 5.3 sy, 0.0 ni, 89.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 926.1 total, 106.6 free, 187.6 used, 631.8 buff/cache
MiB Swap: 100.0 total, 99.5 free, 0.5 used. 641.9 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
650 root 20 0 349212 67328 19808 S 23.5 7.1 70:59.10 domoticz
11011 root 20 0 10328 3044 2512 R 11.8 0.3 0:00.04 top
1 root 20 0 34836 8236 6432 S 0.0 0.9 1:06.73 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.16 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
9 root 20 0 0 0 0 S 0.0 0.0 0:06.58 ksoftirqd/0
10 root 20 0 0 0 0 I 0.0 0.0 0:44.18 rcu_sched
11 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_bh
12 root rt 0 0 0 0 S 0.0 0.0 0:00.58 migration/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
14 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/1
15 root rt 0 0 0 0 S 0.0 0.0 0:00.51 migration/1
16 root 20 0 0 0 0 S 0.0 0.0 0:02.53 ksoftirqd/1
19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/2
20 root rt 0 0 0 0 S 0.0 0.0 0:00.49 migration/2
Top command after copy script_device_pass2php.lua
Code: Select all
top - 21:14:06 up 21:42, 1 user, load average: 2.39, 1.46, 0.89
Tasks: 134 total, 1 running, 133 sleeping, 0 stopped, 0 zombie
%Cpu(s): 7.8 us, 6.3 sy, 0.0 ni, 55.6 id, 30.0 wa, 0.0 hi, 0.3 si, 0.0 st
MiB Mem : 926.1 total, 102.2 free, 194.0 used, 629.8 buff/cache
MiB Swap: 100.0 total, 99.5 free, 0.5 used. 635.6 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
650 root 20 0 349212 67324 19808 S 19.9 7.1 70:18.35 domoticz
330 pi 20 0 126484 35600 26404 S 4.0 3.8 35:22.09 deCONZ
1732 root 20 0 20512 7684 6912 S 1.0 0.8 0:00.03 curl
1758 root 20 0 20512 7544 6772 S 1.0 0.8 0:00.03 curl
1768 root 20 0 20512 7608 6836 S 1.0 0.8 0:00.03 curl
372 root 20 0 8336 3188 2480 S 0.7 0.3 5:31.85 deCONZ-WIFI2.sh
373 root 20 0 7808 2596 2344 S 0.7 0.3 1:52.61 deCONZ-update2.
626 mysql 20 0 728176 69148 16032 S 0.7 7.3 1:28.44 mysqld
1525 root 20 0 10328 3084 2552 R 0.7 0.3 0:00.10 top
16 root 20 0 0 0 0 S 0.3 0.0 0:02.52 ksoftirqd/1
25 root rt 0 0 0 0 S 0.3 0.0 0:00.47 migration/3
383 root 20 0 27656 1356 1228 S 0.3 0.1 1:26.59 rngd
1770 root 20 0 20512 7516 6744 S 0.3 0.8 0:00.01 curl
1771 www-data 20 0 247036 11188 7584 S 0.3 1.2 0:00.01 php-fpm7.3
15496 www-data 20 0 50740 3924 2492 S 0.3 0.4 0:03.12 nginx
16215 root 20 0 0 0 0 I 0.3 0.0 0:00.55 kworker/u8:1-events_unbound
1 root 20 0 34836 8236 6432 S 0.0 0.9 1:06.26 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.16 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
Why does the load increase like this?
My fstab:
Code: Select all
root@domoticz:~# cat /etc/fstab
proc /proc proc defaults 0 0
PARTUUID=738a4d67-01 /boot vfat defaults,noatime 0 2
PARTUUID=738a4d67-02 / ext4 defaults,noatime,commit=1800 0 1
#/run, /var/run, /run/lock, /var/run/lock will be automatically created by default - tmpfs
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=100M 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=100M 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755 0 0
tmpfs /var/log/nginx tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755 0 0
#tmpfs /var/www/html tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=50M 0 0
tmpfs /var/lib/upsd tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=4K 0 0
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
I use /var/www/html folder
Code: Select all
root@domoticz:~# ls -la /var/www /var/www/html /var/www/html/secure
/var/www:
total 16
drwxr-xr-x 3 root root 4096 Jun 27 21:22 .
drwxr-xr-x 12 root root 4096 Apr 14 19:14 ..
-rw-r--r-- 1 root root 596 Jun 27 21:22 config.php
drwxr-xr-x 3 root root 4096 Jun 28 17:31 html
/var/www/html:
total 12
drwxr-xr-x 3 root root 4096 Jun 28 17:31 .
drwxr-xr-x 3 root root 4096 Jun 27 21:22 ..
lrwxrwxrwx 1 root root 21 Jun 28 17:30 phpmyadmin -> /usr/share/phpmyadmin
drwxr-xr-x 3 root root 4096 Jun 28 18:11 secure
/var/www/html/secure:
total 96
drwxr-xr-x 3 root root 4096 Jun 28 18:11 .
drwxr-xr-x 3 root root 4096 Jun 28 17:31 ..
-rwxrwxrwx 1 root root 25766 Jun 27 12:45 _cron60.php
-rwxrwxrwx 1 root root 2667 Jun 27 12:45 cron.php
-rwxrwxrwx 1 root root 3309 Jun 27 12:45 cron.sh
-rwxrwxrwx 1 root root 3215 Jun 28 17:33 _fetchdomoticz.php
-rwxrwxrwx 1 root root 40491 Jun 27 12:45 functions.php
drwxr-xr-x 2 root root 4096 Jun 28 21:09 pass2php
-rwxrwxrwx 1 root root 1223 Jun 27 12:45 pass2php.php
root@domoticz:~# cat /var/spool/cron/crontabs/root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.7zbnHk/crontab installed on Sat Jun 27 20:07:44 2020)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /usr/bin/nice -n20 /var/www/html/secure/cron.sh >/dev/null 2>&1
root@domoticz:~# ls -la /var/www/html/secure/pass2php/
/var/www/html/secure/pass2php/:
total 12
drwxr-xr-x 2 root root 4096 Jun 28 21:09 .
drwxr-xr-x 3 root root 4096 Jun 28 18:11 ..
-rw-r--r-- 1 root root 2240 Jun 28 21:09 E-H-Mozgas1-Sensor.php
I use ony one pass2php file for my PIR sensor E-H-Mozgas1-Sensor and for my Test wallswitch E-I-Kapcsolo-Bal
Code: Select all
root@domoticz:~# cat /var/www/html/secure/pass2php/E-H-Mozgas1-Sensor.php
<?php
/**
* Pass2PHP
* php version 7.3.3-1
*
* @category Home_Automation
* @package Pass2PHP
* @author Guy Verschuere <[email protected]>
* @license GNU GPLv3
* @link https://egregius.be
**/
if ($d['E-H-Mozgas1-Sensor']['s']=='On') {
sw('E-I-Kapcsolo-Bal', 'On');
} root@domoticz:~#
What I couldn't install from the description:
php-mycrypt
I added _cron60 but
"and your _cron60 or _cron 120 files etc
make sure to add the $d=fetchdata(); function to the _cron files"
What is this?
I skip domoticz log things.
My config.php
Code: Select all
root@domoticz:~# cat /var/www/config.php
<?php
/**
* Pass2PHP
* php version 7.3.4-2
*
* Example config file
* Can be placed in /var/www/config.php
*
* @category Home_Automation
* @package Pass2PHP
* @author Guy Verschuere <[email protected]>
* @license GNU GPLv3
* @link https://egregius.be
**/
error_reporting(E_ALL);
ini_set("display_errors", "on");
date_default_timezone_set('Europe/Brussels');
if (!defined('TIME')) {
define('TIME', $_SERVER['REQUEST_TIME']);
}
$log=false;
$page=basename($_SERVER['PHP_SELF']);
$dbname='domotica';
$dbuser='domotica';
$dbpass='domotica';
php version:
Code: Select all
$domoticzurl='http://127.0.0.1:8080';root@domoticz:~# php -v
PHP 7.3.14-1~deb10u1 (cli) (built: Feb 16 2020 15:07:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.14-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
root@domoticz:~# php -m
[PHP Modules]
apc
apcu
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
root@domoticz:~#
php _fetchdomoticz.php output without loaded pass2php lua script:
Code: Select all
root@domoticz:/var/www/html/secure# time php _fetchdomoticz.php
9 E-K-Huto-Switch = On
E-K-Huto-kWh Meter = 9.600 kWh
E-K-Huto-Watt = 86.6
16 E-F-Bojler-Switch = On
E-F-Bojler-kWh Meter = 27.370 kWh
E-F-Bojler-Watt = 1435
23 E-F-HMV-Switch = Off
E-F-HMV-kWh Meter = 0.000 kWh
E-F-HMV-Watt = 0
30 E-H-Klima-Switch = Off
33 E-I-Munkaallomas-Switch = On
E-I-Munkaallomas-kWh Meter = 4.810 kWh
E-I-Munkaallomas-Watt = 70.9
E-H-Klima-kWh Meter = 0.000 kWh
E-H-Klima-Watt = 0
58 E-I-Kapcsolo-Bal = Off
59 E-I-Kapcsolo-Jobb = On
60 E-N-Iranyfeny-Switch = On
E-N-Iranyfeny-kWh Meter = 0.120 kWh
E-N-Iranyfeny-Watt = 0
65 E-N-Klima-Switch = Off
E-N-Klima-kWh Meter = 0.000 kWh
E-N-Klima-Watt = 0
73 E-K-Kapcsolo1-Jobb = On
74 E-K-Kapcsolo1-Bal = Off
81 E-K-Forralo-Switch = On
E-K-Forralo-kWh Meter = 0.420 kWh
E-K-Forralo-Watt = 0
88 E-K-Teafozo-Switch = On
E-K-Teafozo-kWh Meter = 0.000 kWh
E-K-Teafozo-Watt = 0
96 E-K-Redony-Switch = Set Level: 58 %
114 E-GY-Klima-Switch = On
E-GY-Klima-kWh Meter = 0.490 kWh
E-GY-Klima-Watt = 6.7
123 E-K-Radiator-Valve Opening = 80
125 E-K-Radiator-Heat = 10.5
E-K-Radiator-Air Temperature = 27.9
148 E-F-Radiator-Valve Opening = 0
150 E-F-Radiator-Heat = 10.0
E-F-Radiator-Air Temperature = 26.7
157 E-H-Radiator-Valve Opening = 0
159 E-H-Radiator-Heat = 10.0
E-H-Radiator-Air Temperature = 27.8
170 E-I-Radiator-Valve Opening = 0
172 E-I-Radiator-Heat = 10.0
E-I-Radiator-Air Temperature = 28
183 E-GY-Radiator-Valve Opening = 0
185 E-GY-Radiator-Heat = 10.0
E-GY-Radiator-Air Temperature = 28.1
196 E-N-Radiator-Bal-Valve Opening = 0
197 Thermostat Mode = Heat
198 E-N-Radiator-Bal-Heat = 10.0
E-N-Radiator-Bal-Air Temperature = 27.8
209 E-N-Radiator-Jobb-Valve Opening = 0
211 E-N-Radiator-Jobb-Heat = 10.0
E-N-Radiator-Jobb-Air Temperature = 27.5
222 E-K-Mozgas1-Sensor = Off
224 E-K-Mozgas1-Illuminance = 19 Lux
229 E-I-Mozgas1-Sensor = Off
231 E-I-Mozgas1-Illuminance = 16 Lux
233 E-I-Mozgas2-Sensor = On
235 E-I-Mozgas2-Illuminance = 17 Lux
237 E-N-Mozgas1-Sensor = Off
239 E-N-Mozgas1-Illuminance = 10 Lux
241 Battery - E-K-Radiator = 60 %
242 Battery - E-F-Radiator = 50 %
243 Battery - E-H-Radiator = 55 %
244 Battery - E-I-Radiator = 30 %
245 Battery - E-GY-Radiator = 55 %
246 Battery - E-N-Radiator-Bal = 60 %
247 Battery - E-N-Radiator-Jobb = 55 %
248 Battery - E-K-Mozgas1 = 100 %
249 Battery - E-I-Mozgas1 = 70 %
250 Battery - E-I-Mozgas2 = 100 %
251 Battery - E-N-Mozgas1 = 100 %
267 E-H-Iranyfeny-Switch = Off
E-H-Iranyfeny-Watt = 0
E-H-Iranyfeny-kWh Meter = 0.100 kWh
274 Battery - E-K-Vizbetores1 = 100 %
275 E-H-Mozgas1-Sensor = Off
277 E-H-Mozgas1-Illuminance = 9 Lux
real 0m0.378s
user 0m0.153s
sys 0m0.065s
root@domoticz:/var/www/html/secure#
php _fetchdomoticz.php output with loaded pass2php lua script:
Code: Select all
root@domoticz:/var/www/html/secure# time php _fetchdomoticz.php
9 E-K-Huto-Switch = On
E-K-Huto-kWh Meter = 9.600 kWh
E-K-Huto-Watt = 86.6
16 E-F-Bojler-Switch = On
E-F-Bojler-kWh Meter = 27.460 kWh
E-F-Bojler-Watt = 0
23 E-F-HMV-Switch = Off
E-F-HMV-kWh Meter = 0.000 kWh
E-F-HMV-Watt = 0
30 E-H-Klima-Switch = Off
33 E-I-Munkaallomas-Switch = On
E-I-Munkaallomas-kWh Meter = 4.820 kWh
E-I-Munkaallomas-Watt = 70.9
E-H-Klima-kWh Meter = 0.000 kWh
E-H-Klima-Watt = 0
58 E-I-Kapcsolo-Bal = Off
59 E-I-Kapcsolo-Jobb = On
60 E-N-Iranyfeny-Switch = On
E-N-Iranyfeny-kWh Meter = 0.120 kWh
E-N-Iranyfeny-Watt = 0
65 E-N-Klima-Switch = Off
E-N-Klima-kWh Meter = 0.000 kWh
E-N-Klima-Watt = 0
73 E-K-Kapcsolo1-Jobb = On
74 E-K-Kapcsolo1-Bal = Off
81 E-K-Forralo-Switch = On
E-K-Forralo-kWh Meter = 0.420 kWh
E-K-Forralo-Watt = 0
88 E-K-Teafozo-Switch = On
E-K-Teafozo-kWh Meter = 0.000 kWh
E-K-Teafozo-Watt = 0
96 E-K-Redony-Switch = Set Level: 58 %
114 E-GY-Klima-Switch = On
E-GY-Klima-kWh Meter = 0.490 kWh
E-GY-Klima-Watt = 6.8
123 E-K-Radiator-Valve Opening = 80
125 E-K-Radiator-Heat = 10.5
E-K-Radiator-Air Temperature = 27.9
148 E-F-Radiator-Valve Opening = 0
150 E-F-Radiator-Heat = 10.0
E-F-Radiator-Air Temperature = 26.7
157 E-H-Radiator-Valve Opening = 0
159 E-H-Radiator-Heat = 10.0
E-H-Radiator-Air Temperature = 27.8
170 E-I-Radiator-Valve Opening = 0
172 E-I-Radiator-Heat = 10.0
E-I-Radiator-Air Temperature = 28
183 E-GY-Radiator-Valve Opening = 0
185 E-GY-Radiator-Heat = 10.0
E-GY-Radiator-Air Temperature = 28.1
196 E-N-Radiator-Bal-Valve Opening = 0
197 Thermostat Mode = Heat
198 E-N-Radiator-Bal-Heat = 10.0
E-N-Radiator-Bal-Air Temperature = 27.7
209 E-N-Radiator-Jobb-Valve Opening = 0
211 E-N-Radiator-Jobb-Heat = 10.0
E-N-Radiator-Jobb-Air Temperature = 27.5
222 E-K-Mozgas1-Sensor = Off
224 E-K-Mozgas1-Illuminance = 19 Lux
229 E-I-Mozgas1-Sensor = On
231 E-I-Mozgas1-Illuminance = 16 Lux
233 E-I-Mozgas2-Sensor = On
235 E-I-Mozgas2-Illuminance = 17 Lux
237 E-N-Mozgas1-Sensor = Off
239 E-N-Mozgas1-Illuminance = 10 Lux
241 Battery - E-K-Radiator = 60 %
242 Battery - E-F-Radiator = 50 %
243 Battery - E-H-Radiator = 55 %
244 Battery - E-I-Radiator = 30 %
245 Battery - E-GY-Radiator = 55 %
246 Battery - E-N-Radiator-Bal = 60 %
247 Battery - E-N-Radiator-Jobb = 55 %
248 Battery - E-K-Mozgas1 = 100 %
249 Battery - E-I-Mozgas1 = 70 %
250 Battery - E-I-Mozgas2 = 100 %
251 Battery - E-N-Mozgas1 = 100 %
267 E-H-Iranyfeny-Switch = Off
E-H-Iranyfeny-Watt = 0
E-H-Iranyfeny-kWh Meter = 0.100 kWh
274 Battery - E-K-Vizbetores1 = 100 %
275 E-H-Mozgas1-Sensor = Off
277 E-H-Mozgas1-Illuminance = 9 Lux
real 0m2.938s
user 0m0.138s
sys 0m0.053s
iotop by high iowait
Code: Select all
Total DISK READ: 0.00 B/s | Total DISK WRITE: 12.32 K/s
Current DISK READ: 0.00 B/s | Current DISK WRITE: 43.11 K/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
702 be/4 mysql 0.00 B/s 0.00 B/s 0.00 % 99.99 % mysqld
22936 be/4 mysql 0.00 B/s 0.00 B/s 0.00 % 91.22 % mysqld
87 be/3 root 0.00 B/s 3.08 K/s 0.00 % 4.10 % [jbd2/mmcblk0p2-]
729 be/4 mysql 0.00 B/s 3.08 K/s 0.00 % 0.00 % mysqld
716 be/4 root 0.00 B/s 3.08 K/s 0.00 % 0.00 % domoticz