Page 1 of 1

Garden watering

Posted: Monday 22 May 2017 19:31
by JuanUil
Hi Folks,

I have automated my garden watering but I am facing a problem:
I have a rainmeter and a uservariable "regenteller"
what I want is this:
when there has been no rain during the past 24 hours (derived from my rainmeter) the uservariable should be risen with 1.
when I make a script in lua where I say
if (regenmeter==0 and hour == 23 and minute== 10) then

the uservariable gets raised with about 60 (all minute 10)

when I include seconds the update sometimes fails and regenteller i not raised.

Is there a way to simply raise regenteller with 1 when there was no rain and the time is at a certain point?

thanks for your replies

Jan

Re: Garden watering

Posted: Monday 22 May 2017 20:34
by Lorccan
(I think I understand you, but do post back if not!)

If your conditional test is correct, you just need to say:

regenteller = regenteller+1

If you need to use another variable to increase the value of regenteller, you need to ensure that you round up or down so that it's also an integer:

regenteller = regenteller+math.floor(othervariable)

Re: Garden watering

Posted: Monday 22 May 2017 21:22
by JuanUil
Hi Lorccan,

Thnx for your reply.
I do exactly what you said:
regenteller is regenteller+1

the problem is that during minute 10 regenteller is raised constantly with 1 until minute is 11 so regenteller is then 60 or so.
When I include the seconds so hour==23 minutes==10 and seconds ==1 then sometimes there is no raisng of regenteller.

jan

Re: Garden watering

Posted: Monday 22 May 2017 21:55
by Lorccan
Ah, got it!

How about making a dummy switch that you turn on once a day with a timer (e.g. At sunset). Then you use a device script to catch the 'On', check your rain meter, increment the var if necessary. You can then either switch the dummy off in the script or have an auto off after some seconds in its definition.

Re: Garden watering

Posted: Tuesday 23 May 2017 6:43
by Egregius
Why not retrieve the history of your rainmeter and go from there?
I'm currently also developing something for this. All tough I don't have a rainmeter.
My plan is to store the rain predection, an average of 3 weather providers, in a SQL table. Grab the data of the last 48 hours. That combined with the rain prediction of the next 48 hours should be good enough to decide if the garden needs water or not.

Re: Garden watering

Posted: Tuesday 23 May 2017 9:28
by zicht

Code: Select all

time = os.date("*t")
if((time.min % 3)==0)then

     >>>>  yourthing to fo with if then else and counter comes here'
     regenteller=regenteller +1

end
The above works ever 3 minutes but you can use it for whatever interval you have in mind.
Just change 3 to 10 in your case.
Make sure it is in a TIME script otherwise it would fire during the minute every time a device reports it status.

Hope this helps !

Re: Garden watering

Posted: Tuesday 23 May 2017 12:24
by JuanUil
Thanx zicht,

that works. As soon as I have the code completew I will post it so that evrybody can use it

Jan