little rule fan bathroom timerset ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bledad
Normal user
Posts: 86
Joined: 23 Nov 2020, 10:57
Location: France

little rule fan bathroom timerset ?

#1 Post by bledad » 06 Apr 2024, 10:01

hello,
i want wait 30mn after humidity <65 when the gpio 12 is on
but no work
my rules

Code: Select all

Let,1,0
on sonde#Humidity<65 do
  if [var#1]=1
    Timerset,1,1800 // wait 30mn before gpio 12,0
     Let,1,0
   endif
    gpio,12,0
  
endon
on sonde#Humidity>75 do
  gpio,12,1
  Let,1,1
endon

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: little rule fan bathroom timerset ?

#2 Post by Ath » 06 Apr 2024, 10:43

Hm, it seems some of the concepts of rules aren't clear to you, you can read about that in the documentation on rules.

- Rules are pieces of code that are triggered by events from ESPEasy
- Events are f.e. generated on every Interval of a device task, like your humidity sensor, or from system events, like the timer you want to set
- The variables ([var#1] / %v1% etc.) are initially set to 0 on system start
- Code outside of an event handler (on xxx do/endon) is not executed, and can possibly confuse the rules engine
- Arguments passed to the event handler are available from %eventvalue1%..%eventvalueX% variables, and are the value at the time the event was generated (events are often queued)

Your request could be handled by this code:

Code: Select all

on sonde#humidity do // Update/refresh on current humidity value
  if %v1%=1 and %eventvalue1%<65
    TimerSet,1,1800 // 30 minute timer started
    let,1,0 // Don't restart the timer
  endif
  if %eventvalue1%>75
    gpio,12,1 // Turn on fan
    let,1,1 // Keep fan on for some more time
    TimerSet,1,0 // Kill the timer if already started
  endif
endon
on rules#timer=1 do // Timer 1 has expired
  gpio,12,0 // Turn off fan
endon
/Ton (PayPal.me)

bledad
Normal user
Posts: 86
Joined: 23 Nov 2020, 10:57
Location: France

Re: little rule fan bathroom timerset ?

#3 Post by bledad » 06 Apr 2024, 11:28

thank , I'm trying to understand , my english it's verry bad

%eventvalue1% = sonde#humidity ? because it is in on -- endon ?
timerset as always "on rules#timer=x do " for expired timer ?

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: little rule fan bathroom timerset ?

#4 Post by Ath » 06 Apr 2024, 11:35

bledad wrote: 06 Apr 2024, 11:28 thank , I'm trying to understand , my english it's verry bad
You can use the translation features of Chrome to translate the documentation ;)
bledad wrote: 06 Apr 2024, 11:28 %eventvalue1% = sonde#humidity ? because it is in on -- endon ?
timerset as always "on rules#timer=x do " for expired timer ?
Yes, the number in %eventvalueN% points at the Nth argument passed to the event
and Yes, the number of timers is 'limited' to ~255, so that shouldn't be a problem :lol:
/Ton (PayPal.me)

bledad
Normal user
Posts: 86
Joined: 23 Nov 2020, 10:57
Location: France

Re: little rule fan bathroom timerset ?

#5 Post by bledad » 06 Apr 2024, 17:40

ok ,thank's , I need to understand the logic of espeasy

exemple , i try a slide gate security by watt detection
device > PZEM-004T interval 1s
LongPulse_mS,14,1,600 > impulse sens < -- >
if > 100 watt start detection timer 3s
after 3s if watt > 400 then secu event ( impulse - wait 2s -impulse)
and more pieton button start open - wait 5s - stop with impulse

Code: Select all

On System#Boot Do
  Let,1,0
Endon

On gr#Power_W Do
 If [gr#Power_W] > 100 and [Var#1]= 0 // si w > 100 pause 3s et var 1 = 0
   Timerset,3,3
   //Let,1,1
 endif	
 If [gr#Power_W] > 400 and [Var#1]= 1 // si w > 400 et var 1 = 1 securite
   Event,secu
 endif
 If [gr#Power_W] < 5 and [Var#1]= 1 // si w < 5 = arret var1 mis a 0
	Let,1,0
  resetenergy,0
 Endif
Endon

On Rules#Timer=3 Do
  Let,1,1
Endon

On secu Do
   LongPulse_mS,14,1,600 // impulsion arret
  TimerSet,2,1
Endon

On Rules#Timer=2 Do
   Let,1,0
   LongPulse_mS,14,1,600 // impulsion retour
Endon

On piet#State Do
  If [piet#State]=0
    Let,1,0
    LongPulse_mS,14,1,600 // impulsion pieton 5s
    TimerSet,1,5
  Endif  
Endon

On Rules#Timer=1 Do
   LongPulse_mS,14,1,600 // impulsion pieton arret
   Let,1,0
   resetenergy,0
Endon
what are my mistakes ??
thank

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: little rule fan bathroom timerset ?

#6 Post by Ath » 07 Apr 2024, 14:20

bledad wrote: 06 Apr 2024, 17:40 exemple , i try a slide gate security by watt detection
device > PZEM-004T interval 1s
LongPulse_mS,14,1,600 > impulse sens < -- >
if > 100 watt start detection timer 3s
after 3s if watt > 400 then secu event ( impulse - wait 2s -impulse)
and more pieton button start open - wait 5s - stop with impulse
That's a totally different use-case, AFAICS, you could have started a new thread for this.
It starts to look like a school assignment we're solving for you, correct?
bledad wrote: 06 Apr 2024, 17:40 what are my mistakes ??
Have you read the general suggestions I gave in a previous message? As you didn't apply them... :?
What does your script not do, that it's supposed to do? We don't have the hardware available to replay this scenario.
/Ton (PayPal.me)

bledad
Normal user
Posts: 86
Joined: 23 Nov 2020, 10:57
Location: France

Re: little rule fan bathroom timerset ?

#7 Post by bledad » 07 Apr 2024, 15:21

That's a totally different use-case, AFAICS, you could have started a new thread for this.
ok I'll open a new post
t starts to look like a school assignment we're solving for you, correct?
i've 65 year , retired , I left school at 15 , self-taught , that's why my english is bad, even with the translations.
thank you for your understanding

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 19 guests