- Introduction
- Command line arguments overview
- Copyright and license
- Encrypted zip file conversion example
- Features
- huawei health
- Json file conversion example
- Release notes
- Requirements
- Single file conversion examples
- Step 1 – install python
- Step 1 – request your data in the huawei health app
- Step 2 – download your requested data
- Step 3 – convert the data with hitrava
- Step 3 – download and extract stand-alone 7-zip
- Step 4 – upload your data to strava
- Zip file conversion example
- Узнайте больше о Huawei
Introduction
Hitrava converts health activities registered using a Honor or Huawei activity tracker or smart watch in the
Huawei Health app into a file format that can be
directly uploaded to Strava.
Command line arguments overview
usage: Hitrava.py [-h] [-z ZIP] [-p PASSWORD] [-j JSON] [--json_export] [-f FILE]
[-s {Walk,Run,Cycle,Swim_Pool,Swim_Open_Water}] [-t TAR]
[--from_date FROM_DATE] [--pool_length POOL_LENGTH]
[--tcx_insert_altitude_data] [--output_dir OUTPUT_DIR]
[--use_original_filename]
[--output_file_prefix OUTPUT_FILE_PREFIX]
[--suppress_output_file_sequence] [--validate_xml]
[--log_level {INFO,DEBUG}]
optional arguments:
-h, --help show this help message and exit
--log_level {INFO,DEBUG}
Set the logging level.
JSON options:
-z ZIP, --zip ZIP The filename of the Huawei Cloud ZIP file containing
the JSON file with the motion path detail data to
convert. The JSON file will be extracted to the
directory in the --output_dir argument and conversion
will be performed.
-p PASSWORD, --password PASSWORD
The password of the encrypted Huawei Cloud ZIP file.
Required for encrypted ZIP files only.
-j JSON, --json JSON The filename of a Huawei Cloud JSON file containing
the motion path detail data to convert or the filename
of the Huawei Cloud ZIP file containing the JSON file
with the motion path detail data (this will work
identical to --zip argument above).
--json_export Exports a file with the JSON data of each single
activity that is converted from the JSON file in the
--json argument. The file will be exported to the
directory in the --output_dir argument with a .json
file extension. The exported file can be reused in the
--json argument to e.g. run the conversion again for
the JSON activity or for debugging purposes.
FILE options:
-f FILE, --file FILE The filename of a single HiTrack file to convert.
-s {Walk,Run,Cycle,Swim_Pool,Swim_Open_Water}, --sport {Walk,Run,Cycle,Swim_Pool,Swim_Open_Water}
Force sport for the conversion. Sport will be auto-
detected when this option is not used.
TAR options:
-t TAR, --tar TAR The filename of an (unencrypted) tarball with HiTrack
files to convert.
DATE options:
--from_date FROM_DATE
Applicable to --json and --tar options only. Only
convert HiTrack information from the JSON file or from
HiTrack files in the tarball if the activity started
on FROM_DATE or later. Format YYYY-MM-DD
SWIM options:
--pool_length POOL_LENGTH
The pool length in meters to use for swimming
activities. If the option is not set, the estimated
pool length derived from the available speed data in
the HiTrack file will be used. Note that the available
speed data has a minimum resolution of 1 dm/s.
TCX options:
--tcx_insert_altitude_data
When an activity has altitude information, inserts the
last known altitude in every track point of the
generated TCX file.
--tcx_use_raw_distance_data
In JSON or ZIP mode, when using this option the
converted TCX files will use the raw distance data as
calculated from the raw HiTrack data. When not
specified (default), all distances in the TCX files
will be normalized to match the original Huawei
distance.
OUTPUT options:
--output_dir OUTPUT_DIR
The path to the directory to store the output files.
The default directory is ./output.
--use_original_filename
In single FILE or TAR mode, when using this option the
converted TCX files will have the same filename as the
original input file (except from the file extension).
--output_file_prefix OUTPUT_FILE_PREFIX
Adds the strftime representation of this argument as a
prefix to the generated TCX XML file(s). E.g. use
%Y-%m-%d- to add human readable year-month-day
information in the name of the generated TCX file.
--suppress_output_file_sequence
Suppresses the sequence number suffix in the filenames
of converted TCX files when converting activities in
ZIP or JSON mode.
--validate_xml Validate generated TCX XML file(s). NOTE: requires
xmlschema library and an internet connection to
retrieve the TCX XSD.
Copyright and license
Copyright (c) 2022-2020 Christoph Vanthuyne
Licensed under the Non-Profit Open Software License version 3.0 from Hitrava version 3.1.1 onward.
Read the full license information here.
If you’re more into a TL;DR approach, start here.
Encrypted zip file conversion example
Use the command below to convert all activities available in the encrypted ZIP file with the Huawei
Privacy data (here with filename HiZip.zip) that were started on October, 3rd, 2022 or later.The ZIP file was encrypted with password 123456 provided in the Huawei Health app.The following files will be generated in folder ./my_output_dir:
- JSON files with the raw JSON data of a single activity (.json file extension).
- HiTrack files with the unconverted source data of a single activity (no extension, filenames start with HiTrack_).
- Converted TCX files for upload to Strava (.tcx file extension).
python Hitrava.py --zip HiZip.zip --password 123456 --json_export --from_date 2022-10-03 --output_dir my_output_dir
Features
- Recognizes and converts the following activity types from Huawei Health to Strava:
- Conversion contains generic activity information such as GPS track, distance, duration, calorie consumption (as
available during recording of the activity). - When available and depending on the activity type, conversion includes health data from your Huawei or Honor smart
watch / fitness band: - Conversion is done using the centralized data from Huawei Health. In principle, any recent Huawei or Honor smart watch
or fitness band should be supported, if you see the data in Huawei Health, e.g.- Huawei smart watches: e.g. Huawei Watch GT2
- Huawei fitness bands: e.g. Huawei Band 4, Huawei Band 4 Pro
- Honor smart watches: e.g. Honor MagicWatch 2
- Honor fitness bands: e.g. Honor Band 4, Honor Band 5
huawei health
English, Amharic, Arabic, Assamese, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Burmese, Cambodian, Catalan, Croatian, Czech, Danish, Dutch, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Hebrew, Hindi, Hits in Russian, Hungarian, Indonesian, Italian, Japanese, Javanese, Kannada, Kazakh, Korean, Laotian, Latvian, Lithuanian, Macedonian, Maithili, Malay, Malayalam, Maori, Marathi, Mongolian, Nepali, Norwegian Bokmål, Oriya, Persian, Polish, Portuguese, Punjabi, Romanian, Serbian, Simplified Chinese, Singhalese, Slovak, Slovenian, Spanish, Swahili, Swedish, Tagalog, Tamil, Telugu, Thai, Tibetan, Traditional Chinese, Turkish, Ukrainian, Urdu, Uzbek, Vietnamese
Json file conversion example
Use the command below to convert all activities available in the motion path JSON file from the requested Huawei
Privacy data that were started on October, 3rd, 2022 or later. Source HiTrack files and converted TCX files will be
generated in folder ./my_output_dir/json
python Hitrava.py --json "motion path detail data.json" --from_date 2022-10-03 --output_dir my_output_dir/json
Same as above, but also create an additional export file for each converted activity containing the raw JSON data of
that activity from the motion path JSON file.
python Hitrava.py --json "motion path detail data.json" --json_export --from_date 2022-10-03 --output_dir my_output_dir/json
Release notes
For a full changelog of all versions, please look in CHANGELOG.md.
Requirements
To use Hitrava, you need:
Single file conversion examples
The example below converts extracted file HiTrack_12345678901212345678912 to HiTrack_12345678901212345678912.tcx in
the ./output directory
python Hitrava.py --file HiTrack_12345678901212345678912
The next example converts extracted file HiTrack_12345678901212345678912 to HiTrack_12345678901212345678912.tcx in
the ./my_output_dir directory. The program logging level is set to display debug messages. The converted file is
validated against the TCX XSD schema (requires installed xmlschema library and an internet connection).
python Hitrava.py --file HiTrack_12345678901212345678912 --output_dir my_output_dir --validate_xml --log_level DEBUG
The following example converts an extracted file HiTrack_12345678901212345678912 to HiTrack_12345678901212345678912.tcx
in the ./output directory and forces the sport to walking.
python Hitrava.py --file HiTrack_12345678901212345678912 --sport Walk
The next example converts an indoor swimming activity in an extracted file HiTrack_12345678901212345678912 to
HiTrack_12345678901212345678912.tcx. The length of the pool in meters is specified to have a more accurate swimming data
calculation.
python Hitrava.py --file HiTrack_12345678901212345678912 --pool_length 25
Step 1 – install python
Only required if you don’t have a (suitable) python installation on your system.
Step 1 – request your data in the huawei health app
- On your phone, open the Huawei Health app.
- Tap the ‘Me’ button in the lower right-hand corner of the main screen.
- Now tap on your account name on top of the screen.
- Tap on ‘Privacy Center’.
- Tap ‘Request Your Data’.
- Select ‘Health’ from the list and confirm your selection.
- You will be obligated to enter a password to encrypt the requested data with. You will need this password later in
step 3 below. - Follow any further in-app instructions.
- Wait for the mail from Huawei to arrive with a link to download the data (ZIP file).
Step 2 – download your requested data
- In the mail from Huawei, click on the link to download your data and follow the instructions.
- Put (a copy of) the downloaded ZIP file in the Hitrava installation folder and rename it to HiZip.zip.
Step 3 – convert the data with hitrava
Tip: If you’re on Windows and you’re not familiar with the Command Prompt or just want to do a quick
conversion with default arguments, you can use the Run_Hitrava_Decrypt.cmd batch file.
- Open the Run_Hitrava_Decrypt.cmd file with a text editor and change the password 123456 to the password you
provided in step 2 above. - double-click the Run_Hitrava_Decrypt.cmd file in the installation folder of Hitrava.
This will convert all available activities in the ZIP file from the previous step.
IMPORTANT: You must replace the password 123456 with the password you provided in step 2 above.
Hitrava.py --zip HiZip.zip --password 123456 --json_export
Step 3 – download and extract stand-alone 7-zip
NOTE: This step is required to convert encrypted Huawei Health ZIP files.
7-Zip Extra: standalone console version, 7z DLL, Plugin for Far Manager
- Extract the file 7za.exe from the downloaded archive and place it in your Hitrava installation folder from step 2
above. Your Hitrava installation folder should now contain at least the following files.
Hitrava.py
7za.exe
Run_Hitrava_Decrypt.cmd
Step 4 – upload your data to strava
You can now go to the Strava website to import your data.
Zip file conversion example
Use the command below to convert all activities available in the ZIP file with the Huawei
Privacy data (here with filename HiZip.zip) that were started on October, 3rd, 2022 or later. The following files will
be generated in folder ./my_output_dir:
- JSON files with the raw JSON data of a single activity (.json file extension).
- HiTrack files with the unconverted source data of a single activity (no extension, filenames start with HiTrack_).
- Converted TCX files for upload to Strava (.tcx file extension).
python Hitrava.py --zip HiZip.zip --json_export --from_date 2022-10-03 --output_dir my_output_dir