Pass2PHP

Moderator: leecollings

User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

I do not mean the version of PHP but the version of pass2php.
There's no version number in the files, you have to compare against Github.
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 do not mean the version of PHP but the version of pass2php.
There's no version number in the files, you have to compare against Github.
Image sorry my mistake Image I’ll do a double check


Sent from my iPhone using Tapatalk
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 »

You are right! the file is different in many ways.

can I just replace the pass2php file or are there other things I need to do to get it working with the new file?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Try and you'll see ;)
I guess you better check the SQL update script to add missing columns and the fetch domoticz file. That one stores the device type in the dt column.
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:Try and you'll see ;)
I guess you better check the SQL update script to add missing columns and the fetch domoticz file. That one stores the device type in the dt column.
Ok, this is going to sound dumb as wellImage the sql update script, is is the same as the script which creates the database?


Sent from my iPhone using Tapatalk
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 »

Trigun wrote: Wednesday 07 August 2019 16:51
Egregius wrote:Try and you'll see ;)
I guess you better check the SQL update script to add missing columns and the fetch domoticz file. That one stores the device type in the dt column.
Ok, this is going to sound dumb as wellImage the sql update script, is is the same as the script which creates the database?


Sent from my iPhone using Tapatalk
I think I got it😊
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 »

Trigun wrote:
Trigun wrote: Wednesday 07 August 2019 16:51
Egregius wrote:Try and you'll see ;)
I guess you better check the SQL update script to add missing columns and the fetch domoticz file. That one stores the device type in the dt column.
Ok, this is going to sound dumb as wellImage the sql update script, is is the same as the script which creates the database?


Sent from my iPhone using Tapatalk
I think I got itImage
I think its not just replacing the file since more files have been updated i have to replace those too.
As for now my new _fetchdomoticz doesn’t work as it says my domoticz url is not definedImage


Sent from my iPhone using Tapatalk
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 »

after changing all the files and setting the correct rights the following errors are stil there:

if I run the _fetchdomoticz.php script I get the following error:

Code: Select all

2019/08/08 10:53:39 [error] 638#638: *2339 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: domoticzurl in /var/www/html/secure/_fetchdomoticz.php on line 14
PHP message: PHP Warning:  file_get_contents(/json.htm?type=devices&used=true): failed to open stream: No such file or directory in /var/www/html/secure/_fetchdomoticz.php on line 14" while reading response header from upstream, client: 192.168.1.40, server: _, request: "GET /secure/_fetchdomoticz.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "192.168.1.200"
since I am only using a cron60 and a cron3600 (from the previous setup) it also get the following error.

Code: Select all

2019/08/08 10:54:01 [error] 638#638: *2363 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined index: PIR_Badkamer in /var/www/html/secure/_cron60.php on line 20" while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /secure/cron.php?cron10&verwarming&rolluiken&cron60&cron120&cron180 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "127.0.0.1"
both errors did not appear with my previous setup. any idea to solve these?
I made an extensive guide for setting up pass2php but I don't remember putting in my domoticz url somewhere as it has always been 'Localhost'

do you have any idea how to solve these?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

$domoticzurl has to be set in your config.php file.
There's an example in the secure folder.
I store mine in /var/www so it doesn't get pushed to Github.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

The second error about PIR_Badkamer means that you're using a name in the cron file that doesn't exists in the database.
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:$domoticzurl has to be set in your config.php file.
There's an example in the secure folder.
I store mine in /var/www so it doesn't get pushed to Github.
I know but it’s already in there: 127.0.0.1:8080
This should be correct.

I believe the reason for the second error is due the _fetch file not working.

Using my old _fetch file gives the same error.
I think I have to start over to het iT working again


Sent from my iPhone using Tapatalk
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 »

ok, GOT IT SOLVED!!!

I thought I had this issue before and after scrolling down this topic I found it!

The folowing lines need to be added to the _Fetchdomoticz.php file.

Code: Select all

require '/var/www/config.php';
require 'functions.php';
Is there a chance you want to add them to your file as well? ( for future updates ;) )

I also added this to my pass2php guide. if anyone is interested I attached it :)
please let me know if anyone thinks I missed something.
8-8-2019 Pass2php Guide.txt
(4.23 KiB) Downloaded 119 times
of course all the credits go Egregius(the majority of the credits :)) and Sincze for helping me out and spending time for all my noob questions!
again, thanks guys!

cheers!
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

My fetchdomoticz is included in my floorplan so I don’t need it ;)

It might be a hard way to learn but this way you also learn how things hang together.
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: Thursday 08 August 2019 22:14 My fetchdomoticz is included in my floorplan so I don’t need it ;)

It might be a hard way to learn but this way you also learn how things hang together.
you are absolutely right and thats ok :)
as long as I can ask a few questions so once in a while :)

so once I got everything working again I updated again to you latest files.

I have a very basic setup compared to yours but my cron files used to work with it.
my cron 60 looks like:

Code: Select all

<?php
lg('this is __cron60 --> a 1 minute Cron'); 

if ($d['Garageportaal']['s']=='On'&&$d['PIR_Garageportaal']['s']=='Off'&&past('Garageportaal')>60) {
	sw('Garageportaal', 'Off');
}

if ($d['Garageportaal']['s']=='On'&&$d['PIR_Garage']['s']=='Off'&&past('Garageportaal')>60) {
	sw('Garageportaal', 'Off');
}

if ($d['Berging']['s']=='On'&&$d['PIR_Berging']['s']=='Off'&&past('Berging')>60) {
	sw('Berging', 'Off');
}

if ($d['Overloop']['s']=='On'&&$d['Auto']['s']=='Off'&&$d['PIR_Overloop']['s']=='Off'&&past('Overloop')>60) {
	sw('Overloop', 'Off');
}
	
lg('STATUS ==> Badkamer='.$d['Badkamer']['s'].', past='.past('Badkamer'));
if ($d['Badkamer']['s']>=1&&$d['Auto']['s']=='Off'&&past('Badkamer')>60){
	sw('Badkamer', 'Off');
}

lg('STATUS ==> BANO_Outdoor-Rain='.$d['BANO_Outdoor-Rain']['s'].', Buienradar_Solar-Radiation='.$d['Buienradar_Solar-Radiation']['s'].', Tuinsproeiers='.$d['Tuinsproeiers']['s']);
if (TIME>=strtotime('T04:00')&&TIME<=strtotime('T07:00')&&$d['BANO_Outdoor-Rain']['s']<1&&$d['Buienradar_Solar-Radiation']['s']<250&&$d['Tuinsproeiers']['s']=='Off') {
	sw('Tuinsproeiers', 'On');

}

?>
with this setup I am unfortunately getting this error which I cant figure out.

Code: Select all

2019/08/08 22:24:02 [error] 703#703: *21135 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: d in /var/www/html/secure/_cron60.php on line 6
PHP message: PHP Notice:  Undefined variable: d in /var/www/html/secure/_cron60.php on line 10
PHP message: PHP Notice:  Undefined variable: d in /var/www/html/secure/_cron60.php on line 14
PHP message: PHP Notice:  Undefined variable: d in /var/www/html/secure/_cron60.php on line 18
PHP message: PHP Notice:  Undefined variable: d in /var/www/html/secure/_cron60.php on line 22" while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /secure/cron.php?cron60 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "127.0.0.1"
you have any idea where this comes from?
If I compare the cron60 to yours the difference is too big to see what I need to change :(
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

You need line 15 of cron.php:
$d=fetchdata();

$d is now filled with the fetchdata() function. So you can include the functions file without it calling the data everytime.
And you can add multiple $d=fetchdata() lines if you need an updated dataset.
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:You need line 15 of cron.php:
$d=fetchdata();

$d is now filled with the fetchdata() function. So you can include the functions file without it calling the data everytime.
And you can add multiple $d=fetchdata() lines if you need an updated dataset.
Ok, so just add $d=fetchdata(); to the cron60 file?
Sorry, but how to put it and where?


Sent from my iPhone using Tapatalk
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

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 »

OK, NICE!!! the error is gone!

now I need to get my cron working again.
are there any lines I need to add to the cron file?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

You mean in cron60?
Normally not.
$d is fetched in cron.php before including cron60 so $d is available.
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 09 August 2019 10:03 You mean in cron60?
Normally not.
$d is fetched in cron.php before including cron60 so $d is available.
Tge strange thing is that my cron files are actually working now!
the only thing is that I have have multiple LG line in my cron60 file see:

Code: Select all

<?php
lg('this is __cron60 --> a 1 minute Cron'); 

if ($d['Garageportaal']['s']=='On'&&$d['PIR_Garageportaal']['s']=='Off'&&past('Garageportaal')>60) {
	sw('Garageportaal', 'Off');
}

if ($d['Garageportaal']['s']=='On'&&$d['PIR_Garage']['s']=='Off'&&past('Garageportaal')>60) {
	sw('Garageportaal', 'Off');
}

if ($d['Berging']['s']=='On'&&$d['PIR_Berging']['s']=='Off'&&past('Berging')>60) {
	sw('Berging', 'Off');
}

if ($d['Overloop']['s']=='On'&&$d['Auto']['s']=='Off'&&$d['PIR_Overloop']['s']=='Off'&&past('Overloop')>60) {
	sw('Overloop', 'Off');
}
	
lg('STATUS ==> Badkamer='.$d['Badkamer']['s'].', past='.past('Badkamer'));
if ($d['Badkamer']['s']>=50&&$d['Auto']['s']=='Off'&&past('Badkamer')>60){
	sw('Badkamer', 'Off');
}

lg('STATUS ==> BANO_Outdoor-Rain='.$d['BANO_Outdoor-Rain']['s'].', Buienradar_Solar-Radiation='.$d['Buienradar_Solar-Radiation']['s'].', Tuinsproeiers='.$d['Tuinsproeiers']['s']);
if (TIME>=strtotime('T04:00')&&TIME<=strtotime('T07:00')&&$d['BANO_Outdoor-Rain']['s']<1&&$d['Buienradar_Solar-Radiation']['s']<250&&$d['Tuinsproeiers']['s']=='Off') {
	sw('Tuinsproeiers', 'On');

}

?>
but I cannot see them comming back in the Log file once I am doing a tail -f of the domoticz.log file
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest