Donations: https://paypal.me/piggz
Companion application for Huami Devices (such as Amazfit Bip, Cor, MiBand2/3 and GTS and GTS), Pinetime Infinitime and Bangle.js.
This application requires several supporting packages. Until Aug 2021, these were available on openrepos for the latest SailfishOS release. Updating these libs is a big pain, so they have now moved to SailfishOS::Chum. If you dont know what that is, read this https://build.merproject.org/project/show/sailfishos:chum:testing
To install Amazfish, first install the "chum" repository from the link above and "pkcon refresh" then install Amazfish.
I apologise about thie extra step, but it makes updates much easier. Pacakges in chum are automatically built for each SailfishOS release and instantly available. In the future, Amazfish may also be distributed this way, but for now, it can still be installed from here, for the current SailfishOS release.
If you already have Amazfish installed, and need to update, you will also need chum, but you may have to drop to a command line and "zypper dup" and accept and changes to the package vendor.
There are 3 tiers of supported devices:
These are devices I have, have tested and will try not to break any functioanlity for an include:
* Amazfit Bip
* Amazfit GTS
* Pinetime Infinitme
* Bangle.js
These are devices which are properly implemented in the application, but I do not have and are tested by the commuity, and include:
* Amazfit BipS
* Amazfit Bip Lite
I do not promise not to break funcaionality in these, but will fix where I can
These are devices which use a protocol that is close to another suppored device, and so is treated like that device. Your mileage may vary with these devices.
* MiBand 2/3/4
* AMzfit Cor
* Amazfit GTR
Amazfish needs to be built on OBS against a defined set of libraries. Becuase there is a delay between a Sailfish release and that release being available on OBS, there will be a delay to supporting the latest versions.
For releases of the current version built against other Sailfish releases, use the repositories at :
https://build.merproject.org/project/show/home:piggz:harbour-amazfish and
https://build.merproject.org/project/show/home:piggz:kf5
The new sport display feature requires the MapBox component. The easiest way to get this is by installing PureMaps from rinigus repository.
Powered by KEXI
As of version 0.5.1, actiivity data is retrieved into an sqlite database. Becuase I think it is important to allow individuals to be in control of their own data, and that they should have the ability to analyse it themsleves, I have chosen to store data in a KEXI compatible database. This will allow you to copy the database from the phone, and open it up inside KEXI on Linux/Windows/Mac and perform queries and reports on it. This added ability means i link to a couple of KDE libraries, which should be installed automatically.
Firmware Download - READ FIRST - I am not liable if you brick your watch ;)
Read this for info about which files to flash https://github.com/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-Firmware...
App has been tested using an amazfit bip and GTS, downloading the latest (0.1.1.45) official firmware.
The firmware is split into multiple files on these devices. With the official MiFit app, all are downloaded at once, and everything works fine. With this app, you have to send each file individually. The firmwares are available by extracting the MiFit apk, and looking in the assets/ folder for files named Mili_chaohu.*. When you select a file, its type and version will be determined, and you will be prevented from sending invalid files.
The firmware (.fw) requires a matching fotn (.ft) and resource (.res). Send the firmware first, the app will send a reboot command at the end of the transfer, and the watch will boot up into a mode where it needs the matching font and resource sent. Just wait for the app to connect again, then send the font and resource.
The following types of file exist:
firmware, resource, a-gps data, fonts
So, to re-iterate, the firmware flashing order is:
The newer devices (GTS, BipS etc) requires a server-side pairing key which requires inital pairing with an android device. To get the key, follow the instructions here and enter into Amzafish when prompted, WITHOUT 0x at the beginning.
See https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS
AGPS Download/Transfer
The official amazfit app can download and transfer the AGPS files to the watch automatically. The amazfit web site limits download of the files to those with accounts. A python script has been developped that can download the AGPS files, these can then be transferred to your phone, and downloaded to the watch using the normal "Download File" option.
Pairing Issues
Pairing works for myself, sometimes I have to try twice. If pairing doesnt work at all, then try:
Check if after all this, pairing works from the sailfish BT settings page. It should pair and connect just fine from there. f that doesnt work, my app wont either.
Not all features currently implemented
***May not work on all devices***
Uses Bluetooth Low Energy to communicate with the watch, this is known to be problematic on some devices. it is known to work on the Xiaomi Mido. Probably also works on the FP2. Official devices unknown.
Implemented
Todo
Tip:
On your device, create a symlink in /home/nemo to /home/nemo/.local/share/harbour-amazfish
This way, you can easilty copy the database off the phone using MTP.
Bip and GTS notify when the watch button is pressed. This is captured by amazfish which allows running actions on theses presses. An action can be ran on 2,3 or 4 presses. To confiure the actions, goto Settings > Application > Button Actions.
A custom script can be used, the script must be called harbour-amazfish-script.sh and be in the home folder. Example which sends a OTP code to the watch as a message:
#!/bin/sh if [ "$1" == "4" ]; then CODE=`python3 -c 'import pyotp;totp = pyotp.TOTP("XXXX Authenticator code here XXXX");print(totp.now())'` dbus-send --session --print-reply --dest=uk.co.piggz.amazfish /application uk.co.piggz.amazfish.sendAlert string:'' string:'Google OTP' string:$CODE boolean:true fi;
Source: https://github.com/piggz/harbour-amazfish
Credits to:
2.0.3
2.0.2 - Now for 4.1
2.0.0 (incl unreleased 1.9.9)
1.9.8
1.9.7
1.9.6
1.9.5 (includes unreleased changes for otehr distros)
1.9.0
1.8.7
1.8.6 (not release for sailfish)
1.8.5
1.8.2
1.8.1 - Includes 1.8.0 which was skipped
1.7.1
1.7.0
1.6.8
1.6.7
1.6.6.
1.6.5
1.6.1
1.6.0
1.5.6
1.5.5
1.5.1
1.5.0
1.4.5
1.4.0
1.3.1
1.3.0
1.2.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
0.9.2
Stop notification when call answered
Fix sending weather on interval
Add more languages for watch (only works if supported by FW)
0.9.1
Fixed crash for new users
Weather UI fixes
Whitelisted some more firmware
Translation updates
Bugfixes for daemon/ui split
0.9.0
***ONLY FOR SAILFISHOS >= 3.0.3***
Daemon/UI split
Reworked some pages to streamline them
0.8.9
Add buffer for 10 notifications when watch disconnected
0.8.8
Added deep sleep value to page
Save GPX files in data location not cache location
May install on SFOS 3.0.3 when available
0.8.7
New UI layout
Sleep statistics
0.8.5
Added step summary chart showing steps over previous 20 days from the selected day
Added auto-sync of activity data which occurs each hour
0.8.2
Fixed applying settings from the UI
0.8.1
Hopefully fixed crash introduced in 0.8.0
0.8.0
Major code restructure to better allow support for other devices (devs needed!)
Whitelist new Bip frmwares
Hopefully fixed GPS issue with new firmwares
0.7.5
Implemented sending weather
Fixed app displaying correct status when watch disconnects
Use correct icon for depecher
Fix layout of HR button
0.7.3
Updated translations
Fixed user profile settings page not opening
Comments
D_R
Sun, 2020/01/12 - 21:47
Permalink
Deleting habour-amazfish directory copletely and reinstalling Amazfish recreated the database.
My Telegram problem ist still pending thats why the logfiles here:
<code>
[nemo@Sailfish harbour-amazfish]$ /usr/bin/harbour-amazfish
-bash: /usr/bin/harbour-amazfish: No such file or directory
[nemo@Sailfish harbour-amazfish]$ /usr/bin/harbour-amazfish
harbour-amazfish-ui harbour-amazfishd
[nemo@Sailfish harbour-amazfish]$ /usr/bin/harbour-amazfish-ui
[D] unknown:0 - BluezAdapter::BluezAdapter
[D] unknown:0 - Connecting to daemon signals
[D] unknown:0 - DRIVERS: ("org.kde.kdb.sqlite")
[D] unknown:0 - Database is: "/home/nemo/.local/share/harbour-amazfish/harbour-amazfish/amazfish.kexi"
[D] unknown:0 - KDbConnection object created.
[D] unknown:0 - KDbConnection::connect() OK.
[D] unknown:0 - Using Wayland-EGL
[D] unknown:0 - "SELECT date(timestamp_dt), sum(steps) FROM mi_band_activity WHERE date(timestamp_dt) >= date('2020-01-12T00:00:00','-10 day') AND timestamp_dt <= '2020-01-12T23:59:59' GROUP BY date(timestamp_dt) ORDER BY timestamp_dt ASC"
[D] expression for onInformationChanged:208 - Information changed 8 14146
[W] unknown:518 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:518:29: Unable to assign [undefined] to float
[D] unknown:0 - "SELECT timestamp_dt, raw_kind, raw_intensity FROM mi_band_activity WHERE timestamp_dt >= date('2020-01-12T11:59:00','-10 day') AND timestamp_dt <= '2020-01-12T12:01:00' ORDER BY timestamp_dt ASC"
[W] unknown:518 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:518:29: Unable to assign [undefined] to float
[D] unknown:0 - "SELECT date(timestamp_dt), sum(steps) FROM mi_band_activity WHERE date(timestamp_dt) >= date('2020-01-12T00:00:00','-10 day') AND timestamp_dt <= '2020-01-12T23:59:59' GROUP BY date(timestamp_dt) ORDER BY timestamp_dt ASC"
[W] unknown:447 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:447:13: QML State: Binding loop detected for property "when"
[W] unknown:447 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:447:13: QML State: Binding loop detected for property "when"
[D] expression for onInformationChanged:208 - Information changed 8 14146
[D] unknown:0 - "SELECT timestamp_dt, heartrate FROM mi_band_activity WHERE heartrate < 255 AND timestamp_dt >= '2020-01-12T00:00:00' AND timestamp_dt <= '2020-01-12T23:59:59' ORDER BY timestamp_dt ASC"
[D] unknown:0 - "SELECT timestamp_dt, steps FROM mi_band_activity WHERE timestamp_dt >= '2020-01-12T00:00:00' AND timestamp_dt <= '2020-01-12T23:59:59' ORDER BY timestamp_dt ASC"
[D] unknown:0 - "SELECT timestamp_dt, ((raw_intensity / 255.0) * 100) FROM mi_band_activity WHERE timestamp_dt >= '2020-01-12T00:00:00' AND timestamp_dt <= '2020-01-12T23:59:59' ORDER BY timestamp_dt ASC"
[W] unknown:518 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:518:29: Unable to assign [undefined] to float
[W] unknown:518 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/PulleyMenuBase.qml:518:29: Unable to assign [undefined] to float
[D] unknown:0 - "SELECT timestamp_dt, heartrate FROM mi_band_activity WHERE heartrate < 255 AND timestamp_dt >= '2020-01-12T00:00:00' AND timestamp_dt <= '2020-01-12T23:59:59' ORDER BY timestamp_dt ASC"
[D] unknown:0 - "SELECT timestamp_dt, steps FROM mi_band_activity WHERE timestamp_dt >= '2020-01-12T00:00:00' AND timestamp_dt <= '2020-01-12T23:59:59' ORDER BY timestamp_dt ASC"
[D] unknown:0 - "SELECT timestamp_dt, ((raw_intensity / 255.0) * 100) FROM mi_band_activity WHERE timestamp_dt >= '2020-01-12T00:00:00' AND timestamp_dt <= '2020-01-12T23:59:59' ORDER BY timestamp_dt ASC"
</code>
piggz
Sun, 2020/01/12 - 22:02
Permalink
Does it work now?
carmenfdezb
Sun, 2020/01/12 - 13:22
Permalink
Hi @piggz!! Thanks for your excellent app!! It works perfect with my amazfit bip, but for some reason, Amazfish doesn't show info about steps in the first page:
https://ibb.co/YbSVJ6R
What am I doing wrong?
piggz
Sun, 2020/01/12 - 22:07
Permalink
Nothing, its just I moved the steps info to the page on the right.
carmenfdezb
Mon, 2020/01/13 - 01:06
Permalink
Ok, thanks for your answer!
D_R
Thu, 2020/01/09 - 13:18
Permalink
I have some trouble with telegram:I'm blocked now...
But I investigated the problem: I can't find any database. Uninstalling and reinstallin amazfish doesn't help. Is there any script to recreate the database?
vige
Thu, 2020/01/09 - 10:21
Permalink
The new disconnect notification is awesome - I would have forgotten my phone already twice today without it :-D
D_R
Mon, 2020/01/06 - 23:51
Permalink
How can I catch you on Telegram?
piggz
Tue, 2020/01/07 - 00:00
Permalink
@adampigg
D_R
Mon, 2020/01/06 - 23:26
Permalink
Yes I can
D_R
Mon, 2020/01/06 - 08:00
Permalink
Happy new year... Thank you for the update of Amazfish. The database problem is still existing in v1.0 on XA2. I can't see any graphs an plots.
piggz
Mon, 2020/01/06 - 10:17
Permalink
can you catch me on telegram with sone logs?
ferlanero
Thu, 2020/01/02 - 20:22
Permalink
Contribution to buy an Amazfit GTS and ships it to @adampigg, so that he can work on adapting Amazfish and make it works on the GTS.
This should make Amazfish working for the new #Xiaomiwatchcolor (Bip2 or Lite) https://leetchi.com/c/amazfish-for-amazfit-gts
Branja
Wed, 2019/12/04 - 22:39
Permalink
I finally installed Sailfish X on my Xperia XA2, and I can confirm that I can pair neither Amazfit BIP lite nor Xiaomi Mi Band 2. I tried pretty much everything.
edit: And as I saw on Twitter, the developer of this app has broken his watch by accident. :(
piggz
Wed, 2019/12/04 - 22:53
Permalink
Its ok, i glued it back together! Im sure you will get it to pair, perhaps supply logs via github.
Branja
Thu, 2019/12/05 - 10:33
Permalink
Amazing! I know it's a noobish question but, how can I do that?
edit: I successfully connected Mi Band 2 but I still can't connect BIP Lite. It says authfailed. I read about it online a little bit (on the Gadgetbridge wiki) and it turns out that all the newer devices, including BIP Lite, need an official app in order to pair because they require a server-based pairing. Now, there is an easy way to obtain a pairing key on an Android-based phone via a cracked Mi Fit app. Is there a way that You can implement pairing keys into your app or should I sell my BIP Lite and order an original BIP watch? p.s. Sorry for bothering you and demanding certain things. I am just a noob who feels love for this kind of technology. I will help you out however I can.
piggz
Thu, 2019/12/05 - 14:18
Permalink
ive just read up on server based pairing, and i should be able to implement it, but you will have to expect to wait a little while.
Branja
Thu, 2019/12/05 - 15:16
Permalink
Not a problem, kind sir. I will wait as long as it takes. Please, let me know if I need to test something out.
alex000090
Sun, 2019/11/24 - 09:37
Permalink
Good morning!
I try flash new firmware for watch, but when I open FW.latin file (first), the program write "Invalid" in type string. I use last version of the program.
Branja
Tue, 2019/11/19 - 22:46
Permalink
Guys, I am planning to buy a Sony Xperia XA2 and an Amazfit BIP Lite. Can somebody confirm that these two will work together?
jpn9s
Fri, 2019/11/22 - 09:42
Permalink
I can confirm that Amazfit Cor with Amazfisf app works quite well in my XA2 Sfos 3.2.0.12. I suppose Cor might be quite near Bip, but I do not know Bip Lite.
Branja
Mon, 2019/12/02 - 12:32
Permalink
Thank you for your reply. I am a bit worried because I read that those new devices (BIP Lite, Mi Band 4, Amazfit GTR) require a server-based paring at first. This means that one needs to pair either of these devices with a Mi Fit app and then obtain a pairing key (at least, that's the case on Android). I ordered an Amazfit BIP Lite, and I want to buy an Xperia XA2 and to run Sailfish on it. I would be hugely disappointed in case I cannot do that, and that I need to return to Android.
foffo
Wed, 2019/10/02 - 22:06
Permalink
ronny_b
Mon, 2019/09/30 - 20:34
Permalink
I no longer get my AmazfitBIP paired. Amazfish runs on the XperiaX with Sailfish 3.1.0.11. The clock is displayed in the Bluetooth settings under paired devices. It is also found by the app and the following text is displayed:
Connecting to watch...
/org/bluez/hci0/dev_F0_1A_...
pairing
That's all there is to it.
What have I already tried...
- Switch Bluetooth off and on again
- In the settings of the "Stop and Start Service" app
When I connect the clock in the shell via bluetoothctl, I get the following:
[Amazfit Bip Watch]# info F0:1A:...
Device F0:1A:... (random)
Name: Amazfit Bip Watch
Alias: Amazfit Bip Watch
Paired: yes
Trusted: yes
Blocked: no
Connected: yes
LegacyPairing: no
UUID: Vendor specific
Besides, the clock now shows connected, only the app unfortunately does not.
Here is an excerpt from the journal:
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - BluezAdapter::stopDiscovery
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - BluezAdapter::StopDiscovery: ""
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - BluezAdapter::matchDevice:looking for: "Amazfit"
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - Found: QVariant(QString, "Jolla-xxx")
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - Found: QVariant(QString, "Xperia X")
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - Found: QVariant(QString, "Amazfit Bip Watch")
Sep 30 19:07:19 Sailfish i[5258]: [D] unknown:0 - BluezAdapter::deviceName:looking for: "/org/bluez/hci0/dev_F0_1A_..."
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - DeviceInterface::pair: "Amazfit Bip Watch" "/org/bluez/hci0/dev_F0_1A_..."
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - DeviceFactory::createDevice: requested device of type: "Amazfit Bip Watch"
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - QBLEDevice::setDevicePath
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - true
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - AbstractDevice::pair
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - DeviceInterface::onConnectionStateChanged "pairing"
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - DeviceInterface::onConnectionStateChanged "pairing"
Sep 30 19:07:19 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - QBLEDevice::pair
Sep 30 19:07:19 Sailfish i[5258]: [D] pair:102 - Pair result:
Sep 30 19:07:19 Sailfish i[5258]: [D] expression for onConnectionStateChanged:202 - pairing
Sep 30 19:07:19 Sailfish i[5258]: [D] expression for onConnectionStateChanged:202 - pairing
Sep 30 19:08:00 Sailfish harbour-amazfishd[5654]: [D] unknown:0 - DeviceInterface::onRefreshTimer
What else can I try? On the PC with Android emulator and "Gadgetbridge" it can be connected without problems.
Thanks Ronny
piggz
Wed, 2019/10/02 - 22:46
Permalink
Does the device mac address match in all cases? You could try fully resetting the application with
dconf reset -f /uk/co/piggz/amazfish
ronny_b
Sat, 2019/10/05 - 17:41
Permalink
Thanks for the answer. I reserve that as my last option.
I have tried pairing the phone with another device. After I have removed this connection, the Amazfish app connects automatically. Unfortunately, the activity data does not arrive completely in the database. After about 25 hours no more lines are created in the Kexi-file and nothing is displayed in the diagram. In the home directory 7.4GB are still free.
So I probably can't get around it...
Ronny
piggz
Sat, 2019/10/05 - 19:39
Permalink
Yeah, i have a known issue with how times are saved for the last sync, ill be working on it soon
EEvnos
Mon, 2019/09/30 - 20:06
Permalink
This is amazing software and works VERY well.
The one issue I'm having is that when setting the Distance Unit to Imperial (under Device Settings) it does not seem to save the settings.
The settings on the watch don't change and the app is defaulted back to Metric when going back into the settings.
piggz
Wed, 2019/10/02 - 22:43
Permalink
Thanks for the feedback. Could you you rasie an Issue on github?
localhorst
Thu, 2019/09/19 - 09:33
Permalink
Pages