[Huawei Watch 2] aricooperdavis:
Huawei TCX Converter

A makeshift python tool that enables the extraction of TCX files from the Huawei Health app. Your phone must be a Huawei Phone or Rooted to access Huawei Health app data!

Introduction

Users of Huawei Watches/Bands sync their fitness data with the Huawei Health App. It is notoriously difficult to get the data out of this app, but through some cunning you can find HiTrack files which seem to contain some run data. This program allows you to take these files and generate .TCX files for use in your tracking app of choice (e.g. Strava). The outputted .TCX files will contain timestamped GPS, altitude, heart-rate, and cadence data where available.

Accessing the App Data

The Huawei Health app generates a 'HiTrack' file when it displays the trajectory of an particular exercise event. We can access these as follows:

Rooted phones

Navigate to data/data/com.huawei.health/files/

Copy the HiTrack files to your computer

Unrooted Huawei phones

Download the Huawei Backup App onto your phone.

Start a new unencrypted backup of the Huawei Health app data to your external storage (SD Card)

Navigate to Huawei/Backup/***/backupFiles/***/ and copy com.huawei.health.tar to your computer

Unzip the file and navigate to com.huawei.health/files/ and you should should see a number of HiTrack files

Using the Huawei TCX Converter

You need python 3 to use this tool.

Download the Huawei TCX Converter and save it as a Python script in the same folder as your HiTrack file.

The tool is run on the command line by passing it the name of your file as a command line argument. Other command line arguments:

-v - validate the final TCX file in order to check that the conversion has worked (requires xmlschema and an internet connection to download the TCX schema to check against)

-f - attempt to filter out any records in which GPS signal was lost, or cadence/heart-rate/altitude are invalid

-b - change sport to Biking

You can rename your HiTrack files if you wish, but for clarity in the examples below I leave mine exactly as I found it.

Illustration

I have copied the Huawei-TCX-Converter.py file to the directory containing my HiTrack file (HiTrack_1551732120000155173259000030001). Now I can run the tool as follows:

python Huawei-TCX-Converter.py HiTrack_1551732120000155173259000030001 -f -v

This gives me the output:

---- Input File ----
reading: OKAY
filtering: OKAY
processing gps: OKAY
processing heart-rate/cadence: OKAY

---- Details ----
sport: Running
start: 2019-03-04 20:42:00
duration: 00:07:49
distance: 1700m

---- XML file ----
generating: OKAY
saving: OKAY
validating: OKAY

Here are both the HiTrack file and the resultant TCX file for you to have a go with.

Next steps

The files are now ready (e.g. for upload to Strava). Some users have recommended the TCX Converter tool to add altitude data to your TCX files once they've been converted. This may overwrite altitude data extracted from your device, if it collects this.

Comparison

This is an image of the GPS trace from the .tcx file. The command line output above also lists the start time as 2019-03-04 20:42:00, the distance as 1.70km, and the duration as 00:07:49.

[IMG="Output from TCX generated using Huawei TCX Converter"]https://raw.githubusercontent.com/aricooperdavis/Huawei-TCX-Converter/master/Examples/Route.PNG[/IMG]

For comparison, below is the data visable on the Huawei Health App. You can see that the distance is off by about 80m, and the duration off by 1 second, but the GPS trace is spot on.

[IMG="Huawei Health Screenshot"]https://raw.githubusercontent.com/aricooperdavis/Huawei-TCX-Converter/master/Examples/Huawei_Health.png[/IMG]

Contributing

Go to the Github Hompage of this tool to contribute.

This is a very early alpha version of this tool, so please help me by making it better! There are some scripts in the Development Tools folder that I find useful for debugging. I'll accept any improvements, but if you're looking for inspiration you could start with this to-do list:

Remove reliance on using the original filename

Enable changing sport type from running (default) to biking

Read timestamped heart-rate, cadence, and altitude data where available

See if we really need to add the unused data elements (e.g. Calories) to the TCX (edit: we do as there is no minOccurs in the schema)

Check that this works for files other than those generated using the Huawei Band 2 Pro:

Confirmed working on a file from a Huawei Watch GT

Improve the distance measurement method (currently using Viscenty's Formulae)

Try and work out what tp=b-p-m is

Add interpolated heart-rate/pace/average speed data to each location element

Work on splitting data into Laps/Tracks rather than shoving it all into one

Try to call on an open API to get altitude data for location points that don't have it

Inspect other files in com.huawei.health to see if we can get any more relevant data out of them

XDA:DevDB Information

Huawei TCX Converter, Tool/Utility for the Smart Watches

Contributors

aricooperdavis

Source Code: https://github.com/aricooperdavis/Huawei-TCX-Converter

Version Information

Status: Testing

Created 2019-03-11

Last Updated 2019-03-11