Mihome tokens extractions

Here a short instructions as I did it a couple of times and always thought it would be useful to have it in one place
On debian/android

on android
uninstall mihome app and install a 5.0.24 or earlier version (get it on apkmirror.com)
enable developer mode by tapping 7 times the build info in android settings if it is no

on debian
install adbtools : sudo apt-get install adbtools
get adbextractor @ https://sourceforge.net/projects/adbextractor/
copy the abe.jar in your local dir
install sqlitebrowser : sudo apt-get install sqlitebrowser

now connect your mobile

then enter

sudo adb backup -noapk com.xiaomi.smarthome -f backup.ab (confirm you want to backup on mobile)
sudo java -jar abe.jar unpack backup.ab backup.tar
sudo tar xvf backup.tar
sudo cp apps/com.xiaomi.smarthome/db/miio2.db .
sudo rm -fr apps/
sudo rm backup.ab
sudo rm backup.tar
sudo sqlitebrowser

browse to teh miio2.db file open it
in table devicerecord you find your mihome devices
column token is the token

or … in the sql tab
select model,name,token from devicerecord where devicerecord.token <> “”

and export to csv