Rule with mult command not working properly

18 views
Skip to first unread message

cybe...@gmail.com

unread,
May 4, 2022, 3:20:03 PM5/4/22
to TasmotaUsers
Consider this rule:

Rule1
  on Dimmer#State do Backlog var4 %value%; mult4 6; mem4 %var4% endon

So basically, I want to multiply the dimmer value by 6 and store that.
It *kinda* works, but only after two events:

When I change the dimmer, the %var4% value used is the one from *before* the event.
So when the event is complete, mem4 is updated with the old value of var4, yet var4 is indeed updated with the dimmer*6 value.
And thus a 2nd event will work, hence my description of "It *kinda* works, but only after two events"


Anyway, I managed to work around it by this rule. But I still wonder, should the above be the way it works, or should I report a bug to github.

Rule1
  on Dimmer#State do Backlog var4 %value%; mult4 6; endon
  on Var4#State do mem4 %value% endon

Maurits

Philip Knowles

unread,
May 4, 2022, 4:19:20 PM5/4/22
to cybe...@gmail.com, TasmotaUsers

On the rules page it explains (in the Setting Variables section)

The following won't work:

Rule1 ON event#setvar1 DO Backlog var1 %value%; Power1 %var1% ENDON

At least not as you probably would expect. The var1 value used by the Power1 command will be the value present before the Backlog command is executed. This is so, because the rule will replace %var1% BEFORE the Backlog commands are put in the Backlog command stream.

To make it work you would need to do

 

Rule1 ON event#setvar1 DO var1 %value%;ENDON

ON var1#state do Power1 %var1% ENDON

 

 

Sent from Mail for Windows

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/5212fc97-b51b-4726-ac1c-ac68b66fbdfbn%40googlegroups.com.

 

cybe...@gmail.com

unread,
May 5, 2022, 12:44:34 AM5/5/22
to TasmotaUsers
Oops, sorry. 
That's a little embarrassing, so see my exact problem, as well as "my" exact workaround, on the manual.
Anyway, thanks for the reply.

Philip Knowles

unread,
May 5, 2022, 1:22:11 AM5/5/22
to cybe...@gmail.com, TasmotaUsers
To be fair it's not easy to find and the work round isn't there - I gave my example for that situation (which is obviously similar to yours).
I will suggest an edit to make it clearer.
Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of cybe...@gmail.com <cybe...@gmail.com>
Sent: Thursday, May 5, 2022 5:44:34 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Rule with mult command not working properly
 
Reply all
Reply to author
Forward
0 new messages