LUUP, Weather Underground, and Irrigation Control

I apologize if this is found in another thread but I been looking for ways to implement this for a week now and over many threads and i am just not getting there. The biggest problem is with my lack of the LUUP or LUA code knowledge. Here is what i am trying to do. I’m not asking someone to do it for me, but some pointers, tips, etc would be great.

I have a remotec Zwave dry contact device http://www.zwaveproducts.com/Zwave-Lighting/Zwave-Wall-Switches/Remotec-15-Amp-Dry-Contact-Module.html
I have a Vera Lite controller
Signed up for weather undergrounds api and installed. (getting data just fine into vera lite)
I have an 8 zone indexing valve that is controlled by one 24V valve
I would like to set up a schedule to:
-run automatically on a schedule i set (likely mon, weds, and sat)
-If it is raining or if rain is forecast for the day, do not trigger the schedule
-Because of the way the valve is setup i need the schedule to be as follows (T is in mins):
Zone 1: T=0 ; close contact
Zone 1: T=20 ; open contact
Zone 2: T=21 ; close contact
Zone 2: T=41 ; open contact
Zone 3: T=42 ; close contact
Zone 3: T=62 ; open contact

and so on.

I know i can get close in the UI of Vera Lite but I would have to set up multiple scenes and schedules but then i don’t know how to group all of those scenes together in order to trigger or not trigger based on the weather.

this is my first dealing with LUUP and i have done some research but have had no success. I have a small programming background but since I’m electrical, it has mostly disappeared since college.

Thanks again in advance and if i need to provide any more info don’t hesitate to comment.

There are a few options … each has it’s pros and cons.

Doing these timing events in Scenes and LUA is likely to be the more difficult and the least stable. If Vera restarts during you timing cycle … it will just stop there … and that could be in a mode with the Valve left open … and not cycling.

I assume you command the Valve on for the 8 * 21 minutes to water your yard.

I will suggest using the Program Logic Event Generator plugin to control you system. You could also use a couple of Countdown timer plugins and a number of scenes.

Lets focus on the actual control first … We can always stop the sequence and/or inhibit the sequence after we get the basics going.

In PLEG you can create schedules and triggers.
We should have the following triggers:

WaterValveOpen When the device controlling the water valve is Open
StepperPulseOn When the stepper is powered

Then the following conditions:
CycleON WaterValveOpen or (WaterValveOpen AND (CycleON; NOW > 21:00))
CycleOFF (StepperPluseOn; NOW > 59)
WaterOFF WaterValeOpen and (WaterValeOpen; NOW > 1:48)

Connect an action to each of the conditions:
CycleON Command to Turn on the device to engage your stepper
CycleOFF Command to Turn off the device to engage your stepper
WaterOFF Command to Turn off the water valve.
[hr]
At this point in time you have a manually initiated, auto stepper system. Turn on the water valve … and it will immediately advance to the next zone … and switch ON every 20 minutes. and off 1 minute later. At the end of stepping through 8 zones (1:40 minutes) it will shut off the water … this also stops the stepper cycles. If you stop it mid cycle … I will also stop the stepper … So when you start … it will advance to the next zone and proceed. No matter how you stop … it will make sure it ends the stepper sequence with the power off.
[hr]
Now Lets automate the start of the process.
This might take a couple of PLEG schedues to indicate your start times … Use what ever # it takes … These will all have names … The simplest is something like Nightly at 10:00 PM … good soak time with minimal evaporation … We will call it Nightly:

Add A condition to the same PLEG to start the valve.

WaterON Nightly OR Schedule2 OR …

Add an action to this condition:
WaterON Command to Turn on the water valve.
[hr]
Now we have the watering system automated.
But we want to inhibit it if forecast or actual rain … and stop it if it actually starts to rain.

The hardest part here is do a boolean expression from the output of the Weather Plugin to make that decision. You can use PLEG to bind Variables to the Weather plugin and express these boolean expressions based on string and or numerical values.

I will leave that task as an exercise for you … Ultimately we will define a condtion
Raining to be true.

We then modify the above expressions as follows:

WaterON (Nightly OR Schedule2 OR … ) and (not Raining)
WaterOFF WaterValeOpen and ((WaterValeOpen; NOW > 1:40) or Raining)
[hr]
You now have a watering solution with NO lua code (unless it’s need to determine if it’s raining) and that will survive a Vera Restarts …

Thank you so much for your very detailed reply. PLEG is likely exactly what I need. I have installed it but when i click on any of the configuration tabs, it says, “Opening PLEG_Inputs” or “Opening PLEG_Outputs” and will not load. I have given it a good few minutes each time. I have uninstalled the plugin, rebooted the device, reinstalled the plugin, then rebooted again and i am still having the issue. Clicked on the help section and went here: Program Logic Event Generator - Vera Plugin but didn’t find anything about the issue. AND to prove that i have done some research on it, i was going to contact the owner of the plugin BUT that seems to be you!

I hope you can help me once again get it working. Here are some details on my unit:
I am running firmware version UI5 1.5.408 on a micasa verde lite
Any other info needed, please let me know.
Thanks again in advance.

You also need to install the Program Logic Core plugin.

So I have been playing around with the code and I have hit a snag. I dont know how to turn the system off after the schedule has been run and NOT turn on again until the next schedule trigger. My conditions always land me in an infinite cycle. One of the troubles i am having is that my actual situation is a little different than how you interpreted it. I am sure because i did a terrible job at explaining it. I’ll try again AND past the stuff i have done so far.

I have one of these: https://www.fimcomfg.com/products/hydro-indexing-valve/ the animation helps explain a lot. The Zwave relay i have will turn on and off an electrically actuated 24V valve that will then allow the water to flow as seen in the animation. You’ll see that the indexing valve works much like a ball point pen. I also dont have a separate stepper. When the relay is closed, water flows and indexes the valve, when the water is stopped, the plunger rises and is ready for the next gush of water that will index the valve to the next zone. So all i am doing is controlling a single contact to turn on 8 times and off 8 times. I know that i can also use your app to use absolute times but i like the fact that i could set up a schedule and only have to modify that if i ever want to change my run times, etc.

So going back to the code. Here is what I have:

Inputs:
WaterOn - Sprinkler Relay is turned on
WaterOff - Sprinkler Relay is turned off
Rain - Weather Underground: Condition Group is ‘Rain’

Schedule:
MWS4AM - Schedule to run everyM, W, and S at 4 AM

Conditions:
ZoneDone (WaterOn; NOW > 19:30) (I gave it 19:30 because I saw that the NOW condition is only evaluated every min. this way i can insure that the bit will toggle)

ZoneWait (WaterOff; NOW >50) Same reason for the 50 seconds here. Also a note. I could make the wait time anything around a min. It takes about 30 seconds for the pressure in the indexing valve to reduce enough to step to the next zone. If you don’t wait long enough, it will not step and will run the same zone again.
WaterTheLawn ((MWS4AM) AND (NOT Rain) AND (Rain; NOW < 04:00:00)) Condition so that the schedule only runs if it in not surrently raining and has not rained in the past 4 hours.

Actions:
ZoneDone - Turn off the Sprinkler Relay
ZoneWaitt - turn on the Sprinkler Relay
WaterThe Lawn - Turn on the Sprinkler relay based on the schedule conditions

Now i need some condition so that it turns off the sprinkler relay after a total time of 2:47:00 from the first time the relay is turned on AND make it so that the program doesn’t run again until the next schedule OR i manually run it.

this is where i am getting stuck. I was thinking i could use a zonecounter and everytime ZoneWait occurs it would add 1 to the counter and when it reached 8 i could use the NOT of that as an AND logic with the ZoneWait condition since the action of ZoneWait is to turn ON the Sprinkler relay, but i am not sure if that is possible. (WaterOff; NOW >50) AND (NOT ZoneCounter). So that statement would be true until the ZoneCounter reached 8, then it would revert back to 0 and not step through the cycle anymore. I was also trying to make a way to have a Cycle Done using a conditional statement like: (WaterOn or WaterOff); NOW > 02:47:00 and use the NOT of that condition in the ZoneWait condition. This would be saying…if the relay has been on or off for less than 2 hours and 47mins, then the ZoneWait would fire, otherwise it wouldnt.

the problem is, in my case, unlike the one you presented, i have to toggle that relay contact and because of that, i dont know how to keep track of how long it has been since it first fired. In your example it was much easier because the “WaterValveOpen” stayed 1 the entire time until we wanted to kill the procedure.

As you can see, i am probably missing a simple use of the tools to make this happen. Thanks for the help so far. I just need that little bump to the finish.

I don’t know whether this helps you or not, but you could create a scene that is triggered by the Z-Wave relay being turned ON. The scene would have a delay of 167 minutes at which time it would set the Z-Wave relay to OFF.

Thanks for the post but i think i will need to make a condition change as well because the loop would still run. The PLEG plugin would see that the relay was off and after 50 secs, it would just turn back on and continue the loop. BUT, i may be misunderstanding some basic functions of the PLEG app. Thanks again for the reply.

Also, does anyone know why such a niche forum like this requires 3 independent forms of verification to post EVEN after you have logged in?

OHHH. i thought about it more and i think you may be on to something there. Hopefully i can do something like that in PLEG. Let me tinker around. Thanks again for the help!

Correction:

WaterTheLawn ((MWS4AM) AND (NOT Rain) AND (Rain; NOW [glow=red,2,300]>[/glow] 04:00:00))

You need:

ZoneWait (WaterOff; NOW >50) and ((AutoOn; NOW < 2:47:00) or (ManualOn; NOW < 2:47:00))
AutoOn WaterOn and (WaterTheLawn;WaterOn < 2:47:00);
ManualOn WaterOn and (WaterTheLawn;WaterOn > 3:00:00);

I would recommend watering a little earlier … You want the water to soak well before the Sun comes up and starts the evaporation process.
If you start at 4:00 AM you finish at 6:40 AM … In the summer the Sun is already coming up.

Can we set day night indicators with this plugin?

I appreciate all the help you gave before. I had to take a break during travel for work and i have been working on this still. It still isnt functioning the way i need it to but i am sure it is because of my conditions/code/syntax. I saw this on your site and i wasn’t sure if i may be having the problem because of this.
UI5 has a bug with events with more than 1 condition variables in scenes. Two of my events have 2 condition variables. If you want to use these, email me, I can tell you how to patch your UI5 to work. I have provided fixes to MCV. I hope they will integrate these soon.
i have quite a number of condition variables. Based on what you know of my conditions and the info that i have presented so far, do you think that any problems may be related to this?

One of the most basic problems i am having is that the sequence isn’t starting when the schedule triggers it. It seems to be working well changing zones correctly if i manually start the relay by Vera or by the actual button. Because we have actually had rain recently. I haven’t tested it through the entire 3 hour cycle so i cannot verify that it will stop running the zones correctly at the end. I will eventually get there but right now, i’m stuck on getting it to start.

I am also having a problem scoping the code you provided here:
ZoneWait (WaterOff; NOW >50) and ((AutoOn; NOW < 2:47:00) or (ManualOn; NOW < 2:47:00))
AutoOn WaterOn and (WaterTheLawn;WaterOn < 2:47:00);
ManualOn WaterOn and (WaterTheLawn;WaterOn > 3:00:00);

I believe AutoOn is saying AutoOn=1 when the sprinkler relay is on AND WaterTheLawn follows the sprinkler relay by less than 2 hours and 47 mins.
likewise with ManualOn is saying ManualOn=1 when the sprinkler relay is on AND WaterTheLawn follows the sprinkler relay by more than 3 hours.

But i am missing the intent. I know one is to determine if i have manually started the irrigation cycle or if it is started by the schedule but i am not bright enough to figure out how.

Man, as crappy as industrial basic is, if i could just use that for programming the automation of my Vera, i could do so many things. But i am having such a hard time with the learning curve of this stuff. Your app is very powerful and i am sure i can do so many things with it. I am just not catching on ???

So i kinda started over here and was wondering if this might work as well.

ZoneDone (WaterOn; NOW > 19:30)
ZoneStart ((WaterOff; NOW > 50) AND (NOT CycleDone))
Schedule ((MWS3AM) AND (NOT Rain) AND (Rain; NOW > 04:00:00))
CycleDone (OneZoneOnly OR (WaterOn @ 8 < 03:00:00) OR OffTime)

I am using:
weatherunderground for the Rain input
A virtual input toggle to indicate if i just want to water one zone. (i have a flower bed that needs more water sometimes and this way i can just toggle that input for it to stop after the one zone)
I also have a schedule called OffTime set for 5:47 AM (2 hours and 47 mins after the MWS3AM start time) as a fail safe.

How does one go about requesting an enhancement to the Wunderground plugin to provide actual precipitation information. That would be one way I’d like to determine if irrigaiton is necessary.

Please see the response to the thread you created asking this question.

  • Garrett

Sorry, I did not explain myself sufficient. This thread is an example of similar requirements, whereby the conditions should already be reported in the plugin. They are covered to a minor degree in the wiki link below…
http://code.mios.com/trac/mios_weather
There are numerous requests to set this function to action and review previous sub threads in the group below:
http://forum.micasaverde.com/index.php/board,42.0.html
The main thread is here and this is where you could request enhancement but this is covered already…
http://forum.micasaverde.com/index.php/topic,1435.0.html
It is now a matter of tying this all together and implementing which hopefully happens the first attempt - good luck and have fun.

[quote=“mbc2237, post:13, topic:174939”]So i kinda started over here and was wondering if this might work as well.

ZoneDone (WaterOn; NOW > 19:30)
ZoneStart ((WaterOff; NOW > 50) AND (NOT CycleDone))
Schedule ((MWS3AM) AND (NOT Rain) AND (Rain; NOW > 04:00:00))
CycleDone (OneZoneOnly OR (WaterOn @ 8 < 03:00:00) OR OffTime)

I am using:
weatherunderground for the Rain input
A virtual input toggle to indicate if i just want to water one zone. (i have a flower bed that needs more water sometimes and this way i can just toggle that input for it to stop after the one zone)
I also have a schedule called OffTime set for 5:47 AM (2 hours and 47 mins after the MWS3AM start time) as a fail safe.[/quote]

I know this is an old thread, but I found it because I’m in exactly the same boat - an indexing valve that needs to be switched on for 20 minutes, off for one, for each of three zones.
I’m wondering if you’d mind sharing where you got to with this? I’m new to PLEG, but can really see the power in it - I’m convinced that once I get this example working, I’ll be able to rework some of my other scenes into a more elegant PLEG setup.

I set up the weatherunderground plugin, got the API key working, and it appears to be correct.
In the PLEG device I have one schedule:

DailyCycle Weekly:1,2,3,4,5,6,7 21:00

I then set up three triggers, identical to yours, and I understand that these essentially become variables I can use in the conditions:
WaterOn Sprinkler Pump is turned on
WaterOff Sprinkler Pump is turned off
Rain World Weather: Condition Group is ‘Rain’

From there, I’m kind of lost on how to set up the conditions to drive the final behaviour I’m looking for:

[ul][li][font=verdana][size=1em]At 9pm start the pump, unless one of the following is true: [[/size][/font][font=verdana][size=small]it’s raining] or [it has rained in the last four hours] or [I’ve set a one-day override e.g. for a BBQ evening][/size][/font][/li]
[li][font=verdana][size=1em]After 20 minutes, stop the pump[/size][/font][/li]
[li][font=verdana][size=1em]Wait one minute, start the pump[/size][/font][/li]
[li][font=verdana][size=1em]Repeat until all three zones have completed[/size][/font][/li][/ul]
I’d also like to be able to run the pump manually when I’m doing maintenance, to test new sprinkler heads or clear the lines. I’m guessing I need perhaps a virtual switch for that, to prevent the WaterOn from triggering? Or can I just check if the pump is coming on outside normal schedule hours, and realise it’s a manual test?

Thanks for any help,
Geoff

i still haven’t got mine working correctly. We are truly in the same boat. I have tried different methods but none of them elegant and none of them actually working the way i would like. If i could simply write some industrial basic code i could do it. I need to use nested if-then statements. The problem is that everything is like a slow state machine since things are evaluated once a min. i can easily get the cycle to start, stop, pause, and start again. the problem is stopping everything once all zones are done. i have tried using the PLEX counter function and the if X happens in Y time functions but i still can’t get them to behave properly. I have given up and moved on for the time being with the intent to eventually just buy a standard, read crappy, sprinkler timer. If you get anywhere, please let me know…Also, if you are truly going to work on this, i will dust off what i have done as well and maybe we can figure it out.

I was just thinking the exact same thing about how it’s really just a state machine. This makes sense, since it’s what gives it the ability to survive a restart. The problem is needing to keep track of which cycle it is up to; I’m not sure how to have that survive a system restart.
I’m guessing that a PLTS would help simplify things, but I’ve only just started digging. I’ll look at this a bit more tonight.
Cheers,
Geoff

PLEG, PLTS, and Countdown timer plugins all retain state across a Vera restart.
This is critical for anything the runs for a while … and where inappropriate operation can cost you $$$$ in terms of failed hardware or inefficient utilization of resources.

The examples above use PLEG for managing the State machine.