[SOLVED] OpenSprinkler Irrigation and Cascading timers rule

A sleep of that amount of time is a pretty bad idea. It’s less so in a Timer. The problem is by default Timers only have two threads to run in. If you have other Rules with Timers, cron triggers or Astro triggers and you have two long running Timers, those may be delayed until the other Timers complete. Better to use a Timer, but in this case I’m not sure of the full impact.

If you have problems I recommend a minor change:

    // Create a timer to turn off curr valve and start the next valve
    irrigationTimer = createTimer(now.plusMinutes(currValveMins.intValue), [ |
        //logInfo("Irrigation", "Turning off " + currValve.name)
        currValve.sendCommand(OFF)
	
        irrigationTimer = createTimer(now.plusSeconds(5), [ |
            if(nextValve !== null) {
                //logInfo("Irrigation", "Turning on " + nextValve.name)
                Irrigation_Curr.postUpdate(nextValve.name)
                nextValve.sendCommand(ON) // causes the Irrigation Cascade rule to trigger
            }
            else {
                //logInfo("Irrigation", "Irrigation is complete")
                Irrigation_Manual.sendCommand(OFF) // causes the cancel rule to trigger for cleanup
            }
            irrigationTimer = null
        ])
    ])

Another more thorough approach would be Design Pattern: Gate Keeper which is probably overkill for this case.

I’m not suggesting you change anything, just providing something to try should the long sleep become a problem. Make sure to test that the cancels work properly if you do make the change.