Integrate MI Smart LED Bulb easy steps

hi, I just brought a Mi Spart Led Bulb and a Mi Smart Led Bulb Essential, started to dig in a little bit and found the a clear guide to set up the device, here the link during the process realize there is a simpler way of doing it.

Step 1 Use the last version of Mi Home and register your bulb. Dont worry if it need to update, feel free of doing it.

Step 2 If possible use a linux base system if you use Windows, you can install the linux Subsystem or even Conda works, any system that let you use pip and let you do wget, important this system has to be in the same network of the device you want to link.

Step 3 Install the miiocli library, for this follow the next steps:

For the most recent release can be installed using pip:

pip install python-miio

Here is the link to the github of miiocli https://github.com/rytilahti/python-miio

Step 4 Using miiocli use the command cloud to get the data from your devices. you need to put your username and password to access the data.

miiocli cloud
Username: [email protected]
Password:

== name of the device (Device offline ) ==
    Model: example.device.v1
    Token: b1946ac92492d2347c6235b4d2611184
    IP: 192.168.xx.xx (mac: ab:cd:ef:12:34:56)
    DID: 123456789
    Locale: cn

Step 5 Now with this data you can alter the device ussing the following command:

miiocli yeelight --ip IP_OF_DEVICE --token TOKEN_OF_DEVICE set_developer_mode 1

This last step should return something like:

Setting developer mode to True
ok

Step 6 Go into HA and add the device with yeelight you will need to add the IP to integrate de device.

Good luck hope this work with your light. the modes of my bulb are: XMBGDP01YLK and MJDPL01YL

Extra Step Suggested by @patzobil :
Set a STATIC IP in your router for the bulb, so it always keep the same IP, this is recommended also for the Home Assistant device.

If there is any problem or error let me know and i will update the tutorial

20 Likes

Thanks a lot.
That helped me and now I can use the light bulb in HA with the yeelight integration

Didn’t work for me for model yeelink.light.color5, even though I got a a good return on the last step.

hi @xiki , did you added the IP in the yeelight integration?

Hey @heartbox, yes I have installed yeelight integration and tried to add the light but I got the usual error. I managed to workaround using this component. I would prefer your solution though and use the official yeelight component

BIG BRAVO on this guide! Life-saver

Might be worth mentioning to reserve a DHCP IP address on those LED bulbs to avoid frustration if your router leases another IP address.

2 Likes

Works amazingly! Thanks.

Works for me! Thanks!
But I have a doubt. Is it safe to leave it in developer mode? Or can I do the reverse command by doing set_developer_mode 0 ?
Thanks!

Worked for me today, Just had to pip install pycrypto and install run pip install python-miio as sudo!

Can the bulbs (and even account) be removed from the Mi App later?

I belive you can, putting the bulb in developer mode let you skip the app usage, sooo you can use it outside of the app.

1 Like

Anyone get an error at this point (the message is massive about no user…)?

Another user recomended this:

Worked for me today, Just had to pip install pycrypto and install run pip install python-miio as sudo!

1 Like

To answer my own question - they stop showing as available in HA once removed from the app/cloud, unfortunately.

thats awesome guide, but I would update step 4 to: GitHub - PiotrMachowski/Xiaomi-cloud-tokens-extractor: This tool/script retrieves tokens for all devices connected to Xiaomi cloud and encryption keys for BLE devices.

Download and unpack archive:

wget https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor/releases/latest/download/token_extractor.zip
unzip token_extractor.zip
cd token_extractor
Install dependencies and run script:

pip3 install -r requirements.txt
python3 token_extractor.py
1 Like

updated, Thank.

Im glad the guide still holds up :smiley:

When i do miiocli in terminal, it says zsh: command not found: miiocli

but it’s already installed from this message

Requirement already satisfied: python-miio in ./Library/Python/3.8/lib/python/site-packages (0.5.12)

What i can do to run miiocli command? should add something to $PATH , btw i’m using macOS 12.4

It is very easy to setup. Thanks!

Dear @heartbox,

I have followed the steps that you suggested and everything worked like a charm!

Thanks a lot!

PS. In my case I had to restart the router before running:
miiocli yeelight --ip IP_OF_DEVICE --token TOKEN_OF_DEVICE set_developer_mode 1

Hello,

for me i got the following error on the last step

Setting developer mode to True
Error: {‘code’: -5001, ‘message’: ‘invalid params’}

Any assistance will be greate ! !
Thank you