Dimmer control using button not switch

699 views
Skip to first unread message

Angus Parkinson

unread,
May 26, 2021, 2:38:08 AM5/26/21
to TasmotaUsers
I have a few shelly dimmer 2 's . 

I have implemented a couple using the stock firmware using a single momentary switch and that works great. However 

The dimmer replaced a sonoff mini that was running tasmota and I was making use of the single, double, triple, and quad press to trigger other actions. 

So I thought easy I will flash the dimmer with Tasmota and I get these button actions back again. 

The problem is there's no Switchmode 11 for buttons in tasmota. Is that something that could be implemented?

Thanks 

   

 

Philip Knowles

unread,
May 26, 2021, 2:57:21 AM5/26/21
to TasmotaUsers, Angus Parkinson
You don't need switchmode for buttons because they already do that
Button state 12 for 2 presses etc. Look at the Buttons section of the Buttons and Switches page
Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Angus Parkinson <ang...@gmail.com>
Sent: Wednesday, May 26, 2021 7:38:08 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Dimmer control using button not switch
 
--
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/8f589a1b-283d-4471-83f9-3f4cc775cdc7n%40googlegroups.com.

Angus Parkinson

unread,
May 26, 2021, 3:15:54 AM5/26/21
to TasmotaUsers
Yeah, I understand that but swicthmode 11 add's some extra states that buttons just don't have and these states are important when controlling dimmers. Ie When pressing the switch (closing the circuit) for a long time (set in SetOption32), Tasmota will send repeated INC_DEC (increment or decrement the dimmer) commands for as long as the button is pressed (use Switch<x>#state=4 in rules).

If I could get the long press of a button to send repeated INC_DEC I would be in business however only generates a hold.

Thanks, Angus 

Philip Knowles

unread,
May 26, 2021, 4:54:13 AM5/26/21
to Angus Parkinson, TasmotaUsers

Well you could use hold in a rule to do the Inc/Dec or you could set the button as a switch and use switchmode0 to change its function to a button.

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

From: Angus Parkinson
Sent: 26 May 2021 08:15
To: TasmotaUsers
Subject: Re: Dimmer control using button not switch

 

Yeah, I understand that but swicthmode 11 add's some extra states that buttons just don't have and these states are important when controlling dimmers. Ie When pressing the switch (closing the circuit) for a long time (set in SetOption32), Tasmota will send repeated INC_DEC (increment or decrement the dimmer) commands for as long as the button is pressed (use Switch<x>#state=4 in rules).

 

If I could get the long press of a button to send repeated INC_DEC I would be in business however only generates a hold.

 

Thanks, Angus 

 

 

 

 

 

On Wednesday, May 26, 2021 at 4:57:21 PM UTC+10 knowles..@gmail.com wrote:

You don't need switchmode for buttons because they already do that

Button state 12 for 2 presses etc. Look at the Buttons section of the Buttons and Switches page

Regards

Phil K

From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Angus Parkinson <ang...@gmail.com>
Sent: Wednesday, May 26, 2021 7:38:08 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Dimmer control using button not switch

 

I have a few shelly dimmer 2 's . 

 

I have implemented a couple using the stock firmware using a single momentary switch and that works great. However 

 

The dimmer replaced a sonoff mini that was running tasmota and I was making use of the single, double, triple, and quad press to trigger other actions. 

 

So I thought easy I will flash the dimmer with Tasmota and I get these button actions back again. 

 

The problem is there's no Switchmode 11 for buttons in tasmota. Is that something that could be implemented?

 

Thanks 

 

   

 

 

--
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/8f589a1b-283d-4471-83f9-3f4cc775cdc7n%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.

Angus Parkinson

unread,
May 28, 2021, 9:57:16 PM5/28/21
to TasmotaUsers
Well this is my current rule 

on system#boot mem1 + ENDON on switch1#state=3 DO publish cmnd/loungelight/POWER TOGGLE ENDON on switch1#state=4 DO publish cmnd/loungelight/DIMMER %mem1% ENDON on switch1#state=5 DO mem1 - ENDON on switch1#state=6 DO mem1 + ENDON

When you push and hold switch 1 out get something like this on the console. You get repeated state=4 untill it's released.


02:44:04.118 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:04.126 MQT: cmnd/loungelight/DIMMER = -
02:44:04.143 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":90}
02:44:04.419 RUL: SWITCH1#STATE=5 performs "mem1 -"
02:44:04.427 MQT: stat/loungelight/RESULT = {"Mem1":"-"}
02:44:05.075 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:05.082 MQT: cmnd/loungelight/DIMMER = -
02:44:05.099 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":80}
02:44:05.476 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:05.483 MQT: cmnd/loungelight/DIMMER = -
02:44:05.499 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":70}
02:44:05.927 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:05.935 MQT: cmnd/loungelight/DIMMER = -
02:44:05.962 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":60}
02:44:06.326 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:06.333 MQT: cmnd/loungelight/DIMMER = -
02:44:06.350 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":50}
02:44:06.779 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:06.785 MQT: cmnd/loungelight/DIMMER = -
02:44:06.817 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":40}
02:44:07.169 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:07.175 MQT: cmnd/loungelight/DIMMER = -
02:44:07.194 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":30}
02:44:07.572 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:07.579 MQT: cmnd/loungelight/DIMMER = -
02:44:07.597 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":20}
02:44:07.970 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:07.977 MQT: cmnd/loungelight/DIMMER = -
02:44:07.994 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":10}
02:44:08.359 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:08.365 MQT: cmnd/loungelight/DIMMER = -
02:44:08.382 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":1}
02:44:08.764 RUL: SWITCH1#STATE=4 performs "publish cmnd/loungelight/DIMMER -"
02:44:08.771 MQT: cmnd/loungelight/DIMMER = -
02:44:11.609 RUL: SWITCH1#STATE=6 performs "mem1 +"
02:44:11.617 MQT: stat/loungelight/RESULT = {"Mem1":"+"}

If you try this using a button and so73 you only get the hold state 3 once.

on system#boot mem1 + ENDON on button2#state=10 DO publish cmnd/loungelight/POWER TOGGLE ENDON on button2#state=3 DO publish cmnd/loungelight/DIMMER %mem1% ENDON on button2#state=5 DO mem1 - ENDON on button2#state=6 DO mem1 + ENDON

02:51:46.454 MQT: stat/loungelight/RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":231,"Free":280,"Rules":"on system#boot mem1 + ENDON on button2#state=10 DO publish cmnd/loungelight/POWER TOGGLE ENDON on button2#state=3 DO publish cmnd/loungelight/DIMMER %mem1% ENDON on button2#state=5 DO mem1 - ENDON on button2#state=6 DO mem1 + ENDON"}}
02:51:51.524 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":100}
02:51:52.605 MQT: stat/loungelight/RESULT = {"POWER":"OFF"}
02:51:52.609 MQT: stat/loungelight/POWER = OFF
02:52:01.945 RUL: BUTTON2#STATE=3 performs "publish cmnd/loungelight/DIMMER +"
02:52:01.952 MQT: cmnd/loungelight/DIMMER = +
02:52:01.965 MQT: stat/loungelight/RESULT = {"Button2":{"Action":"HOLD"}}
02:52:01.994 MQT: stat/loungelight/RESULT = {"POWER":"ON","Dimmer":100}

I would be great if there was a way of intregating switchmode 11 and setoption 73.

I am 100% sure it's posible but I am no coder

Thanks

Philip Knowles

unread,
May 29, 2021, 2:00:54 AM5/29/21
to TasmotaUsers, Angus Parkinson
I'll have a think later (but you shouldn't use mem) but first thoughts if you set var1 to 5 then, if it's just a normal button you'll get on and off with a short press and hold (or 3) with a long press. You can use that to add var1 to the current brightness until it hits 100. You can then use that to set var1 to -5 until it hits the minimum brightness when you change it back to 5 again.
Need to get it to keep cycling maybe a 1 second RuleTimer could do that?
Regards

Phil K

Sent: Saturday, May 29, 2021 2:57:16 AM
To: TasmotaUsers <sonof...@googlegroups.com>

theb...@gmail.com

unread,
Sep 8, 2024, 8:24:38 AM9/8/24
to TasmotaUsers
Hi, sorry to bump this 3 year old post.
Do you mind explaining how to do as you've described with var or cycling with ruletimer

```
You can use that to add var1 to the current brightness until it hits 100. You can then use that to set var1 to -5 until it hits the minimum brightness when you change it back to 5 again.
Need to get it to keep cycling maybe a 1 second RuleTimer could do that?
```
I thought of using this with button hold but I can't quite figure out how to keep cycling the dimming + or - action

```
Rule1
On system#boot do var1 0 endon
On button1#state=3 do add1 1 endon
On var1#state>=2 do var1 0 endon

Rule2
On var1#state==0 do dimmer - endon
On var1#state==1 do dimmer + endon

Rule3
On button1#state=15 do backlog rule2 0; rule2 1 endon08:22 PM
```

On Saturday 29 May 2021 at 14:00:54 UTC+8 knowles...@gmail.com wrote:
I'll have a think later (but you shouldn't use mem) but first thoughts if you set var1 to 5 then, if it's just a normal button you'll get on and off with a short press and hold (or 3) with a long press. You can use that to add var1 to the current brightness until it hits 100. You can then use that to set var1 to -5 until it hits the minimum brightness when you change it back to 5 again.
Need to get it to keep cycling maybe a 1 second RuleTimer could do that?
Regards

Phil K

Philip Knowles

unread,
Sep 8, 2024, 2:56:43 PM9/8/24
to theb...@gmail.com, TasmotaUsers
It's worth looking at this before trying to programme something


Documentation (Wiki) for Tasmota


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of theb...@gmail.com <theb...@gmail.com>
Sent: 08 September 2024 13:24

theb...@gmail.com

unread,
Sep 8, 2024, 6:59:51 PM9/8/24
to TasmotaUsers
Yes I did have at look at pwm dimmer but that one seems to be for multiple buttons for controlling dimming. 
What I need is one button for dimming, basically switchmode 11 but for button hold/release just like original poster intended.

Philip Knowles

unread,
Sep 9, 2024, 5:15:08 AM9/9/24
to theb...@gmail.com, TasmotaUsers
Except that it specifically says

For single-button devices or multi-button devices with remote device mode enabled, only the operations controlled by the power button in the instructions below apply
So this applies
When the power is on, holding the power button alternately increases or decreases the brightness. Initially, holding the power button increases the brightness. Releasing and then holding the power button again decreases the brightness.


Sent: 08 September 2024 23:59
Reply all
Reply to author
Forward
0 new messages