Multifunction single button light dimmer piston


#1

1) Give a description of the problem
I have a xaiomi aqara single button paired in ST with bsprangers DTH. I would like to create a piston that can turn lights on at 100% brightness with a single press and various dimmed levels with a double, triple and quadruple press. The problem I have is getting the off function correct. When the lights are dimmed using double, triple or quadruple push and I try to toggle them off, they will go to 100% first and I have to press the button agin to toggle off.

The button functions a double press as button 2 of the device, and triple as button 3 and so on.

2) What is the expected behaviour?
When button is pressed once, lights on 100%.
When button is pressed twice, lights on 75%
When button is pressed three times, lights on 50%
When button is pressed four times, lights on 25%
When button is toggled once, lights off.

3) What is happening/not happening?
I can get lights to toggle on and off, but not in combination with off at the correct stage.

**4) Post a Green Snapshot of the piston!


5) Attach logs after turning logging level to Full


#2

Can’t see the piston image.


#3

I’ve never used “toggle”
so I am wondering if toggle is registering as a single or double button push?


#4

Updated original post :wink:


#5

Hmm, I think you just need to add a little bit of logic on the button #1 to check if any of the dimmer’s level greater than 1, if true, turn off, else turn on 100%? Not at a computer right now so can’t really test it.