Moderators: grovkillen, Stuntteam, TD-er
-
budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
#1
Post
by budman1758 » 31 Dec 2017, 08:05
Howdy all. This is a part of my keypad project that I'm working on. Got the hardware issues pretty much settled and its working pretty well. I'm trying to make a certain thing happen and having a bit of trouble figuring out a rule sequence. I want ONE of three things to happen when I hit a certain key. Here is the rule as it is now.
Code: Select all
On Send Do
If [Dummy#TempCode]=38607.00
Event,Pin1
Endif
If [Dummy#TempCode]=55527.00
Event,Pin2
Else
Event,Clear
Endif
Endon
"Send is an event called from a certain scancode. Same as hitting "enter" after entering your pin code. I want ONLY one of the 3 events here to occur. As it is now if the code is good for "pin1" it calls that event AND the "clear" event. If the code is good for "pin2" it ONLY calls the pin2 event.
I suspect that the answer to this is quite simple but it eludes me. Hope this is enough info to help.
Happy New Year to all!!
Forum topic about the project.
viewtopic.php?f=2&t=3845
Github topic about the project.
https://github.com/letscontrolit/ESPEasy/issues/640
"The glass is twice as big as it needs to be".
-
grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
#2
Post
by grovkillen » 31 Dec 2017, 08:10
Since the rules engine is fairly simple in the ESP Easy FW I suspect that the event calls break the loop. Place the "Event, Clear" in the end of "Event,pin1" and "Event,pin2" instead of the event send as you have right now.
EDIT: I read that wrong. Let me think some more about it. In suspect you need to dump the value to a dummy in between...
EDIT2: I think my first thought is still valid. You want to clear the code once done? Just put the event clear in the end of all these events and you will trigger it correctly. In that case, remove the else part in your code and place the event clear right before "endon".
-
budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
#3
Post
by budman1758 » 31 Dec 2017, 08:25
grovkillen wrote: ↑31 Dec 2017, 08:10
Since the rules engine is fairly simple in the ESP Easy FW I suspect that the event calls break the loop. Place the "Event, Clear" in the end of "Event,pin1" and "Event,pin2" instead of the event send as you have right now.
EDIT: I read that wrong. Let me think some more about it. In suspect you need to dump the value to a dummy in between...
EDIT2: I think my first thought is still valid. You want to clear the code once done? Just put the event clear in the end of all these events and you will trigger it correctly. In that case, remove the else part in your code and place the event clear right before "endon".
Actually I don't want the clear event if the "pin" values are correct. I will start a timer to clear them from the "pin" events. I want clear called if the pin values are incorrect. Reason is to allow some time for the clear code event to happen. Say you open the door and then want to close it in within, say 2 minutes. That way you do not have to enter the code again. Just hit enter.

"The glass is twice as big as it needs to be".
-
grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
#4
Post
by grovkillen » 31 Dec 2017, 08:36
So maybe try to use a dummy that is checked at the end of the timer, as well as after a code is accepted. I mean, if the code is not correct then you clear straight away. If it is accepted it will clear after the timer is ended.
-
budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
#5
Post
by budman1758 » 31 Dec 2017, 09:16
I'm still trying to evaluate 3 things. The problem is the third thing could be any number. If this particular number or this particular number or this RANDOM number. How do you tell ESPEasy to call an event from a random value? Or set a dummy value from it?
"The glass is twice as big as it needs to be".
-
grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
#6
Post
by grovkillen » 31 Dec 2017, 09:46
I'd do it similar to what I did to evaluate color (
viewtopic.php?f=2&t=3021&p=15565#p17512) using TCS34725.
Code: Select all
On Send Do
If Dummy#PINaccepted>0 do
//Just open the door, PIN already accepted
Else
TaskValueSet,3,1,0 //Set to default not accepted PIN (Dummy#PINaccepted)
Endif
If [Dummy#TempCode]=38607.00
TaskValueSet,3,1,1 //This is an accepted PIN! (Dummy#PINaccepted)
Endif
If [Dummy#TempCode]=55527.00
TaskValueSet,3,1,1 //This is an accepted PIN! (Dummy#PINaccepted)
Endif
TaskValueSet,3,2,[Dummy#EvaluationComplete]+1 //This dummy is used to trigger the EvaluationComplete
Endon
On Dummy#EvaluationComplete do
If [Dummy#PINaccepted]>0
//Do whatever you want
Else
//Do whatever you want
Endif
timerSet,1,120 //set the timer to 2 minutes
Endon
On Rules#Timer=1 do
TaskValueSet,3,1,0
Endon
Something like this...?

I don't have your setup so this it strictly theoretical and must be seen as inspiration

-
budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
#7
Post
by budman1758 » 31 Dec 2017, 09:57
Let me attempt to wrap what few brain cells I have left around that for a bit.

Getting a bit late here. Time for me to get some shut eye. Thanks for all the help.
"The glass is twice as big as it needs to be".
-
grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
#8
Post
by grovkillen » 31 Dec 2017, 10:06
budman1758 wrote: ↑31 Dec 2017, 09:57
Let me attempt to wrap what few brain cells I have left around that for a bit.

Getting a bit late here. Time for me to get some shut eye. Thanks for all the help.
Sure, I understand that

Get some sleep and it will all be in your brain by tomorrow morning

-
Martinus
#9
Post
by Martinus » 31 Dec 2017, 10:38
It looks like you need a case/else condition structure like:
Code: Select all
Select Case
case 1
..
case 2
..
else
..
end
The simple rule engine does not have this, but you could mimic this behaviour in general using an extra dummy value like this:
Code: Select all
on test do
taskvalueset 3,2,0 // reset Dummy#Select
if [Dummy#Value] = 1
event case_one
taskvalueset 3,2,1
endif
if [Dummy#Value] = 2
event case_two
taskvalueset 3,2,1
endif
if [Dummy#Select] = 0
event case_else
endif
endon
Where Dummy is task 3 with two values:
1=Value
2=Select
So the Dummy#Select keeps track if something valid has been chosen. If no case matches, the value will remain 0 and the "case else" wil be executed
-
budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
#10
Post
by budman1758 » 31 Dec 2017, 22:04
Thanks for those suggestions. I think I found a simpler way. I rewrote the rule like this.
Code: Select all
On Send Do
Pulse,2,1,100
TimerSet,1,3
If [Dummy#TempCode]=38607.00
Event,Pin1
Endif
If [Dummy#TempCode]=55527.00
Event,Pin1
Endif
Endon
The pulse command flashes an led to indicate the keypress.
The timer when it ends calls the event to clear the codes.
The first thing the "goodpin" event does is reset the timer to what ever delay I want.
If no "good pin" entered then the clear event gets called in 3 seconds.
So far so good. Seems to be doing what I wanted. Amazing what a little brain cell refreshment will do.

"The glass is twice as big as it needs to be".
-
grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
#11
Post
by grovkillen » 31 Dec 2017, 22:31
budman1758 wrote: ↑31 Dec 2017, 22:04
Thanks for those suggestions. I think I found a simpler way. I rewrote the rule like this.
Code: Select all
On Send Do
Pulse,2,1,100
TimerSet,1,3
If [Dummy#TempCode]=38607.00
Event,Pin1
Endif
If [Dummy#TempCode]=55527.00
Event,Pin1
Endif
Endon
The pulse command flashes an led to indicate the keypress.
The timer when it ends calls the event to clear the codes.
The first thing the "goodpin" event does is reset the timer to what ever delay I want.
If no "good pin" entered then the clear event gets called in 3 seconds.
So far so good. Seems to be doing what I wanted. Amazing what a little brain cell refreshment will do.
Great you got it sorted!
Who is online
Users browsing this forum: Anthropic Claude Bot [bot], Bing [Bot], Perplexity.ai [bot] and 19 guests