"Fake" event

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

"Fake" event

#1 Post by mackowiakp » 18 Oct 2019, 17:39

I use such rule for push on button:

Code: Select all

on Switch#Switch=1 do
  // body of rule
EndOn
So action is activated if button was depress. Is any possibility to activate such action from rule?

I mean about something like this:

Code: Select all

on Switch#Switch=1 or another_event do
  // body of rule
EndOn
and call another_event from rule like this:

Code: Select all

event,another_event
Is it possible in any way?

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

Re: "Fake" event

#2 Post by grovkillen » 18 Oct 2019, 19:03

You should call an event from the switch#switch event. That way you can easily call that event using any way you want.
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: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: "Fake" event

#3 Post by TD-er » 18 Oct 2019, 20:32

You can also change the switch mode from "normal" to "toggle".

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#4 Post by mackowiakp » 19 Oct 2019, 06:05

You can also change the switch mode from "normal" to "toggle".
The situation is more complicated. Its because as a "switch" I use 3D gesture sensor. To be more precise - I'm trying to use that one:

https://www.aliexpress.com/item/3286420 ... 2c69e13d2d

It recognized 9 kind of movement. My goal is to use ESP in conjunction with this sensor and 11 inch e-paper display for presentation of all parameters measured by all my sensors connected to other ESP and RPi, together with charts, warnings etc. Its for constant access (24/7/365) to data without turning on any PC or using tablet, phone or so.

Main advantage of such solution is ultra low power consumption (even one year battery powered) and absence of touch screen. Its because touch screen is always dirty, always fingerprints on it and so on. It needs to be clean from time to time. I don like it.

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#5 Post by mackowiakp » 19 Oct 2019, 19:32

grovkillen wrote: 18 Oct 2019, 19:03 You should call an event from the switch#switch event. That way you can easily call that event using any way you want.
Finally I got it working. But i think that there is limitation of maximum amount of called events from event to two. My rule code has a structure:

Code: Select all

on Switch#Switch=1 do
  if somethink_1
    event,event_1
   // rest body of rule
  endif
  
    if somethink_2
    event,event_1
   // rest body of rule
  endif
  
  .........
  
    if somethink_8
    event,event_1
   // rest body of rule
  endif
EndOn
Of course event_1 must be taken as subroutine not real event, just for limit amount of code lines.
But if I change the structure to:

Code: Select all

on Switch#Switch=1 do
  event,action
 endon
  
 On action do
  if somethink_1
    event,event_1
   // rest body of rule
  endif
  
    if somethink_2
    event,event_1
   // rest body of rule
  endif
  
  .........
  
    if somethink_8
    event,event_1
   // rest body of rule
  endif
EndOn
the unit reboots if I call "action" event from rule or from Tools->Command menu.
Is there any limitation? My personal feeling is that samothing like this exist.

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

Re: "Fake" event

#6 Post by grovkillen » 22 Oct 2019, 13:35

I really don't know what your asking. Please elaborate.
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:

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#7 Post by mackowiakp » 22 Oct 2019, 13:49

Simplify. I am calling event_1, event_1 call event_2, event_2 call event_3. Event_1 can be call by depress of physical switch or from rule. If I call event_1 by key depressing - its OK. If I call event_1 from rule, device reboots.
But if I eliminate event_3 (whats dramatically increases amount of lines code in rule) in both cases unit works OK.
So I think that is any limitation for amount of events called from events. Is it true?

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

Re: "Fake" event

#8 Post by grovkillen » 22 Oct 2019, 14:14

Show your rules instead. I don't get it...
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:

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#9 Post by mackowiakp » 22 Oct 2019, 14:23

Code: Select all

on Switch#Switch=1 do
  event,action
 endon
  
 On action do
  if somethink_1
    event,event_1
   // rest body of rule
  endif
  
    if somethink_2
    event,event_1
   // rest body of rule
  endif
  
  .........
  
    if somethink_8
    event,event_1
   // rest body of rule
  endif
EndOn

On event_1 do
    event,event_2
   // rest body of rule
EndOn

On event_2 do
    event,event_3
   // rest body of rule
EndOn

On event_3 do
   // body of rule
EndOn
event_2 and event_3 can be call from another rules

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

Re: "Fake" event

#10 Post by grovkillen » 22 Oct 2019, 14:35

You should ALWAYS command event triggers last! ;)
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:

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#11 Post by mackowiakp » 22 Oct 2019, 14:41

Hmmm. OK, I dont know about it...

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#12 Post by mackowiakp » 22 Oct 2019, 19:46

OK, but can I send events one by one like this:

Code: Select all

On event_1 do
   // rest body of rule
    event,event_2
    event,event_3
EndOn

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

Re: "Fake" event

#13 Post by grovkillen » 22 Oct 2019, 20:09

Yes but if you want to run them one after another you should do this:

Code: Select all

On System#Boot Do
  Let,1,0
EndOn

On LoopDeLoop Do
  Let,1,[INT#1]+1
  Event,event_[INT#1]
EndOn

On event_1 Do
   //body of rule
   Event,LoopDeLoop
EndOn

On event_2 Do
   //body of rule
   Event,LoopDeLoop
EndOn

On event_3 Do
   //body of rule
   Event,LoopDeLoop
EndOn

On event_4 Do
  Let,1,0
   //body of rule
EndOn
This is an example since you're not giving me the real rule set you try to use.
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: "Fake" event

#14 Post by grovkillen » 22 Oct 2019, 20:11

Here you have our current benchmark test rule set, use it as inspiration: https://github.com/letscontrolit/ESPEas ... rules1.txt
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:

mackowiakp
Normal user
Posts: 531
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: "Fake" event

#15 Post by mackowiakp » 22 Oct 2019, 20:25

THX, thats what I wanted !

Post Reply

Who is online

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