[SOLVED] Xiaomi miio and yeelight, missing tokens

Xiaomi home automation devices are good!.. Zigbee implementations work fine, their mobile app is comprehensive, and in general is good value for the money.

In my tests with openhab, keeping in mind that all the devices where set via their corresponding apps, this is what I found so far:

3 bindings:
(mihome) Xiaomi MI Smart Home, the gateway acting as a bridge and the ZigBee devices.
(miio) Xiaomi MI IO, All other devices, Wifi.
(yeelight) Yeelight Binding

:grinning: Everything work fine at installation, all devices are detected and operable
:grin: Low latency and reliable
:confused: No way to control the chanels of the gateway, whatever I do can’t get them to respond (light, sounds)
:open_mouth: When the gateway changes IP, all devices loose communication. Only soluiton is to remove and reinstall the gateway binding. No way to set a fixed IP at the gateway (naturally, wifi).

:face_with_raised_eyebrow: Binding missing in the downloadable package and its a nightmare to install teh add-on. Happily on the openhabian, it is included.
:expressionless: Got the mi wifi plugs working, erratically. They loose communication often. But at least can comunicate with them most of the time.
:unamused: Yeelight lamps, which land on the Inbox was never able to get them working.

:roll_eyes: The binding seems to be redundant with miio?!?!

  1. I can’t get the bulbs to comunicate with openhab.
  2. It seems that we need tokens that are not reported by the lamps.
  3. Tried to used the miiojs tool for and miio discover reports no token,
    Device ID: 56221500
    Model info: Unknown
    Token: ???
    Support: Unknown
  4. At the end of the day, it seems that the tokens change regularly, so even if I could find them - which I can’t - and insert them manually, on first change will lost them.

Tried everything and so far, the miio binding seems to be highly unreliable, difficult or impossible to get working.

Any hints?

1 Like

Ok, After some hours of digging…

Yes, yeelight binding is redundant, and worst, i suspect its not not usable due to the fact that there is no known way to get the needed tokens to set the thing.

Using Xiami smarthome application, the only wat I could get the tokens - the most well kept secret in the Xiami kingdom - was via iPhone backup viewer, extract the mihome sqllite and from there, with the ip of the bulb, query the token.

The db name is (your mi id)_mihome.sqlite in IOS, and not miio2.db, as in the andriod app.

Tried to get the db via Android, found it very dificult, file seems to be in /data/data/com.xiami.smarthome, but to access it, you need to root the phone, which is not very clear and depends a lot on your phone brand and the android distro on it.

Also tried miio tool (npm install miio), great tool, but does not get the tokens for Yeelight bulb or Xiami vacuum cleaner. Also tried yeeeligh.py tools, and a lot other stuff, at the end of the day, no way to see the light without the damn token.

The origin and role of these tokens is still a mistery. It seems that is originated (and stored) in Xiaomi app, but never displayed in the last versions of the app (shown in previous versions in device, settings, network) as it should. Its role, could be security at a first glance, excessive in my opinion.

At the end of the day, i would buy any other bulb brand less complicated…

After getting comms with the bulb, bumpec into one other issue, the color is named RGBColor and it seems to fail getting a profile for the channel… any hint?..

I think nowadays the easiest for getting a token is to use the hacked mihome app.
search for mihome_5.4.50_vevs.apk (wwww.kapiba.ru)
You can go to the device network info tab to get access to the token (last line on the page)

As I can’t confirm this app’s origin/safety, I do suggest to de-install after getting the token and use the regular app.

btw… what is the model of the yeelight you are using? (you can see in the device tab… something like yeelight.xx.xxx and do you have a debug log, than I can take a look what is the issue with the color channel

Hi Marcel,

Yeap, that was a path to get it, but I found it easier (and you can get there again if token changes) to read it from the App DB Backups.

In the Xiaomi app, at the bottom I can see
Version: 140_44.

The bulb itself, printed,
CMIIT: 2015DP4838

Ah, I mean the model Id like you can see in OH in paperUI.
Click show properties. as in below example

Ahh… Ok, here:

You can reserve an ip based on the mac address of your Gateway in your DHCP Server.


I also created this app, until now it only works with the yeelight app. But I’m planning getting ready with the mihome app aswell. https://github.com/LuigiTheHunter/GetMiTokens

1 Like

I’ve found this on github, https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token.md
I used android not rooted version apk was downloaded from https://android-apk.org/com.xiaomi.smarthome/43397902-mi-home/

I hope it will help.

I’ve tried your app on a rooted device, but only white screen :frowning: Shall I install any particular version of Yeelight? I’ve also tried to extract the SQLite DB, but device.db -> devices do not contain token column.

I’m using it with the latest yeelight version it is working for me. Also the tokens are not in the devices.db but in the miot.xml :slight_smile: If you are willing to help me that would be great we could figure out why it is not working for you and how to resolve this. :slight_smile:

Also I found out the app has to be restarted after the first launch with root. Im currently trying to fix this.

This is fixed now.

i got the solution for xiaomi philips light now.
step 1:restore the xiaomi philips light bulb by fast turn on off five times
step 2:during 30 second after restore,connect to the wifi with ssid philips-light-cbulb_miap1efd
step 3:input command
~$ miio discover
than you will get the token value to the bulb
after you add the bulb to mi home,the ap mode will be disabled。

~$ miio discover

I’m not sure which exact token you retrieve that way?
The developer token as used in the yeelight binding?
(note: most devices will reset the miio token with each wifi change, hence ‘regular’ tokens pulled this way will be changed again when adding your bulb to the mihome app)

For the ‘regular’ mihome tokens the current easiest ways are 1) the alpha miio binding with cloud access it pulls the tokens from the cloud. 2) the other way is with Mi Home app version 5.4.49 (the one with debug turned on)… look in the xiaomi robot topic for more details.

you are right , i had taken the wrong token and could not add the bulb to home assistant. could you tell me where to download alpha miio,is it a special miio version. thank you very mush.

you can download it here for now Xiaomi Robot Vacuum Binding