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 »

poudenes wrote: Friday 03 May 2019 11:02 from SSH:

Code: Select all

root@raspberrypi:/var/www/html/secure# php _fetchdomoticz.php                                                                                                                                                                                                                                  
PHP Warning:  require(/var/www/html/config.php): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 12
PHP Fatal error:  require(): Failed opening required '/var/www/html/config.php' (include_path='.:/usr/share/php') in /var/www/html/secure/_fetchdomoticz.php on line 12
from browser:

(A white screen)
ah ok, so you still get the same error?

just put the following files in the following folders and make no changes to the files at all:
2019-05-03 11_33_36-lua - Domoticz-NEW! - WinSCP.png
2019-05-03 11_33_36-lua - Domoticz-NEW! - WinSCP.png (3.79 KiB) Viewed 955 times
2019-05-03 11_33_13-www - Domoticz-NEW! - WinSCP.png
2019-05-03 11_33_13-www - Domoticz-NEW! - WinSCP.png (2.73 KiB) Viewed 955 times
2019-05-03 11_32_52-secure - Domoticz-NEW! - WinSCP.png
2019-05-03 11_32_52-secure - Domoticz-NEW! - WinSCP.png (3.5 KiB) Viewed 955 times
after that, please test again.
when you put the files in the folders and made no changes to the files(not even your own domoticz IP) it should work
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 »

Trigun wrote: Friday 03 May 2019 11:35
poudenes wrote: Friday 03 May 2019 11:02 from SSH:

Code: Select all

root@raspberrypi:/var/www/html/secure# php _fetchdomoticz.php                                                                                                                                                                                                                                  
PHP Warning:  require(/var/www/html/config.php): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 12
PHP Fatal error:  require(): Failed opening required '/var/www/html/config.php' (include_path='.:/usr/share/php') in /var/www/html/secure/_fetchdomoticz.php on line 12
from browser:

(A white screen)
ah ok, so you still get the same error?

just put the following files in the following folders and make no changes to the files at all:
2019-05-03 11_33_36-lua - Domoticz-NEW! - WinSCP.png
2019-05-03 11_33_13-www - Domoticz-NEW! - WinSCP.png
2019-05-03 11_32_52-secure - Domoticz-NEW! - WinSCP.png

after that, please test again.
when you put the files in the folders and made no changes to the files(not even your own domoticz IP) it should work
Moved config.php to /var/www/ and also change the path in the other files back to /var/www

then php _fetchdomoticz.php now I don't see any notices or errors :D
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
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 »

poudenes wrote: Friday 03 May 2019 11:40
Trigun wrote: Friday 03 May 2019 11:35
poudenes wrote: Friday 03 May 2019 11:02 from SSH:

Code: Select all

root@raspberrypi:/var/www/html/secure# php _fetchdomoticz.php                                                                                                                                                                                                                                  
PHP Warning:  require(/var/www/html/config.php): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 12
PHP Fatal error:  require(): Failed opening required '/var/www/html/config.php' (include_path='.:/usr/share/php') in /var/www/html/secure/_fetchdomoticz.php on line 12
from browser:

(A white screen)
ah ok, so you still get the same error?

just put the following files in the following folders and make no changes to the files at all:
2019-05-03 11_33_36-lua - Domoticz-NEW! - WinSCP.png
2019-05-03 11_33_13-www - Domoticz-NEW! - WinSCP.png
2019-05-03 11_32_52-secure - Domoticz-NEW! - WinSCP.png

after that, please test again.
when you put the files in the folders and made no changes to the files(not even your own domoticz IP) it should work
Moved config.php to /var/www/ and also change the path in the other files back to /var/www

then php _fetchdomoticz.php now I don't see any notices or errors :D
GREAT! now put the "echo"comment after the store line in de _fetch... file.

in the browser you can see the output when you enter http://domoticzip/secure/_fetchdomoticz.php
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 »

With all the support this is how you install pass2php. :D if im archived the way correct haha.

This is what I did now:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache
sudo apt-get install mysql-server
sudo apt-get install phpmyadmin
sudo mysql_secure_installation 

mysql -u root -p

GRANT ALL PRIVILEGES ON *.* TO 'domotica'@'localhost' IDENTIFIED BY 'domotica';
CREATE DATABASE domotica;
Download the GitHub package zip file. In this zip file you have ‘Create-Update SQL Database.txt'

Code: Select all

mysql -u domotica -p domotica < 'Create-Update SQL Database.txt'
mysql -u root -p

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| domotica           |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

sudo ln -s /usr/share/phpmyadmin /var/www/html
Copy all files from the ZIP to:

Code: Select all

/var/www/html/
So lots of files are in /var/www/html/
And lots of files are in /var/www/html/secure

move config.php to /var/www/

Edit _fetchdomoticz.php and add 2 lines:

Code: Select all

require '/var/www/config.php';
require 'functions.php';
copy from /var/www/html/secure/lua the file

Code: Select all

script_device_pass2php
to

Code: Select all

/domoitcz/script/lua
Edit _fetchdomoticz.php and add follow line direct below: store($name, $status, $idx, false);

Code: Select all

echo $idx.' '.$name.' = '.$status.'<br>';
so it looks like

Code: Select all

store($name, $status, $idx, false);
echo $idx.' '.$name.' = '.$status.'<br>';
to fetch all devices in dB:

Code: Select all

php _fetchdomoticz.php
If everything is correct what I post now, then all devices will be now in database.

open

Code: Select all

http://192.168.x.x/phpmyadmin
Login and in database: domotica > devices you can see all the devices
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 »

Could be that the spaces causes issues, I don't use them in my devicenames. Maybe Sincze can confirm or deny that.
Will look into it a bit later, just accidentally deleted all my devices :o
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: Friday 03 May 2019 12:05 Could be that the spaces causes issues, I don't use them in my devicenames. Maybe Sincze can confirm or deny that.
Will look into it a bit later, just accidentally deleted all my devices :o
Since I updated the path of config I can fetch without any errors... Everything is now in dB
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 »

Great, next step would be create a device script on a motion sensor to switch the light on.
And after that a cron script to switch it back off.
If that is working you're started to use pass2php ;)
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: Friday 03 May 2019 12:17 Great, next step would be create a device script on a motion sensor to switch the light on.
And after that a cron script to switch it back off.
If that is working you're started to use pass2php ;)
have a virtual switch "Switch-Hall-MEEK"

created a PHP file Switch-Hall-MEEK.php

add:

Code: Select all

if ($['status']['s']=='On') {                                                                                                                       
    sw('Dressoir-All', 'On');                                                                                                                        
} 
is this 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 »

Nope, it should be:

Code: Select all

if ($status=='On') {                                                                                                                       
    sw('Dressoir-All', 'On');                                                                                                                        
} 
$status holds the new status of the changed device.
$d array holds all the previous statusses.
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: Friday 03 May 2019 12:51 Nope, it should be:

Code: Select all

if ($status=='On') {                                                                                                                       
    sw('Dressoir-All', 'On');                                                                                                                        
} 
$status holds the new status of the changed device.
$d array holds all the previous statusses.
Changed it and there is nothing happen. Can I check a log to see what happend?

switch name is correct in dB, also the IDX is correct.
php filename is exact same as device name stored in dB, include case sensitive parts.
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
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 »

poudenes wrote: Friday 03 May 2019 12:54
Egregius wrote: Friday 03 May 2019 12:51 Nope, it should be:

Code: Select all

if ($status=='On') {                                                                                                                       
    sw('Dressoir-All', 'On');                                                                                                                        
} 
$status holds the new status of the changed device.
$d array holds all the previous statusses.
Changed it and there is nothing happen. Can I check a log to see what happend?

switch name is correct in dB, also the IDX is correct.
php filename is exact same as device name stored in dB, include case sensitive parts.
Sorry, I really don't understand this.
does it mean that for everything I want to switch I also have to make a new dummy switch?
That means I am going to have a whole lot of extra switches.

also, what do I need to do when I just want to switch a light on/off?

thnx guys!
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 »

poudenes wrote: Friday 03 May 2019 12:54 Changed it and there is nothing happen. Can I check a log to see what happend?

switch name is correct in dB, also the IDX is correct.
php filename is exact same as device name stored in dB, include case sensitive parts.
If your domoticz log is at /var/log/domoticz.log it should have extra lines in it. These aren't shown by the domoticz GUI log viewer.
You can use this to view the log in realtime thru SSH:

Code: Select all

tail -f /var/log/domoticz.log
Every switch line from pass2php starts with "(SWITCH)".
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 »

Trigun wrote: Friday 03 May 2019 13:39 Sorry, I really don't understand this.
does it mean that for everything I want to switch I also have to make a new dummy switch?
That means I am going to have a whole lot of extra switches.

also, what do I need to do when I just want to switch a light on/off?

thnx guys!
You don't need any dummy switch.
How do you want to switch of the light? From the floorplan or from a schedule?
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: Friday 03 May 2019 13:55
Trigun wrote: Friday 03 May 2019 13:39 Sorry, I really don't understand this.
does it mean that for everything I want to switch I also have to make a new dummy switch?
That means I am going to have a whole lot of extra switches.

also, what do I need to do when I just want to switch a light on/off?

thnx guys!
You don't need any dummy switch.
How do you want to switch of the light? From the floorplan or from a schedule?
I was wondering if I switch a light on/off via the domoticz dashboard if I also could use 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 »

This issue is now solved for Pass2php in latest Domoticz release. Tnx @Gizmocuz

https://github.com/domoticz/domoticz/is ... -489075040

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.
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: Friday 03 May 2019 13:54
poudenes wrote: Friday 03 May 2019 12:54 Changed it and there is nothing happen. Can I check a log to see what happend?

switch name is correct in dB, also the IDX is correct.
php filename is exact same as device name stored in dB, include case sensitive parts.
If your domoticz log is at /var/log/domoticz.log it should have extra lines in it. These aren't shown by the domoticz GUI log viewer.
You can use this to view the log in realtime thru SSH:

Code: Select all

tail -f /var/log/domoticz.log
Every switch line from pass2php starts with "(SWITCH)".
hmm I don't 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 »

Are the new statusses automatically available in the devices MySQL table?
If not, is the lua script in place?
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 »

Trigun wrote: Friday 03 May 2019 14:14 I was wondering if I switch a light on/off via the domoticz dashboard if I also could use pass2php
Yes, of course. All statusses are sent with the lua script to pass2php. So you can do everything with them.
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: Friday 03 May 2019 16:58
Trigun wrote: Friday 03 May 2019 14:14 I was wondering if I switch a light on/off via the domoticz dashboard if I also could use pass2php
Yes, of course. All statusses are sent with the lua script to pass2php. So you can do everything with them.
GREAT!!! I am getting closer and closer to the final result where I can go completely haywire with scripts :)

Ok, if i press a light to go On in domoticz what do I need to write in the php file?
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 »

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?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests