Re: Pass2PHP
Posted: Wednesday 17 April 2019 17:21
Nice job!
I can imagine that looking at it first time all @Egregius hard work looks overwhelming.Trigun wrote: ↑Wednesday 24 April 2019 18:21 Hey Guys,
at this moment my Rpi is getting slower and slower as more devices and camera are added.
I looked at pass2php multiple times but thought it will be too hard to implement but I really want to put my teeth into it as I believe this will be the answer to my issues.
hopefully you guys are willing to help me out a bit with my noob questions
as for starters which database is needed? mariaDB fof MySQL, I see both being mentioned in previous posts. as the principle doesn't really matter is still would like to make the richt choice
also, are the instructions of gimic all there is to carry out?
thanks in advance guys!
Code: Select all
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo apt-get install mysql-server
sudo apt-get install phpmyadmin
sudo mysql_secure_installation
Code: Select all
mysql -u root -p
Code: Select all
GRANT ALL PRIVILEGES ON *.* TO 'domotica'@'localhost' IDENTIFIED BY 'domotica';
CREATE DATABASE domotica;
Code: Select all
mysql -u domotica -p domotica < 'Create-Update SQL Database.txt'
Code: Select all
mysql -u root -p
Code: Select all
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| domotica |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
Code: Select all
sudo ln -s /usr/share/phpmyadmin /var/www/html
tnx.Egregius wrote: ↑Thursday 25 April 2019 14:40 Great post Sincze!
I linked to it from the readme
A starter pack could be interesting. However it basically isn't needed.
All that has to be done from the Github repo is:
- Empty secure/pass2php folder
- Empty _cron*.php files
Update/replace the config file.
After that it should be good to start.
Of course if you'd like to use the floorplan also there's some work to be done there to.
All files are delivered as I use them on my system. The Github repository https://github.com/Egregius/PHP-Floorpl ... r-Domoticz is a realtime image of my system.
All _cron*.php and secure/pass2php files can be used as an example and to see/learn the great flexibility of it.
Without it I've would already have abandoned Domoticz and maybe even domotica completely. What's the use of spending thousands of € if the stuff doesn't do exactly what you want?
WoW! that would be fantastic! than anybody can have a great, fast and stable working working domoticz setup.sincze wrote: ↑Thursday 25 April 2019 14:53tnx.Egregius wrote: ↑Thursday 25 April 2019 14:40 Great post Sincze!
I linked to it from the readme
A starter pack could be interesting. However it basically isn't needed.
All that has to be done from the Github repo is:
- Empty secure/pass2php folder
- Empty _cron*.php files
Update/replace the config file.
After that it should be good to start.
Of course if you'd like to use the floorplan also there's some work to be done there to.
All files are delivered as I use them on my system. The Github repository https://github.com/Egregius/PHP-Floorpl ... r-Domoticz is a realtime image of my system.
All _cron*.php and secure/pass2php files can be used as an example and to see/learn the great flexibility of it.
Without it I've would already have abandoned Domoticz and maybe even domotica completely. What's the use of spending thousands of € if the stuff doesn't do exactly what you want?
And you are correct with the light version
I found this OBS Studio video recorder.
Maybe I can create a video how to install from scratch
Mmm good question indeed.poudenes wrote: ↑Monday 29 April 2019 10:13 Hi All guys,
I tried to understand this but the installation makes me crazy already.
I understand to install MySQL, create user, import the .db file of Egregius.
But then ... Do I need to git pull the whole stuff to a folder or do I only need some .php files etc?
Can someone do the steps from a to z ?
Ok, got it all setup.sincze wrote:I can imagine that looking at it first time all @Egregius hard work looks overwhelming.Trigun wrote: ↑Wednesday 24 April 2019 18:21 Hey Guys,
at this moment my Rpi is getting slower and slower as more devices and camera are added.
I looked at pass2php multiple times but thought it will be too hard to implement but I really want to put my teeth into it as I believe this will be the answer to my issues.
hopefully you guys are willing to help me out a bit with my noob questions
as for starters which database is needed? mariaDB fof MySQL, I see both being mentioned in previous posts. as the principle doesn't really matter is still would like to make the richt choice
also, are the instructions of gimic all there is to carry out?
thanks in advance guys!
Keep in mind basically you only need:
- A Running Domoticz instance -> with a Pass2PHP lua file in the scripts/lua directory
- A Working Webserver (like NGINX) that calls a specific web page... pass2php.php
- A Pass2PHP.php file in the /var/www/html/secure directory
- A Function/ setting files that do thing in /var/www/html/secure
- A MariaDB (Debian default) database to store everything in.
- Phpmyadmin to keep an eye on the database
In addition a cron.sh will monitor A your Domoticz (and restart it if it crashed) B call cron jobs for things you want to happen at specific intervals. Like switch the lights off ar 23:00 or after 5 minutes of no motiion.
The rest he created is pure fun
Resume:
So everytime in Domoticz a device changes its state... It will call the lua file.
The lua calls the pass2php.php file and that file will store all changes in the database.
The database is also read in memory and that is the data you work with (An Array).
Should the Pi crash or reboot the changes are also kept in the Database so nothing lost.
I'm thinking of releasing a pass2php 'starter pack' that goes back to the beginning of Pass2PHP but is in line with the latest release of Egregius.
I hope this clears the smoke a bit.
viewtopic.php?f=64&t=12343&start=740#p211760
Do the secure installation after installin phpmyadmin, or be in some serious trouble....Code: Select all
sudo apt-get update sudo apt-get upgrade sudo apt-get install nginx sudo apt-get install mysql-server sudo apt-get install phpmyadmin sudo mysql_secure_installation
https://www.digitalocean.com/community/ ... untu-16-04
After changing the root password:Code: Select all
mysql -u root -p
Exit MYSQLCode: Select all
GRANT ALL PRIVILEGES ON *.* TO 'domotica'@'localhost' IDENTIFIED BY 'domotica'; CREATE DATABASE domotica;
Now import the Egregius database.Check if Database was createdCode: Select all
mysql -u domotica -p domotica < 'Create-Update SQL Database.txt'
Code: Select all
mysql -u root -p
To have phpmyadmin working via http://server_domain_or_IP/phpmyadmin for me I had to issue:Code: Select all
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | domotica | | information_schema | | mysql | | performance_schema | +--------------------+ 4 rows in set (0.00 sec)
Code: Select all
sudo ln -s /usr/share/phpmyadmin /var/www/html
Code: Select all
<?php
if ($status=='On') {
sw('lightkitchen', 'On');
}
Code: Select all
<?php
if ($status=="On"&&$d['auto']['s']=='On') {
if ($d['Weg']['s']==0&&$d['inkom']['s']=='Off'&&$d['zon']['s']<$zoninkom) {
sw('inkom', 'On');
}
}
Code: Select all
<?php
if ($status=="On"&&$d['auto']['s']=='On') {
if (TIME<strtotime('20:00')&&$d['Weg']['s']==0&&$d['keuken']['s']=='Off'&&$d['wasbak']['s']=='Off'&&$d['werkblad1']['s']=='Off'&&$d['kookplaat']['s']=='Off'&&($d['zon']['s']<$zonkeuken||($d['RkeukenL']['s']>70&&$d['RkeukenR']['s']>70))) {
sw('keuken', 'On');
}
}
just checken the file now but after putting in the url I am getting a unexpected error in line 12.Egregius wrote: ↑Wednesday 01 May 2019 6:12 Of course you can test it.
First of all you should check that the devices table is filled and that the idx's are known there.
To fill in the IDX's you have to include _fetchdomoticz.php somewhere, I have it included on a button on floorplan.others.php.
If the devices table is filled you know the exact names of all the devices.
Then, lets say you have a motion sensor called "PIRkitchen" you have to make a file secure/pass2php/PIRkitchen.php
In that file you could add something like:Then, if the light switches on upon movement pass2php if operational.Code: Select all
<?php if ($status=='On') { sw('lightkitchen', 'On'); }
Look at my examples starting with PIR for more advanced ways like using the sun and other devices to decide if the light needs to go on or not.
For example:Here the light is only switch on if the virtual switch auto is on, we're at home, the light is off and the power of the solar panels is less than $zoninkom.Code: Select all
<?php if ($status=="On"&&$d['auto']['s']=='On') { if ($d['Weg']['s']==0&&$d['inkom']['s']=='Off'&&$d['zon']['s']<$zoninkom) { sw('inkom', 'On'); } }
Or some more advanced:The light of the kitchen is only switched on when all other lights of the kitchen are off and that the solar power is less than 50W except when the shutters are more than 70% closed.Code: Select all
<?php if ($status=="On"&&$d['auto']['s']=='On') { if (TIME<strtotime('20:00')&&$d['Weg']['s']==0&&$d['keuken']['s']=='Off'&&$d['wasbak']['s']=='Off'&&$d['werkblad1']['s']=='Off'&&$d['kookplaat']['s']=='Off'&&($d['zon']['s']<$zonkeuken||($d['RkeukenL']['s']>70&&$d['RkeukenR']['s']>70))) { sw('keuken', 'On'); } }
Code: Select all
PHP Parse error: syntax error, unexpected '192.168' (T_DNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in /var/www/html/secure/_fetchdomoticz.php on line 12
Code: Select all
$domoticz=json_decode(file_get_contents($domoticzurl.'/json.htm?type=devices&used=true'), true);
Code: Select all
$domoticz=json_decode(file_get_contents($http://192.168.1.200:8080.'/json.htm?type=devices&used=true'), true);
Code: Select all
$domoticz=json_decode(file_get_contents($192.168.1.200:8080.'/json.htm?type=devices&used=true'), true);
Ok, no I am a bit lost too.sincze wrote: ↑Wednesday 01 May 2019 14:34 $domoticz=json_decode(file_get_contents($domoticzurl.'/json.htm?type=devices&used=true')
The $domoticzurl.'/json...
Is defined somewhere else as
http://127.0.0.1:8080 or similar
With that variable filled you can use it everywhere in Domoticz and believe me... A lot of functions use that variable.
ok, this is what I did so far:
Code: Select all
pi@raspberrypi:/var/www/html/secure $ php _fetchdomoticz.php
PHP Parse error: syntax error, unexpected ':', expecting ',' or ')' in /var/www/html/secure/_fetchdomoticz.php on line 12