Rules#Timer and eventvalue

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Rules#Timer and eventvalue

#1 Post by Micha_he » 05 May 2020, 10:06

Is it possible to use one 'Rules#Timer' trigger and use the timer# in %eventvalue% ?

I've 6 partially parallel running timer, which mostly execute the same actions.

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

Re: Rules#Timer and eventvalue

#2 Post by TD-er » 05 May 2020, 10:30

Micha_he wrote: 05 May 2020, 10:06 I've 6 partially parallel running timer, which mostly execute the same actions.
You can create your own events and fire them from rules.
Consider it like calling a function in normal programming languages.
So if you place the 'same actions' in a separate event block and just fire that event, then you may be able to reduce code duplication.

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Rules#Timer and eventvalue

#3 Post by Micha_he » 05 May 2020, 11:18

Example (current):

Code: Select all

On Rules#Timer=1 do
  Event,CloseValve=1
  LogEntry,ValveClose 1
  Let,1,0
EndOn

On Rules#Timer=2 do
  Event,CloseValve=2
  LogEntry,ValveClose 2
  Let,2,0
EndOn

On Rules#Timer=3 do
  Event,CloseValve=3
  LogEntry,ValveClose 3
  Let,3,0
EndOn
My idea:

Code: Select all

On Rules#Timer do
  Event,CloseValve=%eventvalue%
  LogEntry,ValveClose %eventvalue%
  Let,%eventvalue%,0
EndOn
With 6 timer I could save some rule-code ;)

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

Re: Rules#Timer and eventvalue

#4 Post by grovkillen » 05 May 2020, 12:16

Your wish is a good feature request. I mean why wouldn't the timer event also have an event value that could be used?
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:

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

Re: Rules#Timer and eventvalue

#5 Post by TD-er » 05 May 2020, 12:18

I'm a bit surprised this isn't available as %eventvalue%

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Rules#Timer and eventvalue

#6 Post by Micha_he » 05 May 2020, 12:43

@TD-er: You think it should work?

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

Re: Rules#Timer and eventvalue

#7 Post by grovkillen » 05 May 2020, 12:57

Yes it should work that way.
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:

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Rules#Timer and eventvalue

#8 Post by Micha_he » 05 May 2020, 12:58

I'll change my rule this evening and report the result here...

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

Re: Rules#Timer and eventvalue

#9 Post by grovkillen » 05 May 2020, 13:18

I just tested this on current code base and it worked just fine.

Code: Select all

On TESTEVENT Do
 logentry,%eventvalue%
EndOn

On Rules#Timer DO
  Event,TESTEVENT=%eventvalue%
Endon
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:

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Rules#Timer and eventvalue

#10 Post by Micha_he » 05 May 2020, 13:30

Nice... The feature is added, before I asked for it :)

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

Re: Rules#Timer and eventvalue

#11 Post by grovkillen » 05 May 2020, 13:32

I've been using it like that but for custom events, not the timer event. I thought you had tested it and found a bug/missing feature. :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
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules#Timer and eventvalue

#12 Post by grovkillen » 05 May 2020, 13:36

You can do it like this too:

Code: Select all

On TEST1EVENT Do
 logentry,HELLO
EndOn

On Rules#Timer Do
  Event,TEST%eventvalue%EVENT
EndOn
So you could send it to different events by name.
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
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rules#Timer and eventvalue

#13 Post by grovkillen » 05 May 2020, 13:47

Or this one:

Code: Select all

On TESTEVENT Do
 logentry,%eventvalue%
EndOn

On Rules#Timer Do
  Let,%eventvalue%,[INT#%eventvalue%#!Z]
  Event,TESTEVENT=[INT#%eventvalue%]
EndOn
Every other run the corresponding variable will be 1 and 0 (alternating).
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:

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Rules#Timer and eventvalue

#14 Post by Micha_he » 06 May 2020, 11:19

Works great for me too. ~600byte rule-code saved :)

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

Re: Rules#Timer and eventvalue

#15 Post by TD-er » 07 May 2020, 00:14

Micha_he wrote: 06 May 2020, 11:19 Works great for me too. ~600byte rule-code saved :)
That's always nice to see some code duplication was prevented :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 49 guests