Rule for watering cycles

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Sigalou
New user
Posts: 9
Joined: 23 Jul 2019, 21:39

Rule for watering cycles

#1 Post by Sigalou » 31 Aug 2019, 10:03

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
Sigalou

Utilisateur/Développeur Plugin Jeedom
Créateur des plugins Alexa-API & WatchDog



TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Rule for watering cycles

#2 Post by TD-er » 31 Aug 2019, 11:05

Please have a look at using timers: https://espeasy.readthedocs.io/en/lates ... g-examples

User avatar
Sigalou
New user
Posts: 9
Joined: 23 Jul 2019, 21:39

Re: Rule for watering cycles

#3 Post by Sigalou » 02 Sep 2019, 21:49

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
Sigalou

Utilisateur/Développeur Plugin Jeedom
Créateur des plugins Alexa-API & WatchDog



TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Rule for watering cycles

#4 Post by TD-er » 03 Sep 2019, 00:15

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.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rule for watering cycles

#5 Post by grovkillen » 03 Sep 2019, 04:53

Thumbs up from me. That's clean :D
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Rule for watering cycles

#6 Post by dynamicdave » 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

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rule for watering cycles

#7 Post by grovkillen » 03 Sep 2019, 13:13

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.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
Sigalou
New user
Posts: 9
Joined: 23 Jul 2019, 21:39

Re: Rule for watering cycles

#8 Post by Sigalou » 03 Sep 2019, 13:21

Merci à tous, thank you all
Sigalou

Utilisateur/Développeur Plugin Jeedom
Créateur des plugins Alexa-API & WatchDog



Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests