Page 43 of 76

Re: Pass2PHP

Posted: Friday 03 May 2019 17:34
by Trigun
Egregius wrote:I'm afraid I don't really understand what you're trying to achive.
Do you want to use the floorplan to control everything, or do you just want to use pass2php for scripting?
I just want to use pass2php for scripting.
I guess I was confused. Obviously when you want a light to go on, you don’t need pass2php. You only need it if you create a function. For example a Pir which sets a light on.

That correct right?


Sent from my iPhone using Tapatalk

Re: Pass2PHP

Posted: Friday 03 May 2019 17:42
by Egregius
Indeed.
The floorplan part is a substitute for the Domoticz GUI wich offers a one page overview of the home and all lights etc.
The pass2php part is for scripting, like when motion detected and it's dark switch the light on.
Take some time to read all the cron and pass2php files of my github to get inspired.

Re: Pass2PHP

Posted: Friday 03 May 2019 17:56
by Trigun
Egregius wrote:Indeed.
The floorplan part is a substitute for the Domoticz GUI wich offers a one page overview of the home and all lights etc.
The pass2php part is for scripting, like when motion detected and it's dark switch the light on.
Take some time to read all the cron and pass2php files of my github to get inspired.
In which folder do I need to put these files?
Also in the secure folder?


Sent from my iPhone using Tapatalk

Re: Pass2PHP

Posted: Friday 03 May 2019 18:48
by Egregius
Wich files? I don't understand.

Re: Pass2PHP

Posted: Friday 03 May 2019 19:49
by Trigun
Egregius wrote:Wich files? I don't understand.
Ah sorry. The device php scripts.


Sent from my iPhone using Tapatalk

Re: Pass2PHP

Posted: Friday 03 May 2019 20:01
by gimic
Device files are in var/www/html/secure/pass2php

Re: Pass2PHP

Posted: Friday 03 May 2019 21:04
by sincze
Egregius wrote:Indeed.
The floorplan part is a substitute for the Domoticz GUI wich offers a one page overview of the home and all lights etc.
The pass2php part is for scripting, like when motion detected and it's dark switch the light on.
Take some time to read all the cron and pass2php files of my github to get inspired.
Currently I use it for scripting as well but was convinced by . Someone.. to try floorplans as well. That looks really promising a one pager for all my hundreds of devices.

Sent from my ONEPLUS A6003 using Tapatalk


Re: Pass2PHP

Posted: Friday 03 May 2019 22:19
by Egregius
One page is for ‘normal’ installations. Mine was one in the beginning. Now I have several.
Floorplan: lights, thermometers and status of rollers
Heating: setpoints, rollers, heating mode etc
Media: everything media related
Others: for the stuff that is lostly automised and rarely used.
I shall post some screenshots tomorrow.

Re: Pass2PHP

Posted: Friday 03 May 2019 23:36
by sincze
Egregius wrote:One page is for ‘normal’ installations. Mine was one in the beginning. Now I have several.
Floorplan: lights, thermometers and status of rollers
Heating: setpoints, rollers, heating mode etc
Media: everything media related
Others: for the stuff that is lostly automised and rarely used.
I shall post some screenshots tomorrow.
Sounds like music to my ears.. including the screenshots as I have massive amount of Domoticz icons. I don't really use them as pass2php takes care of all the automation. WAF is so far in the project that she even complains when she has to touch the bathroom/toilet switch in somebody else's home. Hahaha. Call that a Success..

Sent from my ONEPLUS A6003 using Tapatalk


Re: Pass2PHP

Posted: Saturday 04 May 2019 7:33
by Egregius
Put some screenshot's of the floorplans together in a post at https://egregius.be/2019/pass2php-and-f ... -domoticz/

Re: Pass2PHP

Posted: Saturday 04 May 2019 8:48
by poudenes
Im here again :)

I checked if all status changes are also stored in dB. Every change I see also back in dB so I guess that connection from Domoticz > pass2php > dB is working correct.

Now im gonna try to create a switch script:

1 switch turn on, then bulb1 must go on.

Code: Select all

if ($status=='On') {
    sw('Dressoir-All', 'On');
}   

Code: Select all

2019-05-04 08:49:02 Domoticz Switch-Hall-MEEK On

2019-05-04 08:49:48 Domoticz Switch-Hall-MEEK Off
But bulb1 (Dressoir-All) is not going on.

When I turn Dressoir-All on in Domoticz it self I get in dB this line

Code: Select all

2019-05-04 08:51:14  Domoticz  Dressoir-Al  On

Re: Pass2PHP

Posted: Saturday 04 May 2019 8:55
by gimic
Are the idx number filled in in tour database?

Re: Pass2PHP

Posted: Saturday 04 May 2019 8:57
by poudenes
gimic wrote: Saturday 04 May 2019 8:55 Are the idx number filled in in tour database?
Yes everything is filled correct

Re: Pass2PHP

Posted: Saturday 04 May 2019 9:27
by Egregius
Remove the // from line 67 of pass2php.php to add a extra logline to the domoticz logfile.
Use tail -f /var/log/domoticz.log to view the logfile.

If the line appears in the logfile pass2php is working.

Then add some extra lg() lines to add extra logging so you find to what point the script is functioning.

Re: Pass2PHP

Posted: Saturday 04 May 2019 10:31
by poudenes
Egregius wrote: Saturday 04 May 2019 9:27 Remove the // from line 67 of pass2php.php to add a extra logline to the domoticz logfile.
Use tail -f /var/log/domoticz.log to view the logfile.

If the line appears in the logfile pass2php is working.

Then add some extra lg() lines to add extra logging so you find to what point the script is functioning.
Nothing show in log.

script_device_pass2php.lua is already in /home/pi/domoticz/scripts/lua

Re: Pass2PHP

Posted: Saturday 04 May 2019 11:14
by Egregius
And the path to the logfile is good in the lg function?
The www-data user has rights to write to that file?
What is in the apache / php error log?

Re: Pass2PHP

Posted: Saturday 04 May 2019 11:39
by poudenes
Egregius wrote: Saturday 04 May 2019 11:14 And the path to the logfile is good in the lg function?
The www-data user has rights to write to that file?
What is in the apache / php error log?
Apache error log:

Code: Select all

Sat May 04 11:33:24.446333 2019] [:error] [pid 12816] [client 127.0.0.1:40336] PHP Warning:  fopen(/var/log/domoticz.log): failed to open stream: Permission denied in /var/www/html/secure/functions.php on line 866
[Sat May 04 11:33:24.446631 2019] [:error] [pid 12816] [client 127.0.0.1:40336] PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/secure/functions.php on line 871
[Sat May 04 11:33:24.446668 2019] [:error] [pid 12816] [client 127.0.0.1:40336] PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /var/www/html/secure/functions.php on line 872
updated the path in

function.php

function lg($msg)

Code: Select all

{                                                                                                                                                                          
    $fp=fopen('/tmp/domoticz.log', "a+");
    $time=microtime(true);
    $dFormat="Y-m-d H:i:s";
    $mSecs=$time-floor($time);
    $mSecs=substr(number_format($mSecs, 3), 1);
    fwrite($fp, sprintf("%s%s %s\n", date($dFormat), $mSecs, $msg));
    fclose($fp);                                                                                                                                                           
}
path to my log of Domoticz:

Code: Select all

/tmp/
-rw-r--r--  1 root root   245227 mei  4 11:34 domoticz.log
After this I still not see anything happen

Re: Pass2PHP

Posted: Saturday 04 May 2019 11:45
by Egregius
chmod 777 the domoticz logfile

Re: Pass2PHP

Posted: Saturday 04 May 2019 11:48
by poudenes
Egregius wrote: Saturday 04 May 2019 11:45 chmod 777 the domoticz logfile
changed still nothing.

in /home/pi/domoticz/scripts/lua/script_device_pass2php.lua have this:

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={}   

Re: Pass2PHP

Posted: Saturday 04 May 2019 11:59
by Egregius
That looks good. Nothing in the error log?