Pass2PHP
Moderator: leecollings
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Yes, if a blockly can be triggered then the device status update will also trigger the lua script to send the status to php.
It should also be possible to let php subscribe to the same MQTT server and receive the messages even faster.
It should also be possible to let php subscribe to the same MQTT server and receive the messages even faster.
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
well, then i give it a try to install the script. Probably i come back to you for help to let the the php script talk to the mqtt server.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
I can help you with the lua script and pass2php but I have no experience with mqtt. A quick google learned me that it’s possible.
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
oke, first NOOB question probably

I followed all the installation steps but get the following error when i type in the following command in my browser:
http://190.168.2.xxx/secure/_fetchdomoticz.php
Notice: Undefined variable: db in /var/www/html/secure/_fetchdomoticz.php on line 84
Fatal error: Uncaught Error: Call to a member function query() on null in /var/www/html/secure/_fetchdomoticz.php:84 Stack trace: #0 {main} thrown in /var/www/html/secure/_fetchdomoticz.php on line 84
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
That page get’s included in my floorplan. If you want to execute it directly in a browser you need the include the functions.php file.
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
I have deleted that part of the code because i am not intend to use the floorplan. I placed all the necessary files at the location as prescribed and added the functions.php and confog.php in the _fetchdomoticz file. I have no more errors anymore. Unfortunatley the database is not filled with the switches of domoticz when i trigger one in domoticz. Could this something to do with the fact that i use apache2 instead of nginx?
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
No, I also use apache2 so that's not the problem.
With fetchdomoticz all current states are stored in the database.
Did you place the lua script? That script sents the updates in realtime.
With fetchdomoticz all current states are stored in the database.
Did you place the lua script? That script sents the updates in realtime.
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: Pass2PHP
I had the same kind of problem. See previous postings in this thread, the answers are very valuable and helpful.madradrakie wrote: ↑Monday 10 February 2020 7:19 I have deleted that part of the code because i am not intend to use the floorplan. I placed all the necessary files at the location as prescribed and added the functions.php and config.php in the _fetchdomoticz file. I have no more errors anymore. Unfortunatley the database is not filled with the switches of domoticz when i trigger one in domoticz. Could this something to do with the fact that i use apache2 instead of nginx?
I think I put these lines at the top of _fetchdomoticz.php
Code: Select all
require '/var/www/config.php';
require '/var/www/html/secure/functions.php';
$db=new PDO("mysql:host=localhost;dbname=$dbname;",$dbuser,$dbpass);
Code: Select all
<?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';
$domoticzurl='http://127.0.0.1:8080';
Greetings McMelloW
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
SUPER! it is working. I think i have seen all 60 pages of this forum but did not found this solution. Thanks again for this part! Now lets start with the next stepMcMelloW wrote: ↑Monday 10 February 2020 16:47I had the same kind of problem. See previous postings in this thread, the answers are very valuable and helpful.madradrakie wrote: ↑Monday 10 February 2020 7:19 I have deleted that part of the code because i am not intend to use the floorplan. I placed all the necessary files at the location as prescribed and added the functions.php and config.php in the _fetchdomoticz file. I have no more errors anymore. Unfortunatley the database is not filled with the switches of domoticz when i trigger one in domoticz. Could this something to do with the fact that i use apache2 instead of nginx?
I think I put these lines at the top of _fetchdomoticz.phpAnd stripped config.php to this minimalCode: Select all
require '/var/www/config.php'; require '/var/www/html/secure/functions.php'; $db=new PDO("mysql:host=localhost;dbname=$dbname;",$dbuser,$dbpass);
After this it did run without any errors. With PhpMyAdmin, I saw all active devises as a row in the Devices table. Correct me if I am wrong.Code: Select all
<?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'; $domoticzurl='http://127.0.0.1:8080';

- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Glad to hear it's working also for you. Seems like it's getting easier to get it running.
I enabled wiki's on the gitbub repo.
I'll try to fill them in the next days but feel free to add information there. Advantage will be that it get's centralized in a couple of pages instead of 60 pages here.
I enabled wiki's on the gitbub repo.
I'll try to fill them in the next days but feel free to add information there. Advantage will be that it get's centralized in a couple of pages instead of 60 pages here.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
I can only advice to use the floorplan. It's way easier and faster than the default gui. Try imagining what time it costs to scroll to a switch list of 88 switches to find the right one? Add to that that on mobile device you may not hit a dimmer slider and you have a unusable thing.
With the floorplan you see instantly the status of the whole house and you just have to click whatever light you want to switch.
With the floorplan you see instantly the status of the whole house and you just have to click whatever light you want to switch.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
And it's perfectly ok to leave the files in their place. The html folder only occupies 460KB... So no need to strip out anything.
I'm wondering how far @sincze got with the floorplan? Any screenshots?
I'm wondering how far @sincze got with the floorplan? Any screenshots?
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
oke, still one more problem. My idx are not shown in the table. I tried to figure uit what @sincze did because he had the same problem but have not that many skills to figure it out.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Idx is only filled while running fetchdomoticz.
That script must also be executed every time you add/change devices in domoticz.
That script must also be executed every time you add/change devices in domoticz.
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
the following thing i did (already multiple times). I opened putty.
Opened the secure map )(cd /var/.. and execeted php _fetchdomoticz.php. I get no errors.
Is this what you mean by execiting _fetchdomoticz.php?
When i look at the database the status of the devices is updated every time so that is not the problem.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
What is the output of the script?
I've made some small changes in it so the output in CLI mode would be nice.
I've made some small changes in it so the output in CLI mode would be nice.
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
it is working. I had made a small error in the _fetchdomoticz file....
The first simple php script is also working, lets continue explorering...next step... cron files..
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Pass2PHP
Great, good job.
You'll find plenty of cron stuf in my _underscore files.
If not, just ask, we'll try to help where possible.
You'll find plenty of cron stuf in my _underscore files.
If not, just ask, we'll try to help where possible.
-
- Posts: 64
- Joined: Wednesday 11 September 2019 21:24
- Target OS: -
- Domoticz version:
- Contact:
Re: Pass2PHP
in my domoticz blockies i often use the function of sunset and sunrise as condition to switch a light on or off. Is this also possible in php to make use of this domoticz functionality? Or do i have to make a dummy switch in domoticz for this?
Who is online
Users browsing this forum: No registered users and 1 guest