Pass2PHP

Moderator: leecollings

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:
Trigun wrote: Friday 10 May 2019 19:28
Trigun wrote: Friday 10 May 2019 19:13 ok, now I know for sure that my cron is not working
because when I manually start the cron.sh script I get the lg line in the domoticz.log
so, back to the cron :)
ok, I think I got it.
2 things - the cron.sh was not executable so I did a chmod 777 to cron.sh
and I found out that I used "sudo crontab -e" instead of crontab -e.
now I see the script is running perfectly every minute :D

just keeping you all informed as it might help others as wel.
Hahaha sudo crontab -e / elevated user
crontab -e .. would be the pi user

Strange that you experience all these things. Well done. Making progress. Weekend just started :)

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: Friday 10 May 2019 20:00
Trigun wrote:
Trigun wrote: Friday 10 May 2019 19:28
he guys just found out that when I have the following code in _cron60, the auto off for just Bijkeuken does not work.

Code: Select all

<?php
lg('this is __cron60'); 

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

if ($d['Garageportaal']['s']=='On'&&$d['PIR-Garageportaal']['s']=='Off'&&past('Garageportaal')>60) {
	sw('Garageportaal', 'Off');
}
?>
but when I leave "&&$d['PIR-Bijkeuken']['s']=='Off'" out of the code, it does work.

I checked the code with php codecheckes but everything seems fine.
don't know where this goes 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: Friday 10 May 2019 22:17
sincze wrote: Friday 10 May 2019 20:00
Trigun wrote:
he guys just found out that when I have the following code in _cron60, the auto off for just Bijkeuken does not work.

Code: Select all

<?php
lg('this is __cron60'); 

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

if ($d['Garageportaal']['s']=='On'&&$d['PIR-Garageportaal']['s']=='Off'&&past('Garageportaal')>60) {
	sw('Garageportaal', 'Off');
}
?>
but when I leave "&&$d['PIR-Bijkeuken']['s']=='Off'" out of the code, it does work.

I checked the code with php codecheckes but everything seems fine.

and for Garageportaal it works fine

don't know where this goes wrong
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 »

Check the status and name of the pir in the devices table. If that's the question, hard to find the new posts in all these quotes.
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 11 May 2019 5:28
I triple checked the device name but there is no difference.
I did change the cron.sh file as I didn't need most of the lines(so I thought), see attached.
2019-05-11 08_25_55-_var_www_html_secure_cron.sh - Domoticz-NEW! - Editor - WinSCP.png
2019-05-11 08_25_55-_var_www_html_secure_cron.sh - Domoticz-NEW! - Editor - WinSCP.png (39.63 KiB) Viewed 1721 times
so basically when I keep the

Code: Select all

&&$d['PIR-Bijkeuken']['s']=='Off' 
out of the code, it does work.

this is a mystery to me.
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 »

Hi Guys,

just wanted to let you know that I got both Garageportaal and Bijkeuken working.
I guess there was something in the devicenames that was wrong so I renamed Bijkeuken to Berging and it all works amazing! :)

Thank you for all you efforts in helping me out with this issue!
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 »

hahaha :lol: you figured it out nice!

I always copy the name from domoticz directly, in case of a missing " " (space) or something.
Just updated my install to the described cron.php and now all is working without cache :D
Also rewrote the crontab to use the /usr/bin/nice functionality/

Code: Select all

# Check if Domoticz is still running else restart
#  */1 * * * *   root    /home/pi/domoticz/scripts/system/domoticzmonitor.sh  >/dev/null 2>&1                           # Monitor if Domoticz is still running 
  * * * * *     root    /usr/bin/nice -n20 /home/pi/domoticz/scripts/system/domoticzmonitor.sh  >/dev/null 2>&1         # Monitor if Domoticz is still running
 */2 * * * *    root    /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/pass2php_include/cron.php?cron120" >/dev/null 2>&1
 0 * * * *      root    /usr/bin/nice -n20 curl -s "http://127.0.0.1/secure/pass2php_include/cron.php?cron3600" >/dev/null 2>&1
I use a bit of a different directory stucture but that does not matter.

Did not find out where in his code @egregius did hide the calling of _cron300.php (the 5 minute cron).
Cron Working.JPG
Cron Working.JPG (18.05 KiB) Viewed 1711 times
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: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Pass2PHP

Post by Egregius »

Cron300 is called the same way as cron120 but then with */5
Only cron10 and cron60 are called from within the cron.sh script.
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 »

Yeah thought so as well.

Check:
https://github.com/Egregius/PHP-Floorpl ... re/cron.sh

The example of the crontab in the first few lines may be a bit 'misleading' for the new guys as the /5 is missing :lol:
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: 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 just added those yesterday...
And new guys have to search and learn a bit so they understand the concept.
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 »

Egregius wrote:I just added those yesterday...
And new guys have to search and learn a bit so they understand the concept.
Image

Yes with the concept in mind it is indeed easier to figure out what goes wrong and why. It just came to my attention. :)


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 »

Hi Guys,

still fiddling around with PHP, its getting better and better.
perhaps you can explain to me why the following script is doing exactly the opposite.

Code: Select all

<?php
$items=array('Dimmer-Woonkamer-Achter','Dimmer-Woonkamer-Voor','Dimmer-Woonkamer-TV' );
foreach ($items as $item)
    if ($d['Woonkamer']['s']=='On') {
    sw($item, 'On');
}
If I switch Woonkamer On, nothing happens. If I switch Woonkamer off, everything the items are going On :shock:
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 »

Is this a device script or a cron script?

If it's a device script I would change $d['Woonkamer']['s'] to $status because $d holds the previous status, not the new one.

Code: Select all

<?php
if ($status=='On') {
	$items=array('Dimmer-Woonkamer-Achter','Dimmer-Woonkamer-Voor','Dimmer-Woonkamer-TV' );
	foreach ($items as $item) {
		sw($item, 'On');
	}
}
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: Wednesday 15 May 2019 13:57
Works like a charm, thanks a lot! :D
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'm working on the floorplan to use Ajax instead of just refreshing the whole page.
Before I just did a reload of the page every 3 seconds resulting in 6,7KB each 3 seconds. That's 137KB per minute.
Now the basic stuff is loaded initially and other stuff is fetched 4 times every second (250 msec) resulting in a realtime view of the home with less data. That's done with just 64KB.
Of course when on mobile internet I set the refresh 'slower' to once every second, then there's only 16KB of data needed.
The javascript must be expanded a lot, for now switches, dimmers, thermometers, pirs and contacts are in realtime. Will continue with the other stuff :-)
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 »

Almost finished. And damn, it's fast :twisted:
When I enter a room with a motion sensor, watching the floorplan, I see the light earlier on the floorplan than in reality. I like it :lol:
Trigun
Posts: 390
Joined: Wednesday 30 November 2016 11:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Pass2PHP

Post by Trigun »

Deleted due to not paying attention
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 »

Hi all,

please pay attention when installing phpmyadmin with apt-get install phpmyadmin.
when doing so, it will also install apache2 as it is one of the recommendations.

of course this is not a problem when you want to use apache but when you have also installed NginX you have two webservers enabled.

please use sudo apt-get --no-install-recommends install phpmyadmin

with this method you can use NginX as being the main webserver.
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 »

Friend of mine has a GoodWe inverter and wanted me to monitor his 32 panels.

Had to create a Pass2PHP solution ofcourse :lol: btw.. it can be used by non Pass2PHP users, but with PHP.

https://github.com/sincze/Domoticz/blob ... Goodwe.php
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 »


Hi Sincze,

What does it do?
I have a goodwe inverter as well and am curious


Sent from my iPhone using Tapatalk
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest