Increase and Decrease Brightness with ONE button of a switch

Maybe that’s the problem. These are 3 different operattions for 4 functions. That’s why the big manufacturers do it differently. 2 operations for 4 function (short press = toggle, a long press = dimming). You’re right, it’s most intuitive to use 4 buttons for that too. But that costs more money, space or does not always meet the design requirements.


For those who doubt the sense of the function: I work for one of the manufacturers mentioned above and in numerous UX tests we have found out that, as expected, the 4 button operation is the most intuitive. However, the all-in-one operation is better than the 2-button operation. This is probably because they have been around in a similar form (the old rotary dimmers) for over 30 years. That’s why there are many users (like me) who enjoy using this function. If you don’t see any added value in the function, you don’t have to set it up. But don’t dismiss it for that reason. Please don’t comment if you can’t or don’t want to help.

Happy to oblige. I’ve even taken the extra step of muting this topic. Enjoy your echo chamber.

1 Like

That’s exactly what I’m looking for. But that only works if the light goes through deconz too? That’s a pity. Then I’ll just have to keep looking for another solution.

That’s the way i use hue dimmer swtich, too. But in the bedroom I would need two of these switches and an additional button for “all off”. And my wife and I do not find these dimmers nice and too clumsy.

Because of that and because I rarely dim the bedside lamps, a simple Button is enough to toggle the light. But if I want to dim the lamps once, I have to open the app every time. With the Hue Smart Button I can dim additionally. This is great. But with the button (just like with the big DImmer switches) you can only control one room at a time. So if I could dim with the Aqara Switch in the same way as with the Hue Button, then I could also implement the “all off” usecase with it.

Everyone is entitled to an opinion, but …
Taras (if you’ve bothered to look) is a major contributor here, he seldom makes arbitrary judgements and his opinion is always significant (even if you (or especially if) you find a way round it (because he’s pointed out the pitfalls)).
He likes to solve ‘some’ problems just as an interlectual exercise. And this is why I’m (and probably Jim is) here, I’d say that burning ‘may’ actually have a use but he’s not beyond “gilding the odd lilly” too.
I’ve said my bit and will leave this to burning to continue as he sees fit, you are in good hands.

1 Like

Please don’t scare of Taras, the forum needs him :wink:

Or move your lights over to deconz as well. Good luck finding another solution that doesn’t involve some Python programming with async code etc. (and from what I’ve read, I assume you don’t really know how to code). Without the deconz service, I don’t see any way to accomplish what you want to do with HA automations and some input_booleans etc.

That’s not true. I can control whatever I want with the Hue Dimmer Switch, this limitation is only if the Hue Dimmer Switch is used with the Hue hub and not with Deconz/Zigbee2MQTT/etc.

1 Like

I found exactly what I was looking for: https://www.youtube.com/watch?v=JDpRmPBw6qE

1 Like

Hi @celair,

It might be too late, but as @Burningstone, ControllerX supports this and you just need less than 7 lines of YAML. The configuration will look like the following:

example_app:
    module: controllerx
    class: WXKG01LMLightController
    controller: your_controller_id
    integration: deconz
    light: light.your_light

You can see the default behaviour in here. You can also map your own button mapping. This configuration supports toggle dimming by changing direction every time the button is held.

If you are interested, let me know since this specific xiaomi button does not have default behaviour support for deCONZ. However, if you let me know of the deconz events for the different actions, I will be able to add support for it easily.

Cheers,
Xavi M.

1 Like

Hi @xaviml,

I tried ControllerX for my Xiaomi switch and it work now for the common actions (“on, “off”, 'double click” etc.) but still not for long press actions for light dimming but perhaps it is because I use ZHA for my Zigbee devices?

Here my current app.yaml:
example_app:
module: controllerx
class: WXKG01LMLightController
controller: “00:15:8d:00:05:48:cb:14”
integration: zha
light: light.yeelight_color_0x0000000007d02a59

Is there a way to add the long press behaviour for dimming actions, please? Is that not the purpose of ControllerX?

Hi @Philou,

Last time I checked this controller does not have long press for the ZHA integration. This ist he original ticket that someone submitted to add it to ControllerX: Xiaomi Mijia Wirelss Switch (Round) · Issue #94 · xaviml/controllerx · GitHub

Could you please check in Developer Tools > Event, listen for “zha_event”, and check if there is any event popping up when long pressing and releasing. If so, let me know and I will update the controller accordingly.

Regards,
Xavi M.

Hi @xaviml,

here what I have when listening to zha_event:
{
“event_type”: “zha_event”,
“data”: {
“device_ieee”: “00:…:14”,
“unique_id”: “00:…006”,
“device_id”: “63…79a”,
“endpoint_id”: 1,
“cluster_id”: 6,
“command”: “attribute_updated”,
“args”: {
“attribute_id”: 0,
“attribute_name”: “on_off”,
“value”: false
}
},
“origin”: “LOCAL”,
“time_fired”: “2021-04-15T22:14:15.985234+00:00”,
“context”: {
“id”: “a88…74”,
“parent_id”: null,
“user_id”: null
}
}
Événement 4 déclenché 0:14:
{
“event_type”: “zha_event”,
“data”: {
“device_ieee”: “00:1…14”,
“unique_id”: “00:1…006”,
“device_id”: “63c…9a”,
“endpoint_id”: 1,
“cluster_id”: 6,
“command”: “attribute_updated”,
“args”: {
“attribute_id”: 0,
“attribute_name”: “on_off”,
“value”: true
}
},
“origin”: “LOCAL”,
“time_fired”: “2021-04-15T22:14:12.241793+00:00”,
“context”: {
“id”: “49…ee3”,
“parent_id”: null,
“user_id”: null
}
}

And when I use a blueprint like the one from ZHA - Mijia Wireless Remote Switch (WXKG01LM) I can use the hold action to for example close a light :

Hi @Philou ,

ControllerX is able to listen only to the ZHA events, not the device changes. Are the 2 events you sent one triggered when pressed, and the other when released? Could you press (without holding) to see if any event pops up, and then release after 5 or 6 seconds and see if the second one shows. If so, could you please send to me both events marking them which one was which (hold and release).

Cheers,

Hi, when I press the button and hold it, I have this:

Événement 22 déclenché 10:03:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:05:48:cb:14",
        "unique_id": "00:15:8d:00:05:48:cb:14:1:0x0006",
        "device_id": "63c83e36f300937ca18d5fd0c981279a",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": true
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-29T08:03:15.869746+00:00",
    "context": {
        "id": "33e3c7873fc5d33806d1882ecb42d319",
        "parent_id": null,
        "user_id": null
    }
}
Événement 21 déclenché 10:03:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:05:48:cb:14",
        "unique_id": "00:15:8d:00:05:48:cb:14:1:0x0006",
        "device_id": "63c83e36f300937ca18d5fd0c981279a",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "click",
        "args": {
            "click_type": "single"
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-29T08:03:15.869505+00:00",
    "context": {
        "id": "b9a58cd1e132d86284a4f8c5d4f7ca42",
        "parent_id": null,
        "user_id": null
    }
}

And when I release i have this:

Événement 23 déclenché 10:03:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:15:8d:00:05:48:cb:14",
        "unique_id": "00:15:8d:00:05:48:cb:14:1:0x0006",
        "device_id": "63c83e36f300937ca18d5fd0c981279a",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "attribute_updated",
        "args": {
            "attribute_id": 0,
            "attribute_name": "on_off",
            "value": false
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-29T08:03:17.586362+00:00",
    "context": {
        "id": "d0e34e8992e9c10beab99a63f2bc4935",
        "parent_id": null,
        "user_id": null
    }
}
1 Like

I will update this controller for the next release, thanks! However, when holding, the single click will be also fired as I can see in the logs you shared.

Thx, yes I saw that, I don’t uderstand why, all I can see is that I can use the hold action to fire actions with some blueprint so I imagine it is possible to use it with ControlleX too. Would be great to use it for increase or decrease brightness on holding down my switch :wink:

Hi @xaviml, I tested this with z2m but doesn’t work for the hold default actions like written here:

WXKG01LMLightController (Light)

This is the default mapping for this controller:

  • 1 click → Toggle
  • 2 clicks → Full brightness
  • 3 clicks → Minimum brightness
  • 4 clicks → 50% brightness
  • Hold the button → Brightness up/down with direction changes

My apps.yaml config:

example_app:
  module: controllerx
  class: WXKG01LMLightController
  controller: sensor.0x00158d000548cd92_click
  integration: z2m
  light: light.0x7cb03eaa0a03f232

Any idea, please?

Hi @Philou,

Which version of zigbee2mqtt are you using? The _click sensor is deprecated in favour of the _action one. Could you see if you have that sensor for that controller and see if that fixes your problem?

Regards,
Xavi M.

Hi, it is the latest one I believe, I’ve just installed it : 1.18.1-1

And yes it works fine now with the action sensor, thx very much!

1 Like

Just as an update to the helpful script above, since when the brightness is zero, at least for my lamp, the brightness attribute disappears i.e. it becomes ‘none’:

service: light.turn_on
target:
  entity_id: light.ledvance_dorm_ccab1300_level_light_color_on_off
data:
  # Tweak the step size to liking. Note, using brightness_pct, its from 0-100, but state_attr is 
  # from 0-255, so need to convert.
  # Also, to handle the rounding, will just jam it to 100% if it's close (> 90%)
  brightness_pct: >
    {% set step_size = 49 %}
    {% set cb = (state_attr('light.ledvance_dorm_ccab1300_level_light_color_on_off','brightness') | float(0) / 255.0) * 100.0 %}
    {% set new_brightness = cb | int + step_size %}
    {% if 91 <= new_brightness < (90 + step_size) %}
      100
    {% else %}
      {{ new_brightness if new_brightness < 100 else 1 }}
    {% endif %}