Nesting level for events

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
_Cyber_
Normal user
Posts: 113
Joined: 20 Oct 2019, 09:46

Nesting level for events

#1 Post by _Cyber_ » 29 Apr 2022, 17:03

On optimizing rules I stumbled over the max nesting level of rules engine.

Is there a way to extend it dynamically, if not would it be an idea to extend it in code? I think is most probably implemented to avoid endless loops, is it?

Thanks. :-)

Br
Alois

Code: Select all

94366064: HTTP: event,ControlZ3=102
94366090: EVENT: controlz3=102
94366096: ACT  : event,ControlZ3L=102
94366098: EVENT: ControlZ3L=102
94366103: ACT  : Let,5,4
94366106: ACT  : Let,6,2
94366139: ACT  : Let,7,=100.00
94366144: ACT  : Let,8,50
94366147: ACT  : Let,9,51
94366149: ACT  : Let,10,55
94366153: ACT  : event,ControlShutter=102,18,19,18
94366156: EVENT: ControlShutter=102,18,19,18
94366277: ACT  : logentry,'GPIO=18,19_cooling_mode to 3 percent'
94366279: GPIO=18,19_cooling_mode to 3 percent
94366282: ACT  : event,ControlShutter=3,18,19,18
94366284: EVENT: ControlShutter=3,18,19,18
94366286: EVENT: Error: Nesting level exceeded!
94366302: ACT  : event,ControlZ3R=102
94366304: EVENT: ControlZ3R=102
94366310: ACT  : Let,5,4
94366313: ACT  : Let,6,3
94366346: ACT  : Let,7,=100.00
94366350: ACT  : Let,8,55
94366353: ACT  : Let,9,56
94366356: ACT  : Let,10,50
94366360: ACT  : event,ControlShutter=102,17,21,18
94366362: EVENT: ControlShutter=102,17,21,18
94366499: ACT  : logentry,'GPIO=17,21_cooling_mode to 3 percent'
94366501: GPIO=17,21_cooling_mode to 3 percent
94366504: ACT  : event,ControlShutter=3,17,21,18
94366506: EVENT: ControlShutter=3,17,21,18
94366509: EVENT: Error: Nesting level exceeded!
94369901: EVENT: Clock#Time=Fri,16:38

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

Re: Nesting level for events

#2 Post by Ath » 29 Apr 2022, 18:57

It is better to use "asyncevent" command instead of "event" to avoid that type of error, as most of the time when having too much levels of events, 'you're doing it wrong'.
Asyncevent adds the event to the end of the eventqueue for processing, to avoid stack-issues on busy or less-memory (read: ESP8266) units.
When running time-critical or fixed-order processes, you might need to pay attention to the code-structure to not end up with endless loops.
/Ton (PayPal.me)

_Cyber_
Normal user
Posts: 113
Joined: 20 Oct 2019, 09:46

Re: Nesting level for events

#3 Post by _Cyber_ » 29 Apr 2022, 19:05

I use asyncevents where possible, but in these cases i can not because before firing the event I set variables which are used in the event itself. With asyncevent only the "last" would win.

For now i duplicated again code, I am only one event too deep :twisted:

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

Re: Nesting level for events

#4 Post by TD-er » 29 Apr 2022, 19:16

Are you running the latest build/code?
If so, then maybe the newly added %eventname% and %eventvar% can be useful to deduplicate code?
Also the latest build no longer is limited to 4 eventvalues.

_Cyber_
Normal user
Posts: 113
Joined: 20 Oct 2019, 09:46

Re: Nesting level for events

#5 Post by _Cyber_ » 04 May 2022, 07:55

yes, I am running the latest build. I saw the removal of the 4 eventvalues restriction, I think this will help, but I need to rework the rules for using this. Will have a look at it on next spare time :-)

Post Reply

Who is online

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