Search code examples
compilationrulestasmota

How to setup a rule at compile time in Tasmota


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?


Solution

  • 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"