Page 44 of 76

Re: Pass2PHP

Posted: Saturday 04 May 2019 12:00
by poudenes
Egregius wrote: Saturday 04 May 2019 11:59 That looks good. Nothing in the error log?
no nothing....

Re: Pass2PHP

Posted: Saturday 04 May 2019 12:36
by Egregius
I don't understand...
Values in mysql table are updated, that means that pass2php is working.
If the lg function doesn't work it either doesn't have rights to the logfile or the parameters are wrong. In any way the apache or php logfile should show the errors.

Re: Pass2PHP

Posted: Saturday 04 May 2019 13:06
by poudenes
Egregius wrote: Saturday 04 May 2019 12:36 I don't understand...
Values in mysql table are updated, that means that pass2php is working.
If the lg function doesn't work it either doesn't have rights to the logfile or the parameters are wrong. In any way the apache or php logfile should show the errors.
all .php files have root:root

Code: Select all

[code]127.0.1.1:80 127.0.0.1 - - [04/May/2019:12:59:38 +0200] "POST /secure/pass2php.php HTTP/1.1" 200 163 "-" "curl/7.52.1"
127.0.1.1:80 127.0.0.1 - - [04/May/2019:12:59:38 +0200] "POST /secure/pass2php.php HTTP/1.1" 200 149 "-" "curl/7.52.1"
127.0.1.1:80 127.0.0.1 - - [04/May/2019:12:59:38 +0200] "POST /secure/pass2php.php HTTP/1.1" 200 163 "-" "curl/7.52.1"
[/code]

Code: Select all

-rwxrwxrwx  1 root root 318951 mei  4 13:03 domoticz.log
fetch is working

Code: Select all

php _fetchdomoticz.php
logging to dB is working, use phpmyadmin then I see last logs based on current time

When I switch for example Switch-Hall-MEEK I see that its updated in dB as well On states on and Off states off in dB

Re: Pass2PHP

Posted: Saturday 04 May 2019 13:06
by poudenes
im now goto my work... :( no testing for some hours... :geek: :roll:

Re: Pass2PHP

Posted: Saturday 04 May 2019 13:51
by Trigun
He Guys,

since I am still a bit of php noob, perhaps you guys are willing to help me out with a fairly simple test setup.
I have a motion sensor called "PIR-Bijkeuken" that needs to switch a light called "Bijkeuken" on and off.

I created a php file called: "PIR-Bijkeuken.php"
I entered the following code:

Code: Select all

<?php
if($status=='On'){
	sw('Bijkeuken','On');
as for now the switch is not working what am I doing wrong?

I would like the domoticz log file to show if the light is triggered(on and off) and I want the light to go out after 1 minute.

thanks in advance!

Re: Pass2PHP

Posted: Saturday 04 May 2019 13:57
by Egregius
Test that apache can write to the logfile, and that the path to the logfile is correct in the lg function.
Add a lg(‘test’); line at the end of pass2php.
If the test is logged (remember to use tail to watch the logfile, not the domoticz gui).
Move the lg test line inside the device script.
Once that is working move the lg test line inside the if status is on brackets.
Or add diferent lg lines so you can see in the logfile where the script gets.

Re: Pass2PHP

Posted: Saturday 04 May 2019 18:36
by Trigun
Egregius wrote: Saturday 04 May 2019 13:57 Test that apache can write to the logfile, and that the path to the logfile is correct in the lg function.
Add a lg(‘test’); line at the end of pass2php.
If the test is logged (remember to use tail to watch the logfile, not the domoticz gui).
Move the lg test line inside the device script.
Once that is working move the lg test line inside the if status is on brackets.
Or add diferent lg lines so you can see in the logfile where the script gets.
ok, this sounds odd bu there is no domoticz.log in /var/log :shock:

Re: Pass2PHP

Posted: Saturday 04 May 2019 21:08
by sincze
Trigun wrote:
Egregius wrote: Saturday 04 May 2019 13:57 Test that apache can write to the logfile, and that the path to the logfile is correct in the lg function.
Add a lg(‘test’); line at the end of pass2php.
If the test is logged (remember to use tail to watch the logfile, not the domoticz gui).
Move the lg test line inside the device script.
Once that is working move the lg test line inside the if status is on brackets.
Or add diferent lg lines so you can see in the logfile where the script gets.
ok, this sounds odd bu there is no domoticz.log in /var/log :shock:
Seems like a 'rights" issue. As _fetch is working just add an lg('test'); in there and look at Apache log as well.. tail -f ****Apache.log

Sent from my ONEPLUS A6003 using Tapatalk


Re: Pass2PHP

Posted: Saturday 04 May 2019 21:52
by Trigun
sincze wrote: Saturday 04 May 2019 21:08
Trigun wrote:
Egregius wrote: Saturday 04 May 2019 13:57 Test that apache can write to the logfile, and that the path to the logfile is correct in the lg function.
Add a lg(‘test’); line at the end of pass2php.
If the test is logged (remember to use tail to watch the logfile, not the domoticz gui).
Move the lg test line inside the device script.
Once that is working move the lg test line inside the if status is on brackets.
Or add diferent lg lines so you can see in the logfile where the script gets.
ok, this sounds odd bu there is no domoticz.log in /var/log :shock:
Seems like a 'rights" issue. As _fetch is working just add an lg('test'); in there and look at Apache log as well.. tail -f ****Apache.log

Sent from my ONEPLUS A6003 using Tapatalk
ok, i did a full search with winscp but no apache.log or domoticz.log is found
i guess im doing something wrong?

Re: Pass2PHP

Posted: Saturday 04 May 2019 21:56
by Trigun
Trigun wrote: Saturday 04 May 2019 21:52
sincze wrote: Saturday 04 May 2019 21:08
Trigun wrote:
ok, this sounds odd bu there is no domoticz.log in /var/log :shock:
Seems like a 'rights" issue. As _fetch is working just add an lg('test'); in there and look at Apache log as well.. tail -f ****Apache.log

Sent from my ONEPLUS A6003 using Tapatalk
ok, i did a full search with winscp but no apache.log or domoticz.log is found
i guess im doing something wrong?
I added this to the pass2php.php file
is this correct?

Re: Pass2PHP

Posted: Saturday 04 May 2019 22:06
by Trigun
could it be that /etc/init.d/domoticz.txt is the correct logfile?

Re: Pass2PHP

Posted: Saturday 04 May 2019 22:20
by sincze
Trigun wrote:could it be that /etc/init.d/domoticz.txt is the correct logfile?
Normally Apache should have some logging.

/var/log/apache2/access.log
/var/log/apache2/error.log

Is Apache running??

The lg command now in @egregiius code create a separate logfile. I modified it a bit so it shows up in the Domoticz log :)


Sent from my ONEPLUS A6003 using Tapatalk


Re: Pass2PHP

Posted: Saturday 04 May 2019 22:22
by Trigun
sincze wrote: Saturday 04 May 2019 22:20
Trigun wrote:could it be that /etc/init.d/domoticz.txt is the correct logfile?
Normally Apache should have some logging.

/var/log/apache2/access.log
/var/log/apache2/error.log

Is Apache running??

The lg command now in @egregiius code create a separate logfile. I modified it a bit so it shows up in the Domoticz log :)


Sent from my ONEPLUS A6003 using Tapatalk
yess I got something and it does show some errors
2019-05-04 22_20_00-_var_log_apache2_error.log - Domoticz-NEW! - Editor - WinSCP.png
2019-05-04 22_20_00-_var_log_apache2_error.log - Domoticz-NEW! - Editor - WinSCP.png (45.13 KiB) Viewed 747 times

Re: Pass2PHP

Posted: Saturday 04 May 2019 22:39
by Trigun
Trigun wrote: Saturday 04 May 2019 22:22
sincze wrote: Saturday 04 May 2019 22:20
Trigun wrote:could it be that /etc/init.d/domoticz.txt is the correct logfile?
Normally Apache should have some logging.

/var/log/apache2/access.log
/var/log/apache2/error.log

Is Apache running??

The lg command now in @egregiius code create a separate logfile. I modified it a bit so it shows up in the Domoticz log :)


Sent from my ONEPLUS A6003 using Tapatalk
yess I got something and it does show some errors
2019-05-04 22_20_00-_var_log_apache2_error.log - Domoticz-NEW! - Editor - WinSCP.png
ok, i did a chmod 777 on /var/log. now the error is gone.
i did a tail -f on the apache error log
since i set a lg (‘test’) on the pass2php.php file i can the test line in the apache log

Re: Pass2PHP

Posted: Saturday 04 May 2019 22:43
by Trigun
Trigun wrote: Saturday 04 May 2019 22:39
Trigun wrote: Saturday 04 May 2019 22:22
sincze wrote: Saturday 04 May 2019 22:20 Normally Apache should have some logging.

/var/log/apache2/access.log
/var/log/apache2/error.log

Is Apache running??

The lg command now in @egregiius code create a separate logfile. I modified it a bit so it shows up in the Domoticz log :)


Sent from my ONEPLUS A6003 using Tapatalk
yess I got something and it does show some errors
2019-05-04 22_20_00-_var_log_apache2_error.log - Domoticz-NEW! - Editor - WinSCP.png
ok, i did a chmod 777 on /var/log. now the error is gone.
i did a tail -f on the apache error log
since i set a lg (‘test’) on the pass2php.php file i can the test line in the apache log
now when I trigger the motion sensor i get the following error.
2019-05-04 22_42_16-_var_www_html_secure_pass2php_PIR-Bijkeuken.php - Domoticz-NEW! - Editor - WinSC.png
2019-05-04 22_42_16-_var_www_html_secure_pass2php_PIR-Bijkeuken.php - Domoticz-NEW! - Editor - WinSC.png (1.66 KiB) Viewed 744 times
apperantly something is wrong with the script :( but I dont know what?

Re: Pass2PHP

Posted: Saturday 04 May 2019 22:59
by Trigun
Trigun wrote:
Trigun wrote: Saturday 04 May 2019 22:39
Trigun wrote: Saturday 04 May 2019 22:22 yess I got something and it does show some errors
2019-05-04 22_20_00-_var_log_apache2_error.log - Domoticz-NEW! - Editor - WinSCP.png
ok, i did a chmod 777 on /var/log. now the error is gone.
i did a tail -f on the apache error log
since i set a lg (‘test’) on the pass2php.php file i can the test line in the apache log
now when I trigger the motion sensor i get the error that something is wrong in line 3
2019-05-04 22_42_16-_var_www_html_secure_pass2php_PIR-Bijkeuken.php - Domoticz-NEW! - Editor - WinSC.png
apperantly something is wrong with the script :( but I dont know what?


Sent from my iPhone using Tapatalk

Re: Pass2PHP

Posted: Saturday 04 May 2019 23:36
by sincze
You are missing a closing bracket } in your script

Re: Pass2PHP

Posted: Saturday 04 May 2019 23:43
by sincze
This website can check your php code and save you a lot of trouble

https://phpcodechecker.com


Sent from my ONEPLUS A6003 using Tapatalk


Re: Pass2PHP

Posted: Sunday 05 May 2019 8:34
by Trigun
sincze wrote:This website can check your php code and save you a lot of trouble

https://phpcodechecker.com


Sent from my ONEPLUS A6003 using Tapatalk
Whaaaa great it works!!!

The light went onImage

Can you tell me it works to make the light go out automatically?
This was done via a cronjob?


Verzonden vanaf mijn iPad met Tapatalk

Re: Pass2PHP

Posted: Sunday 05 May 2019 10:42
by sincze
please have a look on the example files e.g. _cron60.php
Look for an example with function past(60) in it.

And issue the sw function but now off. :)

Dit you implement cron.sh the Domoticz monitor and also used for pass2php crons??