Rules#Timer and eventvalue
Moderators: grovkillen, Stuntteam, TD-er
Rules#Timer and eventvalue
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.
I've 6 partially parallel running timer, which mostly execute the same actions.
Re: Rules#Timer and eventvalue
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.
Re: Rules#Timer and eventvalue
Example (current):
My idea:
With 6 timer I could save some rule-code
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
Code: Select all
On Rules#Timer do
Event,CloseValve=%eventvalue%
LogEntry,ValveClose %eventvalue%
Let,%eventvalue%,0
EndOn
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules#Timer and eventvalue
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rules#Timer and eventvalue
I'm a bit surprised this isn't available as %eventvalue%
Re: Rules#Timer and eventvalue
@TD-er: You think it should work?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules#Timer and eventvalue
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rules#Timer and eventvalue
I'll change my rule this evening and report the result here...
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules#Timer and eventvalue
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rules#Timer and eventvalue
Nice... The feature is added, before I asked for it
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules#Timer and eventvalue
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.
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules#Timer and eventvalue
You can do it like this too:
So you could send it to different events by name.
Code: Select all
On TEST1EVENT Do
logentry,HELLO
EndOn
On Rules#Timer Do
Event,TEST%eventvalue%EVENT
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules#Timer and eventvalue
Or this one:
Every other run the corresponding variable will be 1 and 0 (alternating).
Code: Select all
On TESTEVENT Do
logentry,%eventvalue%
EndOn
On Rules#Timer Do
Let,%eventvalue%,[INT#%eventvalue%#!Z]
Event,TESTEVENT=[INT#%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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rules#Timer and eventvalue
Works great for me too. ~600byte rule-code saved
Re: Rules#Timer and eventvalue
That's always nice to see some code duplication was prevented
Who is online
Users browsing this forum: Bing [Bot] and 49 guests