Finally - a cheap WIRELESS switch that dims! Xiaomi Switch Gen1

Any cheap lights that work well in this configuration?

Yeelight RGB bulbs work ok with this and they are quite cheap I think

Glad to see this is getting some use!

Anyone got a neat mounting solution for the gen1 round button they can share?

Also, what is everyone using to communicate with button? Xiaomi GW or Zigbee receiver (if so, what are you using?)

Thanks and I hope this automation is still useful to people out there :slight_smile:

for mounting I have just been using adhesive velcro dots attached to the light switch face plate. That allows me to quickly pull them off and be mobile if needed. ie: grab one and bring it to the coffee table

A portable light switch! I like it, that’s a great idea. Mine are stuck to blanking wall switches, those Xiaomi sticky pad’s are a pain to remove too!

Hi I followed the script and it is working great with my Philips Hue lights. Smooth dimming and reliable. In another room I have a Fibaro2 dimmer which doesn’t seem to work with this script. Long pressing results in some flickering and sometime the light turning off completely. Another time it would suddenly jump to max brightness.

I seems to me that those Z-wave dimmers need a different kind of script. Anyone with a possible working solution?

Has anyone tried to do this with Ikea Trådfri lights? I have tried for 3 hours now and not got it working.
If anyone has successfully managed to dim Ikea tradfri I´d appreciate if you could share your code :pray:

Thanks for now!

You show us no config, or logs, or anything which would enable anyone to help you.

I tried this concept with a Ikea light bulb, so yes it works. As far as I know it works with al kinds of dimmable lights. I don’t have any code I can share with you as I’m on holiday.

This, with a few appropriate changes works for me using a xiaomi press and hold button, conbee, deconz and hue colour lights. Thank you.

Has anybody tried to adapt this to rotate thru the colours of a light?
Changing colour instead of dimming?
It is on my list of things to try…

Would you like to share?


I had this file in my packages area:


I’d like to know if you have success with this as I was hoping to do the same thing but using the Xiaomi Cube rotation to scroll gradually through the colour spectrum.

I tried using zigbee2mqtt with mixed results. Zigbee2mqtt couldn’t seem to handle the rapid influx of messages.

Can anyone confirm this is still working? I’m on HA 91.3
I’ve tried following the original post with no luck, and also tried with the package that INTEL posted without any luck either.

I’m using a magic home LED controller with a xiaomi button (I have like 6 of these buttons in the house already)

I can get single clicks, double clicks to work.
I can see in the DEV tools that I am “holding the button” but the LEDs don’t dim up or down.

My code is exactly like the package INTEL posted, but I replaced all the sensor names with my own.

I’m not sure how to check logs to see where it’s faulting.

I’m trying to get this to work with my Tradfri remote and Tradfri lights, but I have not had any success with any of the scripts posted here. It should be possible as the Tradfri remote sends a 2001 event when longs pressing and a 2003 event when letting go of the button.

I have created a AppDaemon app that binds controllers with lights and media players for zigbee2mqtt, deconz and zha. You can download it from HACS. Here you have some details:

Let me know if you have any questions!


I’ve an issue, I can’t make this to work.
when I long press the xiaomi button, it turns the boolean “on” an “off”; if I run the scripts, after changing the state in the boolean, it dimm the light (xiaomi philips light); but can’t make it work all together.

could you help me? I used the code as you said and changed the “YOURSENSORID” “YOURLIGHT” for my xiaomi button and ligths.

thanks in advance

I’ve been trying to use this automation with light.fastled integration and the brightness only changes when I let go of the button. Anyone tried this with fastleds?