fison67 / mi_connector

Connector for Xiaomi Devices with Smartthings, Hubitat
MIT License
213 stars 595 forks source link

Token not found, miio discover shows "Token: ???" #35

Closed jezzaaa closed 5 years ago

jezzaaa commented 5 years ago

I have one light strip and one colour light. The light strip is fine, discovers in the Mi Connector web app. I've deleted and re-connected the light but it's still the same.

I also tried to get the token from a backup of the Mi Home app, by extracting the database. Both devices were in there, but the token field was empty for both of them.

Is it possible that the Xiaomi is being more secure with the token, and that the latest version of firmware and Mi Home app both keep it secret?

Here's handshake reply output of miio discover with debug on:

  thing:miio:87425134 <- Handshake reply: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +526ms
  thing:miio:83894783 <- Handshake reply: <Buffer c5 6a 4c 97 08 e8 cc 86 11 8c 0e 2f 79 7f 69 5a> +516ms

I tried deleting and re-adding in Mi Home app. I tried resetting the light by powering off/on 5 times. I checked that it's in developer mode.

fison67 commented 5 years ago

Try a this version of mihome. https://www.apkmirror.com/apk/xiaomi-inc/mihome/mihome-5-0-31-release/

jezzaaa commented 5 years ago

Thanks. Didn't seem to work.

I uninstalled the current version, installed that version from apkmirror, deleted my color bulb, added it again and still the same output from miio discover. Also extracted the app database again, and still has an empty token field.

fison67 commented 5 years ago

miio discover is not able to show token of bulb. Are you sure you extract the database of app again?

jezzaaa commented 5 years ago

I was quite sure. But I'm trying it again now. Yep, found it.

For anyone else having trouble with this, here were the steps I used.

  1. Launch the MiHome app and remove the color bulb.
  2. Uninstall the MiHome app.
  3. Use "adb shell" to confirm that the directory /data/data/com.xiaomi.smarthome/ no longer exists.
  4. Install the old MiHome app downloaded from APKMirror, and sign in with my Xiaomi account.
  5. Add the color bulb into the app (set wifi password, rename bulb), check that on/off works.
  6. Exit the MiHome app.
  7. Use "adb shell" and "su" to get a root shell, then copy the files miio2.db* from /data/data/com.xiaomi.smarthome/databases/ into /storage/emulated/0/Download/
  8. Open the database in an sqlite3 reader app (SqlitePrime)
  9. Open the devicerecord table, tap on a row, scroll to the "token" (near then end) and there it is!
fison67 commented 5 years ago

Great!