[General Accessories] Bonoboo:
Gathering statistics and battery level for use in Tasker

Also check other useful additions for Mi Band

What is this

API to retrieve data from the app not available for now.

But if someone wants to use data in Tasker for own purposes here is a task.

You can get all basic information for current day from last synchronization.

Stats will be updated after each app launch.

How it works

1. Waiting for launch Mi Band app

2. Pause 30 seconds for finishing synchronization

3. Current date going converted to YYYY-MM-DD format via JavaScript

4. From application database retrieved data about current day in JSON format (as it uploading to the cloud)

5. JavaScript parsing it's data on Tasker variables

6. UNIX-time converted into normal time

7. Now use variables for your own purposes

Requirements

– Root to access program data

– Binary utility sqlite3 to read database: not all ROM's include it, so better install manually

Variables

%DRMLIG – light sleep, minutes

%DRMDEEP – deep sleep, minutes

%DRMWAKE – awake, minutes

%DRMSTA – asleep, time

%DRMEND – woke up, time

%DRMSTA2 – asleep when set manually, time

%DRMEND2 – woke up when set manually, time

%WLKSTPS – walking, steps

%WLKDIST – walking, meters

%WLKTIME – walking minutes

%WLKCAL – walking, calories

%WLKGOAL – steps goal

%RUNDIST – running, meters

%RUNTIME – running, minutes

%RUNCAL – running, calories

%ROPE – how may times today you jumped over rope

%SITUPS – how many times today you performed situps

Installation

1. Check via file manager (RootExplorer) file /system/xbin/sqlite3

2. If it absent: download sqlite3.img below post and remove extension .img (source), for devices with Intel x86 CPU use sqlite3_x86.img, remove prefix

3. Copy this file to /system/xbin

4. Via file manager set permission on it "all 9 ticks" (chmod 777)

5. Download below post profile Mi_Band_Get_Data.prf.zip

6. File from ZIP copy to /sdcard/Tasker/profiles

7. Tasker > tap on the tab Profiles > Import > Mi_Band_Get_Data

8. After running the task you get variables

9. Important: for Android 5.0 Lollipop and newer enable Settings > Accessibility > Tasker

Addition: Obtaining battery level of the bracelet

Important!

This is no longer works due changes in Mi Fit app.

Guaranteed working at least on ancient 1.4.341 which support only band with color LED.

Use powerful app Mi Band Tools provide configurable widgets with battery level and current steps amount.

Also it provides very flexible notifications from apps.

Battery level not written to database and only requests at connecting.

So we reconnect bracelet and find data in log.

How it works

1. Bluetooth turns off

2. Deleting log /sdcard/mili_log.txt

3. Bluetooth turns on

4. Pause 10 seconds to establish connection

5. Contents of the log reads into variable %log

6. Parsing text between level: and %

7. Battery level writes into variable %MIBATT1

8. Disabled action: write in /sdcard/battery.txt current date, time and battery level

Notes

– root NOT required

– sqlite3 NOT required

Installation

1. Download below post task Mi_Band_Battery_Level.tsk.zip

2. File from ZIP copy to /sdcard/Tasker/tasks

3. Tasker > tap on the tab Tasks > Import > Mi_Band_Battery_Level

4. Run the task e.g. by time for logging bracelet discharge

Changelog

1.5

– fixed bug when data can't parsed if there performed some exercises – thanks [MENTION=4588657]signaleleven[/MENTION] for tip

– gathering number of your todays situps / rope-skipping

1.4

– profile simplified

– removed demo notification

– from post removed standalone task: you can take it from profile

– to post added universal sqlite3 binary for manual install (38)

1.3

– compatibility with app version 1.2.312 and above

– removed variables of press and rope exercises: there's no data in app

1.2

– compatibility with the app versions 1.1.511...1.2.171

– gathering total amount of exercise for the press / rope exercises

– cleaning incorrect data in the variables if there was no manual input of bedtime

1.1

– more reliable choice of data per day – now via date in a different format

– added demo for test: toast notification with a short walk and sleep statistics

1.0

– initial release