Jump to content

Question about the repeat command


Blackbird

Recommended Posts

Posted (edited)

The logic is being continuously evaluated. If it ever become False Then stops running and Ese starts running.

 

You could set a variable true/false and test that with Repeat While $sVariable = $cTrue

 

You could use one program to initiate on a cyclic basis the other with conditions.

 

 

You cannot have more than one condition is a Repeat While, though.

 

BTW: The Repeat Every is a bt of misnomer. Your loop will happen every 2 hours and 10 minutes.

 

 

10 minutes is a lot of water once the ground gets wet! I did this years ago with an X10 system and used 3, 2 or 1 minutes, depending on the brightness in the house. Then I didn't cycle at all at nights. Grass grew so fast that a neighbour commented on the speed.

Edited by larryllix
Posted (edited)

Okay, this thread has me a little confused.  I wrote this little program to demonstrate my question. 

 

I want to water in some grass seed on the back lawn that suffered some winter/dog damage.  Is there a way, within this program, to have the repeat clause reevaluate the conditions in the "if" statement prior to each repeat cycle (the climate module stuff is dynamic and would optimally be reevaluated each time the program repeats)?  I was fairly certain that the "if" clause isn't reevaluated with each repeat cycle, but suddenly I'm unsure about that.  Normally, I'd use one program to call other programs based on values from the climate module to accomplish this.  Is that correct?

BackLawnReSeed - [ID 008A][Parent 0089]

If
        From     7:00:00AM on 2017/05/05
        To      10:00:00PM on 2017/05/20
    And (
             From    Sunrise +  4 hours 
             To      Sunset  -  1 hour  (same day)
         And (
                  Module 'Climate' Temperature > 50 °F
              And Module 'Climate' Total Rain Today < 0.2 "
              And Module 'Climate' Wind Speed < 15 mph
             )
        )
 
Then
        Repeat Every  2 hours 
           Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Start
           Wait  10 minutes 
           Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Stop
 
Else
   - No Actions - (To add one, press 'Action')
 

Thanks in advance.  This forum is invaluable!

 

I want to say that your program as is will not work.

 

During a wait or repeat, the "if" clause is open to being re-triggered.  So any item in the "if" clause that triggers on a status change will re-trigger the program.  I do believe this includes climate module value changes.  Does this program work currently?  I would expect it to not work since I would expect if the temp changed that the program would re-trigger and start over.

 

Ie, during the 10 minutes wait, temp changes by one degree, program restarts from scratch and enters the 10 minute wait again (or worse, it now is false and the lawn keeps getting watered until the next day).  Then, lets say the first 10 minute ends and now it is waiting for the 2 hour repeat, but temp changes again, so now program starts all over.

 

Generally a program like this needs a trigger program (that just has the time constraints) and a second program with the just the weather module stuff.  

 

If

time constraints

and

weather module program is true

Then

water routine

Else

Stop watering   

 

weather module program

 

if

weather module constraints

Then

blank

Else

blank

 

At this point, if the weather module program becomes false, it will re-trigger the main program and it now runs false shutting down the sprinkler.

 

In summary, you can't use "repeat while" since you have multiple parameters, so you use a second program.

Edited by apostolakisl
Posted

The logic is being continuously evaluated. If it ever become False Then stops running and Ese starts running.

 

You could set a variable true/false and test that with Repeat While $sVariable = $cTrue

 

You could use one program to initiate on a cyclic basis the other with conditions.

 

 

You cannot have more than one condition is a Repeat While, though.

 

BTW: The Repeat Every is a bt of misnomer. Your loop will happen every 2 hours and 10 minutes.

 

 

10 minutes is a lot of water once the ground gets wet! I did this years ago with an X10 system and used 3, 2 or 1 minutes, depending on the brightness in the house. Then I didn't cycle at all at nights. Grass grew so fast that a neighbour commented on the speed.

I originally figured I would put the climate data into variables that a second program would check before running.  I may still do that, but I thought I'd give this program a whirl after reading this thread and see how it behaved.  You're right, this might be too much water.  I just wrote this program this morning, figuring I'd adjust it before long.

 

I want to say that your program as is will not work.

 

During a wait or repeat, the "if" clause is open to being re-triggered.  So any item in the "if" clause that triggers on a status change will re-trigger the program.  I do believe this includes climate module value changes.  Does this program work currently?  I would expect it to not work since I would expect if the temp changed that the program would re-trigger and start over.

 

Ie, during the 10 minutes wait, temp changes by one degree, program restarts from scratch and enters the 10 minute wait again (or worse, it now is false and the lawn keeps getting watered until the next day).  Then, lets say the first 10 minute ends and now it is waiting for the 2 hour repeat, but temp changes again, so now program starts all over.

 

Generally a program like this needs a trigger program (that just has the time constraints) and a second program with the just the weather module stuff.  

 

If

time constraints

and

weather module program is true

Then

water routine

Else

Stop watering   

 

weather module program

 

if

weather module constraints

Then

blank

Else

blank

 

At this point, if the weather module program becomes false, it will re-trigger the main program and it now runs false shutting down the sprinkler.

 

In summary, you can't use "repeat while" since you have multiple parameters, so you use a second program.

The program ran for the first time this morning, right when I expected it would (four hours after sunrise).  As I was typing this response, the program fired again, though not when I expected it to, so it appears you're correct about climate data changes re-triggering the "if" clause (the wind speed was the value that changed).

 

And yes, I definitely want to shut the water off!

 

It fired off this morning and caught the dog out in the yard doing her business, so at the very least I've gotten a laugh out it!

 

This has been very helpful.  Back to the drawing board...

Posted

The usual and safe way to circumvent triggers (the we need to star a process) from stopping the process is to creat two programs.

 

-Use one (enabled) to see all the triggers and call the second program from it.

-Use a second program with any further wanted conditions (maybe twoo different timers or processes) and a timer that ensures the job will complete.

-Disable program Two from any trigger influence.

Posted (edited)

The usual and safe way to circumvent triggers (the we need to star a process) from stopping the process is to creat two programs.

 

-Use one (enabled) to see all the triggers and call the second program from it.

-Use a second program with any further wanted conditions (maybe twoo different timers or processes) and a timer that ensures the job will complete.

-Disable program Two from any trigger influence.

 

This case is different though.

 

You do want the weather module triggers to stop the watering, but ONLY if they change to a value outside of the designated range.  You want it to be looked at as the entire set of parameters as being either true or false and only a change from the entire thing true to false or false to true is a trigger, not every incidental change.

 

You do this by using the true/false status of the program containing the weather module info as the trigger.  The program stays true no matter how many times the temp or wind or whatever changes, so long as it stays within range.  And it will trigger the sprinkler to stop sprinkling if it changes to a value out of range. 

Edited by apostolakisl
Posted

That's exactly what I described and almost every effect / action can fall into.

 

Program Water.initiater

If

...trigger conditions (could be a list of daily times)

Then

....Wait a while to be sure

....run program water cycler (if)

....disable self (optional with same below)

Else

....

 

Program water cycler (disabled)

If

....lots of water needed (based on brightness and/or wind/temperature conditions etc.

............................. Outside humidity maybe best)

Then

....disable Water.initiate

....turn on water

....wait 5 minutes

....turn off water

....wait 55 minutes

....enable Water.initiate

Else

....disable Water.initiater

....turn on water

....wait 1 minute

....turn off water

....wait 4 hours

....enable Water.initiater

Posted

This is the exact program that does what you intended.

BackLawnReSeed - [ID 008A][Parent 0089]

If
        From     7:00:00AM on 2017/05/05
        To      10:00:00PM on 2017/05/20
    And (
             From    Sunrise +  4 hours 
             To      Sunset  -  1 hour  (same day)
    And Program 2 is true

Then
        Repeat Every  2 hours 
           Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Start
           Wait  10 minutes 
           Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Stop
 
Else
        Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Stop
 
Program 2

If
       
                  Module 'Climate' Temperature > 50 °F
              And Module 'Climate' Total Rain Today < 0.2 "
              And Module 'Climate' Wind Speed < 15 mph
 
Then
   - No Actions - (To add one, press 'Action')       
 
Else
   - No Actions - (To add one, press 'Action')
 

Any false trigger in the main program turns off the water or prevents it from starting.

 

False triggers include the aggregate of your weather module conditions becoming false.

You end times (sunset or your hard times).

 

It will also turn on with a true trigger.  So, your aggregate of weather conditions become true between the designated times.  Or your designated start time while the weather conditions are already true.

  • Like 1
Posted

This case is different though.

 

You do want the weather module triggers to stop the watering, but ONLY if they change to a value outside of the designated range.  You want it to be looked at as the entire set of parameters as being either true or false and only a change from the entire thing true to false or false to true is a trigger, not every incidental change.

 

You do this by using the true/false status of the program containing the weather module info as the trigger.  The program stays true no matter how many times the temp or wind or whatever changes, so long as it stays within range.  And it will trigger the sprinkler to stop sprinkling if it changes to a value out of range. 

You described the problem exactly.  I've never used the true/false status of a program as a trigger, and I don't recall seeing that technique described before (though maybe I just haven't paid enough attention).  I do see how this can solve some thorny conditional problems in other areas, such as lighting schedules being affected by occupancy.

Posted

That's exactly what I described and almost every effect / action can fall into.

 

Program Water.initiater

If

...trigger conditions (could be a list of daily times)

Then

....Wait a while to be sure

....run program water cycler (if)

....disable self (optional with same below)

Else

....

 

Program water cycler (disabled)

If

....lots of water needed (based on brightness and/or wind/temperature conditions etc.

............................. Outside humidity maybe best)

Then

....disable Water.initiate

....turn on water

....wait 5 minutes

....turn off water

....wait 55 minutes

....enable Water.initiate

Else

....disable Water.initiater

....turn on water

....wait 1 minute

....turn off water

....wait 4 hours

....enable Water.initiater

I understand how this would work.  This is a variation of what I was thinking before I started reading this thread and confused myself. 

 

BTW, outside humidity where I live tends to swing quite a bit in the spring, with very localized rain and sun conditions.  The weather station I use in the climate module is close, but not that close, and I don't need a great deal of precision with this application (the affected area is small).

Posted

This is the exact program that does what you intended.

BackLawnReSeed - [ID 008A][Parent 0089]

If
        From     7:00:00AM on 2017/05/05
        To      10:00:00PM on 2017/05/20
    And (
             From    Sunrise +  4 hours 
             To      Sunset  -  1 hour  (same day)
    And Program 2 is true

Then
        Repeat Every  2 hours 
           Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Start
           Wait  10 minutes 
           Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Stop
 
Else
        Set 'Devices / dirNodeServers / RainMachine / RainMachine / Rear Lawn' Stop
 
Program 2

If
       
                  Module 'Climate' Temperature > 50 °F
              And Module 'Climate' Total Rain Today < 0.2 "
              And Module 'Climate' Wind Speed < 15 mph
 
Then
   - No Actions - (To add one, press 'Action')       
 
Else
   - No Actions - (To add one, press 'Action')
 

Any false trigger in the main program turns off the water or prevents it from starting.

 

False triggers include the aggregate of your weather module conditions becoming false.

You end times (sunset or your hard times).

 

It will also turn on with a true trigger.  So, your aggregate of weather conditions become true between the designated times.  Or your designated start time while the weather conditions are already true.

I like this, and you've taught me something here.  I'm currently building out my (somewhat simplistic) HA installation by putting in a ELK system, along with a variety of occupancy sensors.  One of the questions I've started thinking about is how to use occupancy sensors in conjunction with lighting schedules, trying to make sure that lights don't get left on unnecessarily, while simultaneously not throwing people into the dark, all the while maintaining a good lighting ambience in the house.  This gives me a way to start solving that problem, too. 

 

Thanks.  I'll put this into production and watch my grass grow!

Posted

The only issue you may have with this is that your weather module program has no hysteresis.  So, if one of the parameters were bouncing around at the threshold level that program would keep switching back and forth.

 

The one I fear the most on that issue is wind.  You might consider dropping wind from it.  Temp and rain aren't likely to bounce.

 

To add hysteresis you would add a third program that has the other end of a range that is a sort of no man's land.

 

 

 

 

Hysteresis 1

If

wind speed is less than 15

then

$state.windspeed = 1

 

Hysteresis 2

If 

wind speed is greater than 20

$state.windspeed = 0

 

In the above example, wind speed variable become true (1) when it is less than 15, and false when it is more than 20.  In between those values, it retains its previous value.  So you would use the variable in your weather program instead of the direct wind speed.

Posted (edited)

Another good idea.  The bouncing would be somewhat mitigated by the 300 second polling interval I have in climate module, but I think I'll add your hysteresis programs so I'll have the idea codified somewhere in my ISY.  I know this will help trigger another solution for me somewhere in the future.  Truth be told, I've never paid much attention to the "status" value of programs before.  Very handy.

 

Thanks again, this is very helpful.

Edited by Bumbershoot
Guest
This topic is now closed to further replies.

×
×
  • Create New...