Fish pond pump script

Moderator: leecollings

Post Reply
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Fish pond pump script

Post by D3LTA »

Anyone here knows if there is a Fish pond pump script that deals with time and weather data?

i searched everywhere and also tried making my own from some heating scripts but without any luck and working script....

what i'm looking for is a script that sets on the pond pump x time (for example 2 hours and then off) at a x interval (example 2 hours on and 1 hours off and repeats that )

and if the temperature is below a x variable (like 0 degrees) it will not turn in on at all of turns is on continuously

i truly hope some of you could help me out or can give me some examples to work with.

(made serveral bash and python scripts, but i can't seem too figure out this one)

thanks alot
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Fish pond pump script

Post by zicht »

In Lua, just give youre some idea;s to get you started with the timing :

Code: Select all

time = os.date("*t")
put the time/date table in variable time

Code: Select all

 if (time.hour==7 or time.hour==19) and time.min==0 then ....pump on or off  ..... end
time.hour contains the hours of time.
time.min contains the minite of time

Code: Select all

if ((time.min% 2)==0) then ..... end
would run every 2 minutes, this can also be done with time.hour.

Dont forget to load the table in time (first sentence)
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Re: Fish pond pump script

Post by D3LTA »

thanks for the push in right direction.. will give it a shot tonight.. is it okay if i post my progress here.. so you can maybe help me out a little?
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Fish pond pump script

Post by zicht »

D3LTA wrote: Sunday 24 September 2017 18:25 thanks for the push in right direction.. will give it a shot tonight.. is it okay if i post my progress here.. so you can maybe help me out a little?
See PM and yes you can post it here if you made something, that way others can benefit or think together with you
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Fish pond pump script

Post by Egregius »

With pass2php times are quite easy:

Code: Select all

<?php
$temp=status('temperature');
$pump=status('pump');
if($temp>25){
	//To hot, let's pump continuosly
	if($pump!='On')sw('pump','On');
}elseif($temp>0){
	//Normal temp
	if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
	elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
}else{
	//It's freezing cold, don't pump at all
	if($pump!='Off')sw('pump','Off');
}
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Re: Fish pond pump script

Post by D3LTA »

Egregius wrote: Monday 25 September 2017 6:13 With pass2php times are quite easy:

Code: Select all

<?php
$temp=status('temperature');
$pump=status('pump');
if($temp>25){
	//To hot, let's pump continuosly
	if($pump!='On')sw('pump','On');
}elseif($temp>0){
	//Normal temp
	if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
	elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
}else{
	//It's freezing cold, don't pump at all
	if($pump!='Off')sw('pump','Off');
}
that looks very good indeed, but how does it get the var temp and pump? are those the names in domoticz ?

i can read the script and understand it.. but can you explain the "timestamp".. is that a persistant value? or does it read the time variables from domoticz? ("last seen")

How do i implement it?
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Fish pond pump script

Post by Egregius »

Yes, the names of Domoticz.
You'll need to get pass2php running. All the magic happens there.
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Re: Fish pond pump script

Post by D3LTA »

thats no problem, please help me understand the script (timestamps) as i have no php knowledge.

is it also possible to store values? because for example if it freezes for 2 days, and temp gets above 0 again.. it takes for example 5 days before the pump can start again because the ice needs to melddown.
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Re: Fish pond pump script

Post by D3LTA »

realy hope you or someone willing to make this a working script... i just don't have the knowledge..yet.. :cry:
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Fish pond pump script

Post by Egregius »

you can store custom variables with the setstatus() function and read them with the status() function of pass2php.
You could (for example) set a variable 'hasfrozen' to the lowest frost temperature. pass2php automatically remembers the last set time of a var.

Didn't test this, but something like this could be a good direction:

Code: Select all

<?php
$temp=status('temperature');
$pump=status('pump');
if($temp>25){
	//To hot, let's pump continuosly
	if($pump!='On')sw('pump','On');
}elseif($temp>8){
	//Normal temp, let's cycle 2 hours on, 1 hour off	
	if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
	elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
}elseif($temp>0){
	//It's cold, did it freeze lately?
	$hasfrozen=status('hasfrozen');
	$hasfrozentime=timestamp('hasfrozen');
	if($hasfrozen<-20){
		//damned that was cold, lets wait 10 days
		if($hasfrozentime<time-(86400*10)){
			if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
			elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
		}
	}elseif($hasfrozen<-10){
		//damned that was cold, lets wait 5 days
		if($hasfrozentime<time-(86400*5)){
			if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
			elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
		}
	}elseif($hasfrozen<-5){
		//damned that was cold, lets wait 2 days
		if($hasfrozentime<time-(86400*2)){
			if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
			elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
		}
	}elseif($hasfrozen<0){
		//Just a litle frost, one day will do
		if($hasfrozentime<time-86400){
			if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
			elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
		}
	}else{
		//It didn't freeze, lets cycle
		if($pump=='On'&&timestamp('pump')<time-7200)sw('pump','Off');
		elseif($pump=='Off'&&timestamp('pump')<time-3600)sw('pump','On');
	}
}else{
	//It's freezing cold, don't pump at all
	if($pump!='Off')sw('pump','Off');
	$hasfrozen=status('hasfrozen');
	if($temp<$hasfrozen)setstatus('hasfrozen',$temp);
}
A lot of information of pass2php can be found at http://www.domoticz.com/forum/viewtopic ... 64&t=12343
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Re: Fish pond pump script

Post by D3LTA »

Thank you very much Egregius.. will give it a try

what will happen if it's -11 2 days in a row? it will just stay 5 days with every extra day its still freezing -11 ?
D3LTA
Posts: 24
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Twente
Contact:

Re: Fish pond pump script

Post by D3LTA »

Anyone willing to help debug and improve this script?

thanks in advance

Code: Select all

-- start lua commandarray  = schakel tabel waarin we opdrachten gaan geven
commandArray = {}  

------------------------------------------------------------
-- functie timedifference = functie di we  verderop aanroepen om te zien hoe lang pomp aan is of uit is.
------------------------------------------------------------
function timedifference (s)   --- tijdverschil bepalen sinds laatste schakeling in sec
   yearx=string.sub(s, 1, 4) monthx=string.sub(s, 6, 7) dayx=string.sub(s, 9, 10)
   hourx=string.sub(s, 12, 13) minutesx=string.sub(s, 15, 16) secondsx=string.sub(s, 18, 19)
   t1=os.time()  
   t2=os.time{year=yearx, month=monthx, day=dayx, hour=hourx, min=minutesx, sec=secondsx}
   difference=os.difftime (t1, t2)
   --print(s.." "..tostring(t).." "..tostring(difference))
   return difference
end

------------------------------------------------------------
-- zet de temperatuur in variable zodat we deze later als vooraarde kunnen laten dienen-- bepaal wat er moet gebeuren
------------------------------------------------------------
local temp = otherdevices_temperature['Temp Ground / Humidity (Twente)']  -- zet temp in waarde, en maak er n getal van ipv string
local laag= 0  -- min temp
local hoog= 25 -- max temp
local timediff=timedifference(otherdevices_lastupdate['vijver-pomp'])
local pompstatus=otherdevices['vijver-pomp']
local pompbeveiliging=false
------------------------------------------------------------
-- bepaal wat er moet gebeuren
------------------------------------------------------------
-- normaal
if temp>laag and temp<hoog then 
    max_uit = 3600     -- 3600 sec (1 uur)
    max_aan = 7200    -- 7200 sec (2uur)
end
-- warm
if temp>laag and temp>hoog then 
    max_uit = 1800       -- 1800 sec (30 min)
    max_aan = 10800    -- 10800 sec (3uur)
end
-- koud
if temp<laag and temp<hoog then 
    pompbeveiliging=true
else
    pompbeveiliging=false
end
------------------------------------------------------------
-- Doe wat er moet gebeuren normaal en warm
------------------------------------------------------------
if pompbeveiliging==false then      -- alleen schakelen als de pompbeveiliging niet actief is
    if otherdevices['pompstatus'] == 'Off' and timediff>max_uit then        -- aanzetten als uit en te lang uit
        commandarray['pompstatus']='On'
    end
    if otherdevices['pompstatus']== 'On' and timediff>max_aan then       -- uitzetten als aan en te lang aan.
        commandarray['pompstatus']='Off' 
    end
end
------------------------------------------------------------
-- Doe wat er moet gebeuren bij vorst
------------------------------------------------------------
if pompbeveiliging==true and otherdevices['pompstatus']=='On' then        -- als pompbeveiliging actief is en pomp aan dan pomp uitzetten
    commandarray['pompstatus']='Off'
end


return commandArray -- nu gaat domoticz wat we in commandarray hebben geplaatst ook werkelijk uitvoeren
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest