Dim/Brighten light on a single button long press?

This is in node-red, but gives you an idea how to form the logic:

The node on the left listens to all ZHA events and feeds the event data through a couple nodes that filter out the specific remote and the specific button pressed (the yellow nodes). This just so happens to also be for an ikea 2 button dimmer.

That “switch” node routes the message to one of five places depending on what event it sees (button 1 press, button 1 hold, button 2 press or hold, and the last for either button being released after a hold. I have mine set up where a simple button 1 or 2 press turns a light on or off. Holding either button here dims the light up or down.

The ornage node is a “looptimer.” Upon being triggered by a hold, this node sends a message to the brighten or dim node to call the brightness_step_pct service. A positive value (say 5) will brighten the light by 5%, a negative value (say -5) will dim it by that amount. In my case, the loop timer node calls this service four times a second, each dimming the light by 5%:

Screen Shot 2020-08-13 at 5.48.32 PM

The looptimer node will stay in the loop until either it times out, or i release the button and send a “stop” message to the node.

I think all of this can now be easily recreated in the built in automation environment in HA. I just haven’t used the new features so you’re on your own if that’s the route you take. I personally find these types of things much easier to handle in node-red.

3 Likes