• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

Share exercise data from the Huawei Health app

Search This thread
Feb 27, 2019
17
17
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:

Code:
python Huawei-TCX-Converter.py HiTrack_1551732120000155173259000030001 -f -v
This gives me the output:

Code:
---- 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.

Route.PNG


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.

Huawei_Health.png


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
 
Last edited:

mrlb

Senior Member
Sep 2, 2005
82
11
Newcastle
Thanks for sharing man! I can't work out if I have a use for this, because I'm already using google fit and strava. But I would like to be able to extract sleep history from Huawei Health. Is that something you would plan to look at? I guess step data and continuous heart rate would be good too. I don't like being locked into an app with no cloud backup/access.
 
Feb 27, 2019
17
17
I would like to be able to extract sleep history from Huawei Health.

So far I haven't found anything resembling sleep data in those HITRACK files - I think sleep data must be held elsewhere. I will keep poking around, but at the moment it's probably not at the forefront of my efforts as the other databases are encrypted so I cannot access them to read info. I'll still add it to the todo list though!
 
  • Like
Reactions: Alaadragonfire

negbd

Member
Mar 4, 2013
6
0
France
Dears, Thx for the type but i'm locked in step with the tar files. I've backuped it with Hisuite on my computer (not SD 'cause i didn't have it - bad version of P20).
But i can't extract the TAR files, it's seems it's corrupt. I've already tried to save the output TAR to different folders on my computer, on my local network etc.. but same issue. TAR is corrupte.
Did you have any idea ?
 

TheJoker71

Senior Member
Mar 1, 2013
64
4
works great... everything is great... only off by several number but overall satisfied...

also i have the schema file "TrainingCenterDatabasev2.xsd"... where should i put it? or this should be done automatically? thanks...
 
Last edited:

carlosgeraldo

Senior Member
Dec 23, 2016
55
17
It worked very well !! How to implement more things in this great code? for example the sport swimming I tried most does not convert to .tcx so it is not possible to import to strava. how to import racing data about time and cadence in every 1km race? Thanks for what we already have works very well
 

thierrysko

Member
Jun 16, 2019
6
0
Dears, Thx for the type but i'm locked in step with the tar files. I've backuped it with Hisuite on my computer (not SD 'cause i didn't have it - bad version of P20).
But i can't extract the TAR files, it's seems it's corrupt. I've already tried to save the output TAR to different folders on my computer, on my local network etc.. but same issue. TAR is corrupte.
Did you have any idea ?

Hi

maybe somehow crypted TAR ?
 

99x

Senior Member
Nov 21, 2011
822
389
Warwickshire
Thanks for making this it's really useful, shame the GT watch GPS is not very accurate and/or low sampling rate. The same run/cycle etc recorded on other devices is far more accurate and detailed. A 30 mile bike ride was 1.5 miles less on the Huawei watch! (Nothing you can do about that as it's the same in health app and after exporting to strava sadly)
 

Rohan Sawant

Member
Mar 1, 2015
15
5
I was trying to create a backup using the HiSuite and the Backup and Restore app but the Heath App does not show up in the app list, anymore.

Can someone else confirm this?
 

rav3ns

Member
Jul 2, 2010
14
0
Hello,
I'm planning to buy huawei smartband, but i want to export heart rate to google fit / garmin app...etc

Heart rate about the day, not about an activity.

With this is possible?
 

TheJoker71

Senior Member
Mar 1, 2013
64
4
Hi sir/mam, im having issue running the latest version 2.3... im still using the old version with -v -b arguments... it is working with me but not the newest version 2.3... here are my batch file and error result... and how to use XML validation... i already downloaded the XSD file... but still nothing... then how to use PIP INSTALL XMLSCHEMAS... thanks...

----------------------------
batch file
---------------------------- @Echo off
echo.
"C:\Users\*******\AppData\Local\Programs\Python\Python37\python.exe" Huawei-TCX-Converter.py --file %1 --sport Cycle
echo.
pause

----------------------------
error output
----------------------------
Info - External library xmlschema could not be imported.
It is required when using the --validate_xml argument.
It can be installed using: pip install xmlschema
Traceback (most recent call last):
File "Huawei-TCX-Converter.py", line 926, in <module>
class TcxActivity:
File "Huawei-TCX-Converter.py", line 944, in TcxActivity
filename_prefix: str = None):
NameError: name 'xmlschema' is not defined
 
Last edited:

Marmock38

New member
Sep 23, 2019
1
0
python Huawei-TCX-Converter.py --file HiTrack_1569078600000156908002700030001
File "Huawei-TCX-Converter.py", line 54
def __init__(self, activity_id: str, activity_type: str = TYPE_UNKNOWN):
^
SyntaxError: invalid syntax
I get this error if anyone can help me
 

rdsk

New member
Sep 25, 2019
4
0
python Huawei-TCX-Converter.py -f HiTrack_1551732120000155173259000030001 - this syntax works for me in newer version of python + dont forget to install schema = pip install xmlschema = search for youtube video called PIP INSTALL COMMAND IN PYTHON 3.6 ( i cannot post links as new user so sorry for that)
BUT
i also have honor band 4 running edition with tracking angles, forces etc. When i create files from those records - data are not here becouse they are not defined to translate in python program. can somebody help me with providing sources from garmin etc so i will try to add it by myself if nobody is interested to do this ?

the file from HB 4 running edition consists of those records : tp=rp;k=5;gct=532;gia=12;sa=65;ee=15;fsp=0;wsp=1;hsp=1;
can somebody help me to translate this?
from my own research so far -
1. ground contact time = GCT
2. Landing impact = gia
3. eversion excursion = ee
4. swing angle = sa
5. forefoot strike pattern = fsp
6. W? midfoot strike pattern = wsp
7. Heel strike pattern = hsp

How those things should be written in tcx files?
 
Last edited:

avvocato.rossi

Senior Member
Nov 13, 2009
109
3
not work

Hello
I don'know python, I just launch the IDLE program from windows menu, I copied the script in the same hitrack folder and I type in the python shell the command
python Huawei-TCX-Converter --file HiTrack_myfilename

It shows syntax error and higlight in red the command "huawei"
Can you explain easily how to proceed? Is there a rule where put the folder?
Thanks
 

rdsk

New member
Sep 25, 2019
4
0
Hello
I don'know python, I just launch the IDLE program from windows menu, I copied the script in the same hitrack folder and I type in the python shell the command
python Huawei-TCX-Converter --file HiTrack_myfilename

It shows syntax error and higlight in red the command "huawei"
Can you explain easily how to proceed? Is there a rule where put the folder?
Thanks

just read my previous post
syntax python Huawei-TCX-Converter.py -f HiTrack_1551732120000155173259000030001 works
 

YiannisM

Member
Mar 30, 2006
13
1
regarding Distance Calculation (haversine instead of viscenty)y)

@aricooperdavis

Checked another calculation for distance between coordinates (haversine) but the results were the same (in your example: 1700.43m for Viscenty, 1699.3m for Haversine). I really do not know which is the algorithm used in HUAWEI Health (80 meters difference)

FYI, code used:
def _haversine(self, point1: tuple, point2: tuple) -> float:

R = 6378137
Phi1 = math.radians(point1[0])
Phi2 = math.radians(point2[0])
dPhi = math.radians(point2[0]-point1[0])
dLamda = math.radians(point2[1]-point1[1])
a = math.sin( dPhi/2 ) * math.sin(dPhi/2) + math.cos(Phi1) * math.cos (Phi2) * math.sin (dLamda/2)* math.sin(dLamda/2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
d = R * c
return round (d,6)

https://www.movable-type.co.uk/scripts/latlong.html
 
  • Like
Reactions: aricooperdavis

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    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:

    Code:
    python Huawei-TCX-Converter.py HiTrack_1551732120000155173259000030001 -f -v
    This gives me the output:

    Code:
    ---- 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.

    Route.PNG


    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.

    Huawei_Health.png


    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
    1
    I would like to be able to extract sleep history from Huawei Health.

    So far I haven't found anything resembling sleep data in those HITRACK files - I think sleep data must be held elsewhere. I will keep poking around, but at the moment it's probably not at the forefront of my efforts as the other databases are encrypted so I cannot access them to read info. I'll still add it to the todo list though!
    1
    Hi all,
    I have created a petition asking Huawei to add export and sync to Strava. Please sign if you agree.

    https://ipetitions.com/petition/huawei-please-add-gpxtcx-export-and-sync-to

    Thanks
    1
    regarding Distance Calculation (haversine instead of viscenty)y)

    @aricooperdavis

    Checked another calculation for distance between coordinates (haversine) but the results were the same (in your example: 1700.43m for Viscenty, 1699.3m for Haversine). I really do not know which is the algorithm used in HUAWEI Health (80 meters difference)

    FYI, code used:
    def _haversine(self, point1: tuple, point2: tuple) -> float:

    R = 6378137
    Phi1 = math.radians(point1[0])
    Phi2 = math.radians(point2[0])
    dPhi = math.radians(point2[0]-point1[0])
    dLamda = math.radians(point2[1]-point1[1])
    a = math.sin( dPhi/2 ) * math.sin(dPhi/2) + math.cos(Phi1) * math.cos (Phi2) * math.sin (dLamda/2)* math.sin(dLamda/2)
    c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
    d = R * c
    return round (d,6)

    https://www.movable-type.co.uk/scripts/latlong.html
    1
    I find that this solution works much better:

    https://github.com/CTHRU/Hitrava

    You just request your data from Huawei, the you can download it as a zip file, rename it to hizip.zip, run the script against it and you have all your workouts as tcx files.