Download and install Python 3.9.13 (it must be Python 3.9!) and make sure you select “Add to PATH” when installing it
Download and install “Build Tools for Visual Studio 2019” (it must be for Visual Studio 2019!)
You will need to restart the PC after you install the Build Tools
Open Command Prompt and run “pip3 install python-miio”
Run in Command Prompt "miiocli yeelight --ip YOURBULBIP --token YOURBULBTOKEN set_developer_mode 1
Make sure the output finishes with “Setting developer mode to True - [‘ok’]”
Add Yeelight integration to HA & put your bulb’s IP address in there
Enjoy!
P.S. As mentioned in the alert at Alerts | Home Assistant Alerts, Xiaomi seems to be step by step locking down their ecosystem, so it would probably be wise after going thru these steps to also go to your router and block the bulb’s IP from the Internet. While this will make it go offline in the MI app, in HA it should work fine forever without the fear of a firmware upgrade that will make it operable from the MI app only.
P.S. 2: If Step 3 to get the token no longer works for some reason, here’s the classic way to get it:
Obtain and install old MI Home app via .apk on Android or Bluestacks (I always use version 5.4.54)
Login with Xiaomi account
Reset bulb by turning on/off 5 times
Give Location permission to MI Home app
Scan for new devices in app
Connect to bulb & add it to the WiFi network
Ignore the fact that it ends with “Connection error, check network and retry” and click on Back button, Stop adding device, OK
Go back from Add Device
Pull down to refresh main device screen, you will see the bulb added and marked New
If you don’t have an on/off button on the device’s image, just long-press to rename the device (which you should anyway), save the new name, exit the MI Home app and enter it again after a few seconds, the switch button should appear
Use a proper Android file manager like Total Commander to go to /storage/emulated/0/SmartHome/logs/plug_DeviceManager & send the file there named TODAY’SDATE.txt to somewhere more easily searchable/editable like a PC via e-mail
Open the file and search for the bulb’s name that you created in Step 10 - the token is in the text right behind it, like: “token”:“YOURTOKENID”,“longitude”:“0.00000000”,“latitude”:“0.00000000”,“name”:“Master Bedroom Window Light”
To be honest, I had no idea what I was getting myself into when I bought these bulbs, as my 2 (theoretically similar) Yeelight lamps just needed a couple of clicks in the Yeelight app in order to enable Developer Mode.
I’ll amend the guide to also mention blocking the bulbs from the Internet, as the problem mentioned here might pop up: Alerts – Home Assistant
I am having some trouble with the step 18. When I run the command it returns the following message:
miiocli : The term ‘miiocli’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
Thanks for the tutorial,
I’ve got the same issues than Deutadado, Step 17 didn’t work. I’ve got lots of errors:
I think this is the most relevant:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: Microsoft C++ Build Tools - Visual Studio
Install build Tools didn’t add something to path, maybe it comes from it?
I have some experience 12 hours of trying to instal this bloody ‘‘pip3 install python-miio’’.
For those who don’t know what are doing like me easest way on windows is with Anaconda Prompt and Visual++ it takes 5min.
Hi, I now its an old post but maybe someone can share the Mi Home 5.4.54, I cant find that exact version, the closer was the 5.4.56 but it wont give me the plug_DeviceManager
Thanks @johnflorin , I was really disappointed when my wife gave me this bulb and at first thougt this couldnt be added to HA, so this post was a miracle for me.
I follow your instructiones but finally I used the linked shared before https://github.com/Maxmudjon/Get_MiHome_devices_token to obtain the token. Also I used the anaconda installation mention by @bratick
Just for help someone new trying to add this bulb, this is what I did. Its not perfect but its what works for me, because I struggle a bit installing the required software
Add the bulb to the MI HOME app (updated play store version)
Right, one of my bulbs got knocked off the network after being without power for a few days (guess its memory has a pretty small lifespan if left without power), so I updated the guide with more recent info like the token tool.
I also found out this way that the reason everyone was getting errors with Python years later was because the python-miio tool is specifically made for Python 3.9 & Visual Studio Tools 2019 and using newer versions will make its install fail!
I have no idea how to use Anaconda, so just followed the classic guide after checking what Python version was latest in 2021 when it was first published.