Pass2PHP

Moderator: leecollings

Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Pass2PHP

Post 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
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post 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.
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Pass2PHP

Post 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
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Wich files? I don't understand.
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Pass2PHP

Post by Trigun »

Egregius wrote:Wich files? I don't understand.
Ah sorry. The device php scripts.


Sent from my iPhone using Tapatalk
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Device files are in var/www/html/secure/pass2php
User avatar
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: Pass2PHP

Post 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

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: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post 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.
User avatar
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: Pass2PHP

Post 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

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: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Put some screenshot's of the floorplans together in a post at https://egregius.be/2019/pass2php-and-f ... -domoticz/
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Pass2PHP

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
gimic
Posts: 50
Joined: Thursday 04 January 2018 8:43
Target OS: Linux
Domoticz version: 3.66
Location: Roeselare, Wvl, BE
Contact:

Re: Pass2PHP

Post by gimic »

Are the idx number filled in in tour database?
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Pass2PHP

Post by poudenes »

gimic wrote: Saturday 04 May 2019 8:55 Are the idx number filled in in tour database?
Yes everything is filled correct
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post 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.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Pass2PHP

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post 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?
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Pass2PHP

Post 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

chmod 777 the domoticz logfile
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Pass2PHP

Post 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={}   
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

That looks good. Nothing in the error log?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest