ZHA Double (and Triple) Click Experiments

Original title: “IKEA Trådfri Remote: ZHA Double (and Triple) Click”
I updated the title after sharing the results of my Xiaomi remote experiments.


I recently picked up an IKEA Trådfri Remote to try out. My computer is in the Living Room and I thought it would be nice to have a multi function remote to manage the fan and lights around me. After watching the zha_event logs I determined that I could get 9 functions out of the 5 button remote. 5 single clicks plus 4 long presses.

Unfortunately, zha_event was not capturing an event for double clicks like my Xiaomi double switches do. I kept thinking there might be a way to capture clicks say a half second apart. As it turns out part of the trick was to delay the single click action by a half second to allow a chance for a second click to be detected!

Anyway, if you are interested in learning more about how I did it, I go into a lot of detail in an article on my blog (link below).

You can find full versions of my automation and script at the links below. My full automation handles multiple remotes instead of just the one in the below example.

3 Likes

Today I sat down with a spare Xiaomi Aqara Wireless Mini Switch. It is the square one with a single button in the middle.

I attempted to recreate the multi-click success, but there seems to be a delay in the button presses being received by ZHA. The delay is long enough that I cannot consistently time the button presses to detect a double click. I even tried extending the delay from 1/2 a second to 2 seconds. Slowing my click rate down did not work. Speeding up my click rate didn’t work.

In the end the timing window for this Xiaomi button is just too narrow to make a double click on this button useful. I doubt any other Xiaomi battery powered buttons would work any differently, so I am going to end the Xiaomi button experiment here.

Let me know if you use this technique successfully any other ZHA buttons!

Tradfri 5 button remote update:

In my article I only tried capturing multi-click on the center button. I wanted to let you know that it also works on the other 4 buttons as well! This means we can use this remote for a practically unlimited number of actions.

So now we can use this remote for:

  • 5 single click actions
  • 4 long press actions
  • 5 double click actions
  • 5 triple click actions
  • etc.

For example, I setup my top and bottom buttons to:

  • 1 click = turn on/off primary lamp
  • 2 clicks = turn on/off table lamp
  • Long press up = increase primary and/or table lamp brightness by 20%
  • Long press down = decrease primary and/or table lamp brightness by 20%

I was eyeing the Ikea remote to control stuff in my living room (that’s not yet implemented but it’s in my head) and this is just perfect! Thank you.
PS: Also great to see what can actually be done with automations

1 Like

I don’t think I realized how game changing the new choose and mode features were going to be until now! I believe this could not have been accomplished sooner without custom Python code! :slight_smile: