Page 49 of 76

Re: Pass2PHP

Posted: Friday 10 May 2019 20:00
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

Re: Pass2PHP

Posted: Friday 10 May 2019 22:17
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

Re: Pass2PHP

Posted: Friday 10 May 2019 22:18
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

Re: Pass2PHP

Posted: Saturday 11 May 2019 5:28
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.

Re: Pass2PHP

Posted: Saturday 11 May 2019 8:32
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 1742 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.

Re: Pass2PHP

Posted: Saturday 11 May 2019 14:15
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!

Re: Pass2PHP

Posted: Saturday 11 May 2019 15:49
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 1732 times

Re: Pass2PHP

Posted: Saturday 11 May 2019 18:09
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.

Re: Pass2PHP

Posted: Saturday 11 May 2019 18:36
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:

Re: Pass2PHP

Posted: Saturday 11 May 2019 19:41
by Egregius
I just added those yesterday...
And new guys have to search and learn a bit so they understand the concept.

Re: Pass2PHP

Posted: Saturday 11 May 2019 19:52
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


Re: Pass2PHP

Posted: Wednesday 15 May 2019 13:26
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:

Re: Pass2PHP

Posted: Wednesday 15 May 2019 13:57
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');
	}
}

Re: Pass2PHP

Posted: Thursday 16 May 2019 11:26
by Trigun
Egregius wrote: Wednesday 15 May 2019 13:57
Works like a charm, thanks a lot! :D

Re: Pass2PHP

Posted: Friday 17 May 2019 4:33
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 :-)

Re: Pass2PHP

Posted: Friday 17 May 2019 13:35
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:

Pass2PHP

Posted: Thursday 30 May 2019 13:51
by Trigun
Deleted due to not paying attention

Re: Pass2PHP

Posted: Sunday 02 June 2019 12:15
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.

Re: Pass2PHP

Posted: Saturday 08 June 2019 21:01
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

Re: Pass2PHP

Posted: Sunday 09 June 2019 16:17
by Trigun

Hi Sincze,

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


Sent from my iPhone using Tapatalk