Modulo operation in rules
Moderators: grovkillen, Stuntteam, TD-er
Modulo operation in rules
Has someone a tip, how I can use the modulo-operator/-function (mod(x,y) or {mod:x:y} ) in a rule if-condition?
I can find help in the docs...
Thanks
I can find help in the docs...
Thanks
Re: Modulo operation in rules
If computation like actions do not seem to work, you can always try to store it first in a variable using the "let" command.
See some examples here: https://espeasy.readthedocs.io/en/lates ... -functions
The problem is that functions may sometimes need several passes to get parsed completely and that's not always done right.
So when trying to make complex computations (e.g. call a function with arguments which are a result of a computation) it is best to store it in a variable first.
See some examples here: https://espeasy.readthedocs.io/en/lates ... -functions
The problem is that functions may sometimes need several passes to get parsed completely and that's not always done right.
So when trying to make complex computations (e.g. call a function with arguments which are a result of a computation) it is best to store it in a variable first.
Re: Modulo operation in rules
But on the linked page, isn't a example for mod, or?
And the rule
ends in the log
and the rule
produce this
I'm going crazy...
And the rule
Code: Select all
Let,4,{mod:15:7}
Logentry,%v4%
Code: Select all
2312470: ACT : Let,4,{mod:15:7}
2312473: Calculate: Unknown token
2312478: ACT : Logentry,0
2312483: 0
Code: Select all
Let,4,mod(15,7)
Logentry,%v4%
Code: Select all
2732473: ACT : Let,4,mod(15,7)
2732476: Command unknown: Let,4,mod(15,7)
2732500: ACT : Logentry,0
2732504: 0
Re: Modulo operation in rules
I will have a look at it, as I had written the documentation when implementing the new functions but then decided that it was a bit too complex so changed it.
I will check for the "mod" operator to see what should be the correct syntax.
N.B. also make sure to check if you are running a "custom" or "normal" build as the "testing" and "dev" builds have the LIMIT_BUILD_SIZE define enabled which does exclude a number of these rules functions.
I will check for the "mod" operator to see what should be the correct syntax.
N.B. also make sure to check if you are running a "custom" or "normal" build as the "testing" and "dev" builds have the LIMIT_BUILD_SIZE define enabled which does exclude a number of these rules functions.
Re: Modulo operation in rules
Tested with:
- ESP_Easy_mega_20210223_hard_SONOFF_POW_4M1M
- ESP_Easy_mega_20210223_hard_other_POW_ESP8285_1M
Re: Modulo operation in rules
Can you test with the "%" operator?
Should store "1" into the 1st variable.
Code: Select all
let,1,10%3
Re: Modulo operation in rules
That works. But not in a if-condition. I must assign it to a var and usw then the var in the if-condition.
Who is online
Users browsing this forum: No registered users and 37 guests