Planned downtime from 11:00 UTC to 11:30 UTC. We try to keep it as short as possible!
15 Huami Server Pairing
Andreas Shimokawa edited this page 2 months ago

Contents

Server based pairing

New devices and older devices with updated firmware require server based pairing. This means, that you absolutely must use MiFit app to make the initial pairing, retrieve the pairing key and then use this key to pair with Gadgetbridge. Currently, Mi Band 4, Amazfit Bip Lite and Amazfit GTR are known to be the first devices with this enabled from the beginning.

Requirements

To set up your band/watch with Gadgetbridge you need Gadgetbridge > 0.35.0 and a unique key for your band. There are several ways to obtain the key.

Obtaining the unique key

On rooted phones

On rooted phone you may grab the key from MiFit/Amazfit database which means that you must:

  • install MiFit (for Amazfit GTS install Amazfit)
  • create an account
  • pair the band/watch

Then, execute the following command in a root shell terminal:

for Mi Band 4, Amazfit Bip Lite and Amazfit GTR
sqlite3 /data/data/com.xiaomi.hm.health/databases/origin_db_[YOURDBNAMEHERE] "select AUTHKEY from DEVICE"
for Amazfit GTS
sqlite3 /data/data/com.huami.watch.hmwatchmanager/databases/origin_db_[YOURDBNAMEHERE] "select AUTHKEY from DEVICE"

NOTICE: Every time you hard reset the band/watch, the Bluetooth MAC Address will be changed and you must grab a new key! Also, anytime you unpair your band/watch from MiFit, the pairing key will be invalidated and you must make new pairing in MiFit app.

On non-rooted phones

Using a python script with your account details

https://github.com/argrento/huami-token

Please see the README for a detailed desctiption on the procedure

freemyband

On a non rooted phone you may consider using https://www.freemyband.com/ NOTE that the procedure described there is not encouraged or supported by the Gadgetbridge developers and the devs have no information on that app and whether it is safe to use

Preparations

  • do not unpair the band/watch from MiFit
  • kill or uninstall the MiFit app
  • ensure GPS/location services are enabled
  • unpair the band/watch from your phone’s bluetooth (as per below)

If you already connected your band/watch with your phone, remove it from Android Bluetooth settings. The procedure depends on which ROM is installed on your smartphone. Here is an example for LineageOS 16 (Android 9):

connected forget device confirm cleared

Setup

1. Once you own your unique key for your band/watch and preparations are done, start Gadgetbridge, go to the home screen and tap “(+)":

main menu

2. Allow acces to location services (required since Android 6) and Bluetooth. Start discovery:

allow location services allow Bluetooth start discovery

3. After a while, your band/watch should appear. Long press on “Device name", for example “Mi Smart Band 4":

found device

4. Scroll down, tap “Auth Key” and enter your own key. Do NOT hit Enter/Return key.

IMPORTANT: Enter your key prefixed with 0x ( eg. if your key is fedcba01234567890fedcba012345678 enter 0xfedcba01234567890fedcba012345678). Do not press the Enter key. Make sure 0x is really 0x , some keyboards might use different symbols.

enter key

5. Go back and tap on “Device name", for example “Mi Smart Band 4". Pairing should start now:

found device pairing

6. After successful connection you will see your band/watch on the home screen.

successful

Congratulations, you did it!


Troubleshooting

If you encounter problems with Bluetooth discovery or pairing process, try the following steps:

  • Make sure MiFit is not running
  • Make sure you did not unpair your band/watch from MiFit
  • Make sure to add 0x in from your key when pasting/typing it to Gadgetbridge
  • Make sure 0x is really 0x , some keyboards might use different symbols, see here.
  • Do not press Enter/Return key when typing the key
  • Make sure that band/watch is unpaired from the phone’s Bluetooth
  • Toggle Bluetooth OFF and ON
  • Reboot your smartphone
  • Reboot your band/watch (More-> Settings-> Reboot)