Pass2PHP

Moderator: leecollings

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: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??
Ok great! Will look into it! I am getting more and more excited Image

Euh no I didn’t where do I need to put it?
Is it also automatically restarting Domoticz when it crashes?


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

Hi All,

My problems are solved for so far. Test script work now when I switch "Switch-Hall-MEEK" then also dressoir is going in.
I was forget:

<?php to start

?> to end the file.

Still I don't get log lines in domoitcz.log but thats probably just a path thing...
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
sincze
Posts: 1300
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:
sincze wrote: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??
Ok great! Will look into it! I am getting more and more excited Image

Euh no I didn’t where do I need to put it?
Is it also automatically restarting Domoticz when it crashes?


Sent from my iPhone using Tapatalk
Yes it restarts Domoticz when it crashes. Beautiful :) does not happen often luckily
.

I put it in /home/pi/domoticz/scripts/pass2php

I automatically backup the Domoticz directory to a NAS so if I keep everything in this directory it is automatically backupped. :)

Now edit
sudo nano /etc/crontab

Add the script here to run every minute and. Voila a working keep Domoticz alive Monitor.



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

poudenes wrote:Hi All,

My problems are solved for so far. Test script work now when I switch "Switch-Hall-MEEK" then also dressoir is going in.
I was forget:

<?php to start

?> to end the file.

Still I don't get log lines in domoitcz.log but thats probably just a path thing...
Should be /var/log/***

If it can't create the file the rights have to be adjusted...
Cheat:

cd /var/log
touch filename.***
sudo chmod www-data:www-data filename.***

Now it should be possible for the Apache machine to add data. This works for nginx so I assume apache is also using www-data as a user.

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: Sunday 05 May 2019 12:05
Trigun wrote:
sincze wrote: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??
Ok great! Will look into it! I am getting more and more excited Image

Euh no I didn’t where do I need to put it?
Is it also automatically restarting Domoticz when it crashes?


Sent from my iPhone using Tapatalk
Yes it restarts Domoticz when it crashes. Beautiful :) does not happen often luckily
.

I put it in /home/pi/domoticz/scripts/pass2php

I automatically backup the Domoticz directory to a NAS so if I keep everything in this directory it is automatically backupped. :)

Now edit
sudo nano /etc/crontab

Add the script here to run every minute and. Voila a working keep Domoticz alive Monitor.



Sent from my ONEPLUS A6003 using Tapatalk
ok, put the script in the /home/pi/domoticz/scripts/pass2php folder and gave it the 777 rights.
is this crontab filled in correctly(as it looks different).
2019-05-05 12_37_18-192.168.1.200.png
2019-05-05 12_37_18-192.168.1.200.png (156.87 KiB) Viewed 780 times
User avatar
sincze
Posts: 1300
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 »

Looks okay on my phonescreen.

User root will call the file Evey minute ;) :D

Usually you pipe the output to something with the > But don't know that by heart. Give it a Google search what the best option would be. This could work.
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:Looks okay on my phonescreen.

User root will call the file Evey minute ;) :D

Usually you pipe the output to something with the > But don't know that by heart. Give it a Google search what the best option would be. This could work.
I got it to pipe the output to a cronlog.log file in the same directory but now my Domoticz is restarting every minuteImage. Do I have to change the cron.sh file? When I open the file I see it is looking at different Cron.php files and a smappeepower.php file in the secure directory. I don’t have those files in there


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:
sincze wrote:Looks okay on my phonescreen.

User root will call the file Evey minute ;) :D

Usually you pipe the output to something with the > But don't know that by heart. Give it a Google search what the best option would be. This could work.
I got it to pipe the output to a cronlog.log file in the same directory but now my Domoticz is restarting every minuteImage. Do I have to change the cron.sh file? When I open the file I see it is looking at different Cron.php files and a smappeepower.php file in the secure directory. I don’t have those files in there


Sent from my iPhone using Tapatalk
Ok, putting the cron.php file in the right directory did the trick Image I am not sure how the cron is working for switching the light off after x seconds. As I see multiple variables doing lots of things. Where do I put in the number of seconds the switch has to turn off?


Sent from my iPhone using Tapatalk
User avatar
sincze
Posts: 1300
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 at the example Cron like _cron60

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

In this case if wc light is on for 5 minutes or longer... Switch it off.
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
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

The first 84 lines of https://github.com/Egregius/PHP-Floorpl ... cron10.php switch of several lights based on multiple things.
The wc light in cron60 is a simple example.

In cron.sh you and cron.php you decide wich scripts are executed.
I’ll post my crontab a bit later and add it to cron.sh as explanation.
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: Sunday 05 May 2019 14:51 Please Have a look at the example Cron like _cron60

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

In this case if wc light is on for 5 minutes or longer... Switch it off.
cool! I created a file called _cron60.php with the following code.

Code: Select all

<?php
if ($d['PIR-Bijkeuken']['s']=='On'
&& past('PIR-Bijkeuken')>60
) {
sw('PIR-Bijkeuken', 'Off');
}
and put in the/var/www/html/secure/pass2php

but it doesn't automatically switch off.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

I have my cron scripts just in the secure folder, take a look at the file/folder structure at github.
I just added a comment to the cron.sh script with my crontab:

Code: Select all

# m h  dom mon dow   command
* * * * * /usr/bin/nice -n20 /var/www/html/secure/cron.sh >/dev/null 2>&1
*/2 * * * * /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/cron.php?cron120" >/dev/null 2>&1
0 * * * * /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/cron.php?cron3600" >/dev/null 2>&1
0 0 * * * /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/cleandomoticzdb.php" >/dev/null 2>&1
1 0 * * * /usr/bin/nice -n20 /var/www/_SQLBackup/sqldaily.sh >dev/null 2>&1
Make sure to check the cleandomoticzdb.php script before adding it to the crontab!

cron.sh handles the cron10, cron60, heating and rollers script.
in cron.sh you can remove the smappee lines of you don't have a smappee.
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 »

Don’t know but all of a sudden nothing works anymore.

I can’t seem to tail anything anymore as it sticks to some old rules

Any ideas?


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:Don’t know but all of a sudden nothing works anymore.

I can’t seem to tail anything anymore as it sticks to some old rules

Any ideas?

Oh yeah, I already restarted Domoticz :)

Sent from my iPhone using Tapatalk


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:
Trigun wrote:Don’t know but all of a sudden nothing works anymore.

I can’t seem to tail anything anymore as it sticks to some old rules

Any ideas?

Oh yeah, I already restarted Domoticz :)

Sent from my iPhone using Tapatalk


Sent from my iPhone using Tapatalk
And for some reason it is working again Image
Had to set the correct rights again and now tail etc is working again.


Sent from my iPhone using Tapatalk
User avatar
sincze
Posts: 1300
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:
Trigun wrote:
Trigun wrote:Don’t know but all of a sudden nothing works anymore.

I can’t seem to tail anything anymore as it sticks to some old rules

Any ideas?

Oh yeah, I already restarted Domoticz :)

Sent from my iPhone using Tapatalk


Sent from my iPhone using Tapatalk
And for some reason it is working again Image
Had to set the correct rights again and now tail etc is working again.


Sent from my iPhone using Tapatalk
Make 1 typo in a crucial place... And it is back to the Apache/nginx logs. :)

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

Egregius wrote:I have my cron scripts just in the secure folder, take a look at the file/folder structure at github.
I just added a comment to the cron.sh script with my crontab:

Code: Select all

# m h  dom mon dow   command
* * * * * /usr/bin/nice -n20 /var/www/html/secure/cron.sh >/dev/null 2>&1
*/2 * * * * /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/cron.php?cron120" >/dev/null 2>&1
0 * * * * /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/cron.php?cron3600" >/dev/null 2>&1
0 0 * * * /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/cleandomoticzdb.php" >/dev/null 2>&1
1 0 * * * /usr/bin/nice -n20 /var/www/_SQLBackup/sqldaily.sh >dev/null 2>&1
Make sure to check the cleandomoticzdb.php script before adding it to the crontab!

cron.sh handles the cron10, cron60, heating and rollers script.
in cron.sh you can remove the smappee lines of you don't have a smappee.
Interesting never heard of;
/usr/bin/nice

What is the catch :)
Never to old to learn new tricks.

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.
User avatar
sincze
Posts: 1300
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:
sincze wrote: Sunday 05 May 2019 14:51 Please Have a look at the example Cron like _cron60

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

In this case if wc light is on for 5 minutes or longer... Switch it off.
cool! I created a file called _cron60.php with the following code.

Code: Select all

<?php
if ($d['PIR-Bijkeuken']['s']=='On'
&& past('PIR-Bijkeuken')>60
) {
sw('PIR-Bijkeuken', 'Off');
}
and put in the/var/www/html/secure/pass2php

but it doesn't automatically switch off.
Did not work with my Xiaomi motion sensors as well they don't like to be switched off :)

Can you give it a go with a lamp?
If motion sw lamp on
After 60 sec and lamp on.. switch lamp off.

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.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

sincze wrote: Sunday 05 May 2019 23:34 Interesting never heard of;
/usr/bin/nice

What is the catch :)
Never to old to learn new tricks.
nice is a program that handles priorities.
Priorities are from 0 to 39 on linux. Default is 20.
A positief nice number lowers the priority (but the number is raised so it's kind of reversed). This way you make sure that less important stuff doesn't get in the way of the more important stuff. You can see this in top in the columns PR and NI.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

sincze wrote: Sunday 05 May 2019 23:30 Make 1 typo in a crucial place... And it is back to the Apache/nginx logs. :)
True! Forget one ' ) ; } and it's done, no more reaction.
But then there's logs.php and log.php to the rescue. log.php is a script that reads in realtime a logfile and show it in the browser.
You should always have the apache error log open while changing stuff.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest