Page 50 of 76
Re: Pass2PHP
Posted: Sunday 09 June 2019 17:06
by sincze
Trigun wrote: ↑Sunday 09 June 2019 16:17
Hi Sincze,
What does it do?
I have a goodwe inverter as well and am curious
Sent from my iPhone using Tapatalk
Friend of mine wanted to be added to my Solar Monitoring installation.
Script does 2 things for me:
1. My friend has a GoodWe inverter and I need the data. So I created this script to scrape the data from the GoodWe server and store it in my Domoticz / Influx / Grafana.
2. As my friend does not have Pass2PHP I added a few functions to the script so he can store the data in his Domoticz as well. (He does not have Pass2PHP).
Now everybody is happy.
I did the same before for SunnyPortal, Omnik and Growatt inverters.

Re: Pass2PHP
Posted: Sunday 09 June 2019 17:29
by Trigun
[/quote]:[/quote]
Ok that sounds good!! Does it give me more data than when I have a P1 cable attached to my smart meter? Please don’t get me wrong, I’m a big fan
Sent from my iPhone using Tapatalk
Re: Pass2PHP
Posted: Sunday 09 June 2019 20:00
by sincze
It will give you the exact amount of Watts the inverter is producing every minute.
Your P1 only shows
- usage
- inverter - Usage....
So by using P1 you loose precious production data.
On a sunny day You will see return but not the usage!
Still following me on this one?

Re: Pass2PHP
Posted: Tuesday 11 June 2019 7:21
by Trigun
sincze wrote:It will give you the exact amount of Watts the inverter is producing every minute.
Your P1 only shows
- usage
- inverter - Usage....
So by using P1 you loose precious production data.
On a sunny day You will see return but not the usage!
Still following me on this one?

Ok, cool! I’ll definitely give it a go to see how it works
Sent from my iPhone using Tapatalk
Re: Pass2PHP
Posted: Thursday 04 July 2019 16:40
by DarkAllMan
Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dt' in 'field list'
Code: Select all
function fetchdata()
{
global $db;
$stmt=$db->query("select n,i,s,t,m,dt,icon from devices;");
while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
$d[$row['n']] = $row;
}
return $d;
}
Ik mis de dt creatie:
Code: Select all
CREATE TABLE IF NOT EXISTS `devices` (
`n` varchar(50) NOT NULL,
`i` smallint(6) DEFAULT NULL,
`s` varchar(500) DEFAULT NULL,
`t` int(11) DEFAULT NULL,
`m` varchar(500) DEFAULT NULL,
PRIMARY KEY (`n`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Re: Pass2PHP
Posted: Thursday 04 July 2019 16:44
by sincze
It seems the
https://github.com/Egregius/PHP-Floorpl ... tabase.txt is not up to date.
I did not use dt column so did not notice it.
Re: Pass2PHP
Posted: Thursday 04 July 2019 17:38
by Egregius
True that
Updated with
Code: Select all
ALTER TABLE `devices` ADD IF NOT EXISTS `dt` VARCHAR(20) NULL AFTER `m`;
ALTER TABLE `devices` ADD IF NOT EXISTS `icon` VARCHAR(20) NULL AFTER `dt`;
This fields are only used by my ajax based floorplan. If you only use Pass2PHP for automation you don't need them.
Re: Pass2PHP
Posted: Monday 08 July 2019 13:36
by DarkAllMan
I think the fields should be able to be NULL. Otherwise you get errors on other functions.
The update statement did not work for me, but at least I know the field types.
Re: Pass2PHP
Posted: Wednesday 10 July 2019 17:04
by Trigun
Hi All,
Perhaps someone can help me out with a bit of PHP in combination with Pass2PHP.
I have a weather station which measures also Rain and have automated my garden sprinklers.
Also, I have pass2php setup which works great for PIRS I have ATM.
Now I would like to extend to the next feature but have no idea how to write this in PHP.
I would like to establish that when it has rained in the last 12 hours, the sprinklers should NOT turn on.
If it hasn't rained in the past 12 hours, the sprinklers should turn on.
Within domoticz I have set a time that the sprinklers turn on at 5AM every morning.
Is there a chance someone can help me out?
Much appreciated!
thnx!
Re: Pass2PHP
Posted: Wednesday 10 July 2019 17:26
by sincze
If you have a sensor for Rain that has a timestamp when it was the last time it has rained (mm in weatherstation) you could work with that. ? Or you could also just store the timestamp of last rain detection and work with that?
Do you want to keep the connection to 5AM and 12 hours or is the 12 hours leading and we forget about the 5AM ??
This is not for my sprinklers... but for sun-screens.

- Rain.png (21.25 KiB) Viewed 14973 times
Re: Pass2PHP
Posted: Wednesday 10 July 2019 21:20
by Trigun
[/quote]
Jep I got one. I have a Netatmo weather station which gives me the following.

- rain.JPG (25.72 KiB) Viewed 14972 times
how does that work? can I use it with pass2php?
ideally I would like to stick with the 5am as this is the most ideal time to water the lawn (just before sunrise)

the 12 hours might change.
is this possible?
Re: Pass2PHP
Posted: Thursday 11 July 2019 6:58
by Egregius
something like this in a one of the cron files:
Code: Select all
<?php
if (TIME>=strtotime('5:00')&&TIME<strtotime('6:00')&&past('BANO_Outdoor-Rain')>43200&&$d['Rain expected']['s']=='Off'&&past('Water')>43200&&$d['Water']['s']=='Off') {
sw('Water', 'On');
}
if ($d['Water']['s']=='On'&&past('Water')>900) {
sw('Water', 'Off');
}
Re: Pass2PHP
Posted: Thursday 11 July 2019 9:30
by Trigun
Egregius wrote: ↑Thursday 11 July 2019 6:58
something like this in a one of the cron files:
Code: Select all
<?php
if (TIME>=strtotime('5:00')&&TIME<strtotime('6:00')&&past('BANO_Outdoor-Rain')>43200&&$d['Rain expected']['s']=='Off'&&past('Water')>43200&&$d['Water']['s']=='Off') {
sw('Water', 'On');
}
if ($d['Water']['s']=='On'&&past('Water')>900) {
sw('Water', 'Off');
}
I think that's it, Thank you Egregius!
But I have a few questions to understand.
TIME>=strtotime('5:00')&&TIME<strtotime('6:00') --> does this mean: when time is between 5am and 6am? (this is a new function for me, sorry

)
('BANO_Outdoor-Rain')>43200&&$d['Rain expected']['s']=='Off'&&past('Water')>43200&&$d --> I don't have A "rain expected" sensor but I guess if Bano Rain is >43200 it will work right?
if ($d['Water']['s']=='On'&&past('Water')>900) { --> this means the sprinklers will be on for 15 minutes?
sw('Water', 'Off');
Re: Pass2PHP
Posted: Thursday 11 July 2019 9:50
by Egregius
I'll split the code in severall lines for you
Code: Select all
<?php
if (TIME>=strtotime('5:00') // If time of day is later than 5am
&&TIME<strtotime('6:00')// And if time of day is before 6am
&&past('BANO_Outdoor-Rain')>43200 // And if BANO_Outdoor-Rain hasn't been updated in the last 43200 seconds (12 hours)
&&$d['Rain expected']['s']=='Off' // And if there's no rain expected
&&past('Water')>43200 // And the water hasn't been turned on in the last 12 hours
&&$d['Water']['s']=='Off' // And the water is off
) {
sw('Water', 'On'); // Switch on the water
}
if ($d['Water']['s']=='On' // If the water is on
&&past('Water')>900 // And it's on for more than 900 seconds (15 minutes)
) {
sw('Water', 'Off'); // Turn off the water
}
Re: Pass2PHP
Posted: Thursday 11 July 2019 9:57
by Egregius
DarkAllMan wrote: ↑Monday 08 July 2019 13:36
I think the fields should be able to be NULL. Otherwise you get errors on other functions.
The update statement did not work for me, but at least I know the field types.
True, changed my post and the script.
Re: Pass2PHP
Posted: Thursday 11 July 2019 10:59
by Trigun
Egregius wrote: ↑Thursday 11 July 2019 9:50
I'll split the code in severall lines for you
Thank You!
I can definitely work with this

Re: Pass2PHP
Posted: Thursday 11 July 2019 11:54
by Trigun
BTW, I believe the first part is for a PHP file and the second part for a cron file right?
Re: Pass2PHP
Posted: Thursday 11 July 2019 12:24
by Egregius
No, both go in one of the pass2php cron files.
Re: Pass2PHP
Posted: Thursday 11 July 2019 12:49
by Trigun
Egregius wrote: ↑Thursday 11 July 2019 12:24
No, both go in one of the pass2php cron files.
aah ok. so what I did is:
Created a _cron3600.php file which runs every hour in a crontab with:
Code: Select all
if (TIME>=strtotime('5:00')&&TIME<strtotime('6:00')&&past('BANO_Outdoor-Rain')>43200&&past('Tuinsproeiers')>43200&&$d['Tuinsproeiers']['s']=='Off') {
sw('Tuinsproeiers', 'On');
}
and I added the following to a the _cron60.php file which runs every minute in a crontab:
Code: Select all
if ($d['Tuinsproeiers']['s']=='On'&&past('Tuinsproeiers')>3600) {
sw('Tuinsproeiers', 'Off');
}
Re: Pass2PHP
Posted: Friday 12 July 2019 22:15
by Trigun
Hi Guys,
Just received two more Pir's combining those two with pass2php works great!
I was just wondering, I know to to switch a light on and off but how does it work with a dimmer?
for example when I enter the bathroom I want the lights to be at 50% instead of of full on.
I thought this would dol the trick but nothing happens.
I used this for PIR_Badkamer in a php file
Code: Select all
<?php
if($status=='On'&&TIME<strtotime('21:00')) {
sw('Badkamer','50%', true);
}
and this in a cron file.
Code: Select all
if ($d['Badkamer']['s']=='On'&&$d['PIR_Badkamer']['s']=='Off'&&past('Badkamer')>60) {
sw('Badkamer', 'Off');
}
thanks for your help guys!