Toggle brightness and or colour

Hi guys, looking for a spot of advice regarding rgbw bulbs and buttons and rule machine. Basically, I have a range of different buttons and I'm wondering what is the best way to increase/ decrease brightness or alter the colours of my bulbs with single press , double press hold etc.
So if single press toggles on/off how can I make double press be 10% brightness, another double press be 20% another double press be 30% and so on. Likewise how can I make a hold be blue, another hold be red, another hold be green and so on.

First, what kind of button device do you have? Does it natively support "double tapped" events? If not, there's another challenge. :slight_smile: (Not impossible to "fake" detecting this with an app or rule, but not as easy as just having it in the first place.) I assume it reports "held" events, too, otherwise that's probably an un-solvable problem.

Assuming that's all figured out...

Do you want a double tapped event to increase the brightness by 10%? If so, that's easy: just use the "adjust level" command (with a positive or negative value) and it will increase or decrease the bulb's brightness by that much. If you really want to cycle through 10%, 20%, etc. with successive double-taps, that's not impossible either (I wrote an app that makes this easier, but you could track the "current" press with a local variable in a Rule; I've seen some examples of that here but could share something more specific if needed). For holds, you'll have to do something similar--and likely track the current "hold" number with a local variable, or use conditionals to detect the current color (I'd use hue) and respond accordingly, something like:

Set currentHue (local number variable) to attribute: bulb hue
IF (currentHue < 10) THEN
  Set bulb hue to 20
ELSE-IF (currentHue < 20) THEN
  Set bulb hue to 30
ELSE-IF (currentHue < 40) THEN
  Set bulb hue to 40
  Set bulb hue to 0

(If the bulb accurately and quickly reports hue values, I'd say that's easier than using a variable to track the "hold number," but either way should work.)

Hi, thanks for the pointers. My devices are aqara wall switches which I've just bought. They support press, double tap and hold. I think the colour change is the head scratcher for me just now. Your example above makes sense regards brigness changing :+1:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.