1 button with more functions, help needed

I’m have made a rather simple flow for switching and dimming a group of Ikea bulbs with a Niko Zigbee connected switch.

Short push : on/off toggle

Long push : depending on the dim level, dim up or down

It sort of works but I have a behaviour I can’t explain. When long press the lights go out and then back on with the new dim level.

So it looks like the flow always does the short press , even when long press is initiated.

Can you help me out with my flow? I might have a wrong way of thinking here.

This part runs only once per long push. You seem to think the trigger repeats itself as long as it hold.

Try this:

1 Like

Thank you for taking a look.

1 dim step per long push works as intended.

But apparently (I noticed in the logging) the switch always gives a short press signal, regardless of I press long. Knowing this, I just need to check if no long press is following the short press.

The example you mentioned is not what I want to do.

In that case consider switching the longpress an shortpress triggers.

Longpress toggle.

Shortpress dim up/down 20% (changing the dimlevel will also turn on the light, so you will only need longpress to turn off the light)

That indeed crossed my mind. But that’s a little too confusing for wife and children :grinning_face:

Need to keep them happy too.

You could try the following:

  • After the long press, set a variable “long press” to true
  • After the short press, add a delay of 1 second, then check the variable to decide if you want to continue or not
  • When the button is released, set the long press variable to false
1 Like

As @s73nm suggested I created a variable ‘long pres is hold’ witch is changed to YES as soon the button is long pressed. Releasing the button changes it back to NO.

As long as the button is hold the flow restarts itself every 1 second.

Theoretically you could dim all the way down 0%. If so a single press will dim the light to 20%. Otherwise it will toggle the light.

Your flow changes the dim direction at 0% and 100%. My flow changes the direction at every button release.

Thinking about this some more… :slight_smile:

It could be that the 1 second delay is confusing, and would result users to press the button a second time. If this is the case, you could also opt for the following:

  • On long press, do what is needed for a long press

  • On the short press, don’t take any action except start a stopwatch. E.g. using the chronograph app.

  • On the release of the button check the time that has passed (and stop the stopwatch). If less than 1 second has passed, toggle the lights. If more than 1 second has passed, execute anything else that is needed for the long press.

I aimed for a simplified solution but it looks indeed I need to build more logic in the flow. Thanks for all the advise.

Thnaks to your suggestions and some more overthinking, I figured it out.

I used variables for press and long press

Long press action works on press, short press action works on release.

Short press now toggles lights on/off

Long press dims up or down between 20% and 100%

Probably this flow can use some cleanup but I’m happy it works now as intended.

Just a note: with unknown buttons I usually learn which events do they send and when by setting a up flow to send me a message to Telegram with the event name. Or an action per event to send corresponding message.