Switchmode 15 effect on rules?

466 views
Skip to first unread message

Andrew Waser

unread,
Jan 10, 2022, 4:54:57 PM1/10/22
to TasmotaUsers
Can someone clarify to me if Switchmode 15 affects the triggering of switch#state rules?

Tried to research this myself but all I could find was someone with the same question and no answer.

My assumption was that since the value of switch1 still changes when the switch itself changes, switch1#state should still fire at the same time.

However, when I write a simple rule to test this, using the console like so:

switchmode 15
rule1 ON Switch1#State DO Power1 %value% ENDON
rule1 1

I'd expect the behavior to mimic switchmode 1, but instead it does nothing.

I've been using tasmota (with home assistant) for quite a while, but I'm relatively new to writing rules. It's possible I'm just doing something dumb with syntax, but I'm stumped.

Can anyone point me in the right direction here?

Philip Knowles

unread,
Jan 12, 2022, 7:30:45 AM1/12/22
to Andrew Waser, TasmotaUsers
You might try switchmode1 15.

Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Andrew Waser <awa...@gmail.com>
Sent: Monday, January 10, 2022 9:54:57 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Switchmode 15 effect on rules?
 
--
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/0eec2acc-f39d-4766-8c27-200db0f64b39n%40googlegroups.com.

Andrew Waser

unread,
Jan 12, 2022, 5:06:29 PM1/12/22
to TasmotaUsers
Wouldn't "switchmode1 15" do exactly the same thing as "switchmode 15"?
anyway, I tried it, and the behavior is the same.

My understanding from reading the docs is that if you have a rule related to a switch state, switchmode shouldn't matter (https://tasmota.github.io/docs/Buttons-and-Switches/#rules):
" To ignore the default behaviour define a rule which triggers on Switch<x> for all state changes or on Switch<x>#State for specific state changes. If a rule matches only certain states, default switch behaviour is suppressed only for those states."

and yet for me, it still seems like my rules aren't picking up on Switch1#State when I'm in Switchmode 15.

Just trying to figure out if I'm misunderstanding the docs, making a stupid mistake, or something else.

Andrew

Philip Knowles

unread,
Jan 13, 2022, 2:23:58 AM1/13/22
to Andrew Waser, TasmotaUsers

So why are you using Switchmode 15? Perhaps if you explain what you are trying to achieve we can help? Switchmode 15 stops the switch controlling the relay and then you create a rule to use the switch to control the relay. Setoption 114 may be a better option for example.

Could you also share the module configuration page too?

 

BTW it is better get into the habit to explicitly use Switchmode1 15 than just Switchmode 15

 

Regards

 

Phil K

 

Sent from Mail for Windows

 

From: Andrew Waser
Sent: 12 January 2022 22:06
To: TasmotaUsers
Subject: Re: Switchmode 15 effect on rules?

 

Wouldn't "switchmode1 15" do exactly the same thing as "switchmode 15"?
anyway, I tried it, and the behavior is the same.

My understanding from reading the docs is that if you have a rule related to a switch state, switchmode shouldn't matter (https://tasmota.github.io/docs/Buttons-and-Switches/#rules):

" To ignore the default behaviour define a rule which triggers on Switch<x> for all state changes or on Switch<x>#State for specific state changes. If a rule matches only certain states, default switch behaviour is suppressed only for those states."

and yet for me, it still seems like my rules aren't picking up on Switch1#State when I'm in Switchmode 15.

Just trying to figure out if I'm misunderstanding the docs, making a stupid mistake, or something else.

Andrew

On Wednesday, January 12, 2022 at 5:30:45 AM UTC-7 knowles...@gmail.com wrote:

You might try switchmode1 15.

 

Regards

 

Phil K

 

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Andrew Waser <awa...@gmail.com>
Sent: Monday, January 10, 2022 9:54:57 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Switchmode 15 effect on rules?

 

Can someone clarify to me if Switchmode 15 affects the triggering of switch#state rules?

Tried to research this myself but all I could find was someone with the same question and no answer.

My assumption was that since the value of switch1 still changes when the switch itself changes, switch1#state should still fire at the same time.

 

However, when I write a simple rule to test this, using the console like so:

switchmode 15

rule1 ON Switch1#State DO Power1 %value% ENDON

rule1 1

I'd expect the behavior to mimic switchmode 1, but instead it does nothing.

I've been using tasmota (with home assistant) for quite a while, but I'm relatively new to writing rules. It's possible I'm just doing something dumb with syntax, but I'm stumped.

Can anyone point me in the right direction here?

--
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/0eec2acc-f39d-4766-8c27-200db0f64b39n%40googlegroups.com.

--
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.

Andrew Waser

unread,
Jan 13, 2022, 5:01:09 AM1/13/22
to TasmotaUsers
The use case is this: I want to "decouple" one switch on a device from its power output, but only some of the time or when certain other conditions are met. I don't want this to affect the behavior of other switches on the device or their mqtt output, so setoption114 won't work.

my plan was to use another rule to enable and disable the first rule above, for example, on a schedule set by timers, in which case the rules would be something like:

rule1:
ON Switch1#State DO Power1 %value% ENDON

rule2:
  ON clock#timer1 DO rule1 1 ENDON   
  ON clock#timer2 DO rule1 0 ENDON

this is still a simplified example compared to what I eventually hope to do (choose to decouple the switch and/or turn it on and off based on various other sensor inputs as well)

the eventual intended application is a water pump with various flow and level sensors that affect when and how it operates. A lot of things in the house depend on it, so I'd like to handle the logic on the device rather than home assistant as much as possible. 

I'll get module configuration tomorrow. 

Andrew

Philip Knowles

unread,
Jan 13, 2022, 5:12:37 AM1/13/22
to Andrew Waser, TasmotaUsers

There’s possibly an easier way.  I’ve had issues programmatically switching rules on and off.

Use your timer to set var1 to 1 or 0.

On switch1#state=1 do power1 %var1% endon

On switch1#state=0 do power1 0 endon

You can then switch off but only switch on if the timer is set.

 

You could also use events (which is probably the way you should go because of the potential complexity)

 

In the old days I would say to create a ‘truth table’ of the inputs and outputs...

Andrew Waser

unread,
Jan 13, 2022, 2:10:07 PM1/13/22
to TasmotaUsers
Thanks for all your help so far.

Your example accomplishes something slightly different than I was going for - I don't want the input to be controlled by the switch *at all* when it is decoupled. If it's on, I want it to remain on.

I think I'd have to do something like this: (still assuming var1 set by timer)

ON Switch1#Boot DO var2 %value% ENDON
ON Switch1#State DO Backlog Event switchEnabled=%var1%;var2 %value% ENDON
ON Event#switchEnabled=1 DO Power1 %var2% ENDON

That seems less elegant than toggling a rule,  but "working" would definitely trump "elegant". I'll give it a shot and see how it goes.

I still wonder why my attempt to use Switchmode 15 doesn't work, but alas, if it's not obvious to everyone else, it's probably not worth the time for anyone to figure out.

With much appreciation,

Andrew

Marc LeFevre

unread,
Jun 11, 2023, 1:03:22 PM6/11/23
to TasmotaUsers
I have the exact same problem as the OP.  My system is ESP8266-based and has one switch and one relay.  I want the switch to be able to turn on the relay but not turn it off.  If I set up a simple rule like this:

ON Switch1#State=1 DO Power1 ON ENDON

to verify rule triggering and set SwitchMode1 1, the rule fires every time. However, I don't get the behavior I want.  If I set SwitchMode1 15, I stop the switch from controlling the relay but my rule trigger stops firing.

The OP never got an answer to his question about whether this dependency between SwitchMode and rule triggers is by design or by accident.

Is there any other mechanism to accomplish what I'm trying to do?

Philip Knowles

unread,
Jun 11, 2023, 1:17:01 PM6/11/23
to Marc LeFevre, TasmotaUsers

There’s a way without using switchmode and using a dummy relay

Assign relay1 to a spare gpio

Rule1 On power1#state=1 do power2 1 endon

It would be better to use a button rather than a switch as the position of the switch may cause confusion.

To switch off you would need to issue power2 0

 

 

 

Sent from Mail for Windows

 

Reply all
Reply to author
Forward
0 new messages