How to setup a rule at compile time in Tasmota

1k Views Asked by At

I want a rule to start the Wifi Manager when a button is long-pressed. I enter the following rule on the web console or serial, it works fine:

Rule 1 on button1#state=3 do wificonfig 2 endon

And to enable the rule:

Rule1 1

I tried to bake this rule into my build at compile time:

#undef USER_RULE1
#define USER_RULE1 "on button1#state=3 do wificonfig 2 endon"

This does not work. So my questions are:

  1. Should I include the word 'rule1' also within the command string ? That is,

    #define USER_RULE1 "Rule1 on button1#state=3 do wificonfig 2 endon"

  2. Should I enable the rule also within this string. I am not sure where to put the 'Rule1 1' part to enable it. Can it be like:

    #define USER_RULE1 "Rule1 on button1#state=3 do wificonfig 2 endon Rule1 1"

Neither of them looks convincing to me. Can someone please point me to the documentation/ examples for compile time rules?

2

There are 2 best solutions below

1
On BEST ANSWER

I had the same question.
Seems like the answer is here: https://tasmota.github.io/docs/Compile-your-build/#advanced-customization

In your case, it should be:

#define USER_BACKLOG "Rule1 1"
1
On

I am a bit lost. When I compile in my rule and the activation of this rule1 in USER_BACKLOG then I see in the log after flashing, that the rule is activated, but it’s not coming to execution, because it’s deactivated from some process during startup again. If I activate it manually after again, the rule is working like expected, only not directly after flashing.