Rules: only one "On System#Boot do" !?
Moderators: grovkillen, Stuntteam, TD-er
Rules: only one "On System#Boot do" !?
I found that in the "Rules" only one rule can contain "On System#Boot do".
If every rule has an "On System#Boot do" then only the first will be executed.
I can't find anything about it in the manual. Is that right?
If every rule has an "On System#Boot do" then only the first will be executed.
I can't find anything about it in the manual. Is that right?
Re: Rules: only one "On System#Boot do" !?
Rules parsing is done by trying to match an event.
As soon as it has been matched, rules parsing will stop.
This also means you need to be careful when creating rules for less specific events and more of a "catch-all" version.
For example:
As you may see, the order of these is quite important.
A few months ago I have added an option to optimize rules order based on the frequency it may have been hit. This would speed up rules parsing.
However I overlooked this use case and thus have removed this optimization
As soon as it has been matched, rules parsing will stop.
This also means you need to be careful when creating rules for less specific events and more of a "catch-all" version.
For example:
Code: Select all
on foo#bar=1 do
...
endon
on foo#bar do
...
endon
A few months ago I have added an option to optimize rules order based on the frequency it may have been hit. This would speed up rules parsing.
However I overlooked this use case and thus have removed this optimization

Re: Rules: only one "On System#Boot do" !?
You seem to expect that every of the 4 files has a separate 'meaning', but in fact they are only split because of a previous limitation of the web-editor used.
To be explicit: These 4 files are processed as if they are 1 file, handled sequentially, if they exist.
As TD-er explained, there is (quite) some optimization/caching performed on the rules, more extensively on ESP32 platform because of less limitations in memory-use.
/Ton (PayPal.me)
Re: Rules: only one "On System#Boot do" !?
Very clear Ton en TD-er. Thanx. That confirms what I already thought based on what I've struggled with.
What Ton mentioned about the 4 Rulesets and what TD said with regard to handling the first hit. Shouldn't that be mentioned in the manual, for example in the chapter (system) events?
What Ton mentioned about the 4 Rulesets and what TD said with regard to handling the first hit. Shouldn't that be mentioned in the manual, for example in the chapter (system) events?
- budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Rules: only one "On System#Boot do" !?
So what exactly is the rule file size limit now? Specifically, on ESP32. If the new editor can handle bigger and the rules are parsed as if its only one file can a single rules file larger than the previous total of 4 separate files be edited in the web editor? Or a single file be uploaded via the tools page? I'm working on an irrigation controller and there is quite a bit of complexity to my rules and flows. Breaking the files up @ 2048 Max characters is kind of a pain sometimes. Inquiring minds would like to know.You seem to expect that every of the 4 files has a separate 'meaning', but in fact they are only split because of a previous limitation of the web-editor used.
To be explicit: These 4 files are processed as if they are 1 file, handled sequentially, if they exist.


"The glass is twice as big as it needs to be".
Re: Rules: only one "On System#Boot do" !?
You can put all rules in a single file, if you want to, though when on ESP8266 that can easily cause memory issues, especially on fully 'populated' units (many memory-intensive tasks used), so splitting them somewhat evenly across files can be helpful.
On ESP32 there is much more memory available (often > 100 kB free), so loading a larger file isn't an issue. Even though the web editor can handle files > 2048 bytes quite easily, the warning is still there, mostly to alert ESP8266 users, but also to avoid getting very large rules as that may slow down the unit because of the processing-time.
On ESP32 there is much more memory available (often > 100 kB free), so loading a larger file isn't an issue. Even though the web editor can handle files > 2048 bytes quite easily, the warning is still there, mostly to alert ESP8266 users, but also to avoid getting very large rules as that may slow down the unit because of the processing-time.
/Ton (PayPal.me)
- budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Rules: only one "On System#Boot do" !?
That's good to know. Thanks.
"The glass is twice as big as it needs to be".
Re: Rules: only one "On System#Boot do" !?
Please don't use 100k rules files, as the ESP32 does cache the rules in memory
(on recent builds)
ESP8266 can also handle files > 2k as we now use some JavaScript to actually call the upload URL when saving the rules.
Before we used HTTP POST, which does seem to have some limit somewhere between 1.5k and 2k (not always the same limit)
That was the reason for this limit.
I have tested with rules files upto 8k and those worked just fine.
Not sure about the effect on speed when using either a single large file or 4 smaller files.
However, it does make sense to have the most frequently called rules blocks placed first in the 1st rules file.

ESP8266 can also handle files > 2k as we now use some JavaScript to actually call the upload URL when saving the rules.
Before we used HTTP POST, which does seem to have some limit somewhere between 1.5k and 2k (not always the same limit)
That was the reason for this limit.
I have tested with rules files upto 8k and those worked just fine.
Not sure about the effect on speed when using either a single large file or 4 smaller files.
However, it does make sense to have the most frequently called rules blocks placed first in the 1st rules file.
- budman1758
- Normal user
- Posts: 303
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Rules: only one "On System#Boot do" !?
Not to worry. Don't think I'm gonna get THAT big.

"The glass is twice as big as it needs to be".
Re: Rules: only one "On System#Boot do" !?
Sure...

Well as soon as you do, please let me know because then we obviously miss something in the rules

Who is online
Users browsing this forum: No registered users and 19 guests