Page 1 of 1

Rule for watering cycles

Posted: 31 Aug 2019, 10:03
by Sigalou
Hello,
I start with the rules and I need your help to understand.
I would like with the instruction "On Clock # Time = All, 22:00 o'clock" to launch 5 launch loops of 3 watering zones (2 min each).
I can do Zone 1 ON and zone 1 OFF


on Clock # Time = All, 22:00 pm
Launch cycle 1/5:
* Launch Zone 1 on for 2 minutes (zone 3 off)
* Launch Zone 2 on for 2 minutes (zone 1 off)
* Launch Zone 3 on for 2 minutes (zone 2 off)
Then same thing cycle 2/5
Then same thing cycle 3/5
Then same thing cycle 4/5
Then same thing cycle 5/5

Can you help me ? or orient myself.
Thank you

Re: Rule for watering cycles

Posted: 31 Aug 2019, 11:05
by TD-er
Please have a look at using timers: https://espeasy.readthedocs.io/en/lates ... g-examples

Re: Rule for watering cycles

Posted: 02 Sep 2019, 21:49
by Sigalou
Thank you for your advice, I went to see and sought to understand.
Hello friends, here's what I did, it works. Do you think we can do more simple?
Thank you for your valuable advice.

Code: Select all

on Clock#Time=All,22:00 do
  let,1,1  // compteur de boucles (de 3 zones) de 1 à %v2%
  let,2,5  // nombre de boucles (de 3 zones) 
  let,3,120  // temps d'arrosage de chaque zone en secondes
  timerSet,5,1  //Initialise le Timer 1 à 1s
  gpio,15,1 // Relais4=ON
endon

On Rules#Timer=5 do // Zone1=ON // Zone3=OFF
   gpio,12,1 // Relais1
   gpio,4,0  // Relais3
   timerSet,6,%v3%  // Lance timer 2 dans %v3% secondes 
endon

On Rules#Timer=6 do // Zone1=OFF   // Zone2=ON
   gpio,12,0 // Relais1
   gpio,5,1  // Relais2
   timerSet,7,%v3%  // Lance timer 3 dans %v3% secondes
endon

On Rules#Timer=7 do // Zone2=OFF // Zone3=ON
   gpio,5,0  // Relais2
   gpio,4,1  // Relais3
   timerSet,8,%v3%  // Lance timer 4 dans %v3% secondes
endon

On Rules#Timer=8 do 
      if %v1%<%v2% do 
        let,1,%v1%+1  
        timerSet,5,1  //Lance timer 5
      else
        gpio,15,0 // Relais4=OFF
        gpio,4,0  // Relais3
      endif
endon

Re: Rule for watering cycles

Posted: 03 Sep 2019, 00:15
by TD-er
Looks quite clean to me, but I'm not the expert on rules here :)
Glad to see you came up with this by just reading the docs. So apparently those are really helpful so it seems.

Re: Rule for watering cycles

Posted: 03 Sep 2019, 04:53
by grovkillen
Thumbs up from me. That's clean :D

Re: Rule for watering cycles

Posted: 03 Sep 2019, 10:30
by dynamicdave
The only comment I would make (from my experience of using 'rules') would be to place the timerSet,5,1 as the last statement.
i.e. interchange the position of timerSet,5,1 and gpio,15,1

Code: Select all

On Clock#Time=All,22:00 do
  let,1,1  // compteur de boucles (de 3 zones) de 1 à %v2%
  let,2,5  // nombre de boucles (de 3 zones) 
  let,3,120  // temps d'arrosage de chaque zone en secondes
  timerSet,5,1  //Initialise le Timer 1 à 1s
  gpio,15,1 // Relais4=ON
endon

Re: Rule for watering cycles

Posted: 03 Sep 2019, 13:13
by grovkillen
dynamicdave wrote: 03 Sep 2019, 10:30 The only comment I would make (from my experience of using 'rules') would be to place the timerSet,5,1 as the last statement.
i.e. interchange the position of timerSet,5,1 and gpio,15,1

Code: Select all

On Clock#Time=All,22:00 do
  let,1,1  // compteur de boucles (de 3 zones) de 1 à %v2%
  let,2,5  // nombre de boucles (de 3 zones) 
  let,3,120  // temps d'arrosage de chaque zone en secondes
  timerSet,5,1  //Initialise le Timer 1 à 1s
  gpio,15,1 // Relais4=ON
endon
Yep,, thanks Dave, it's good practice to do so.

Re: Rule for watering cycles

Posted: 03 Sep 2019, 13:21
by Sigalou
Merci à tous, thank you all