This topic is to explain how you can use long press/release with a button to dim lights. Note that if you use z-wave associations you do not need this tutorial, and dimming will be smoother. But for all other cases, this will do the trick.
For this tutorial I implemented one-button dimming, where the lights dim up and down until the button is released. The simpeler version: dim up with one button, dim down with another can be created using the same building blocks with ease if you get this one.
For this example I use the Chronograph - Adds precise timer, stopwatch and transition functionality to Homey app to create a transition. A transition is a change from one value to another in steps. This app requires Homey Pro.
Here I use transitions to gradually change from low dimming to high. When the transition is done, I start one in reverse. I look at the dimming level of the light to see which way the transition should go:
This flow creates the transitions, but does not yet specify what to do when a step is reached. For that you need a flow to set the value from the transition in the dimming level of the light:
So now we need a flow to start this off on a long press of a button, and stop the transitions once the button is released. However, these flows will juggle the dim level up and down infinitely once started. So just to be sure, I also ad a timer that stops the juggling after a while if the button is not released or the release was not registered. This is also done using the Chronograph app, this time using a timer. The final flows needed:
A note to this tutorial: I purposely did not use the current dim level as a starting point for the transition. It can be done, but it will require math to calculate the right transitions, which I felt was too complicated for this tutorial. If the light supports stepwise changing of the dim level, that can be implemented easier using that, but as I also wanted to demonstrate the use of the transition value, so I created the flows as shown above.
Also note: if you set the transitions faster, Homey might decide to disable your flows because they fire too much. And because Homey isn’t precise with its timings, the chances are the dimming changes a lot after you let go of the button.