Pass2PHP

Moderator: leecollings

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: Saturday 04 May 2019 11:59 That looks good. Nothing in the error log?
no nothing....
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: 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 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.
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: 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
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand 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 »

im now goto my work... :( no testing for some hours... :geek: :roll:
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 »

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

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.
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: 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:
User avatar
sincze
Posts: 1302
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 »

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

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.
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 »

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?
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: 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?
Attachments
2019-05-04 21_54_59-_var_www_html_secure_pass2php.php - Domoticz-NEW! - Editor - WinSCP.png
2019-05-04 21_54_59-_var_www_html_secure_pass2php.php - Domoticz-NEW! - Editor - WinSCP.png (4.03 KiB) Viewed 726 times
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 »

could it be that /etc/init.d/domoticz.txt is the correct logfile?
User avatar
sincze
Posts: 1302
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 »

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

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.
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 »

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 725 times
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: 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
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: 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 722 times
apperantly something is wrong with the script :( but I dont know what?
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: 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
User avatar
sincze
Posts: 1302
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 »

You are missing a closing bracket } in your script
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.
User avatar
sincze
Posts: 1302
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 website can check your php code and save you a lot of trouble

https://phpcodechecker.com


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.
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 »

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
User avatar
sincze
Posts: 1302
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 »

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

Who is online

Users browsing this forum: No registered users and 1 guest