Mi Band 4 on Sailfish XA2 Ultra

This is how sleep is calculated

The activity values are taken from here

Read that and try to come up with a calculation for sleep :smiley:

1 Like

I have “just” estimated that Activity Kind over 109 (110 up) are sleep. From here I have analysed the pulse.
Low steady pulse ~ Deep sleep
Higher steady pulse ~ Light sleep
Varying pulse ~ REM sleep
The low and high pulse has been calculating out from the sleeping pulse (average/standard deviation/some factors).

Here this night your calculation gives:
Deep sleep: 3:46
Total sleep: 8:46

According to mine Excel:
Deep sleep: 3:44
Total sleep: 8:50 (3:44 + 3:20 + 1:46)
This include some sleep during the afternoon (which I did not have( and some non sleeping time during the night (which I had).

I have only been doing programing in 2 languages, Lisp for many years ago and VBA in Excel. Therefore I have some issue reading the above code - but I can see that in the code:
if (activity == 123 || (in_sleep == false && activity)) {
//qDebug() << “Starting sleep tracking”;
that 123 means start sleep 124 should be end sleep. This I do not have in my Excel.

Sometimes the 124 or 123 do not end/start a sleep :frowning:

I will see how to code in the 123 in my Excel.

One more thing.

After downloading the data there is still 1 hour with not data. I do not know if you have tried to solve this in your latest update 22-09-2020.

Now after cleaning the rest-time as not sleeping-time I get the following figures:
Deep sleep: 3:44
Total sleep: 8:16 (3:44 + 3:02 + 1:30)

I will in the future check yours up against mine Excel.

You can download the Excel on the following webpage:
Excelfish

I have now checked some more sleeping data in my Excel with the App and not always it is the same. This maybe because mine Excel finds sleeping time for a 24 hours period. Also, not always the deep sleeping time is the same, this because the used algorithm is different.

New.
Half sleeping added. The sleep is now calculated as below:
105,106,123 Start sleep
108,124 Stop sleep
80-99 Half sleeping or half awake - depending on heart rate like “255-62-255-60”
112,122 Sleep
If Stop/Start sleeping is missing, heart rate like “255-62-255-60” will clarify the sleep.

New Excel can be found on my webpage.

1 Like

Hi, I just got a Mi Band 4 and managed to set it up thanks to this useful thread.
I also tried to download your Excel template, but it is not available anymore? Any chance to get it?

Hi
I have now updated the homepage and you can now download the latest version.
If you get this Excel up running, please check if you also have the issue with 1 hour gap with no data stored after downloading data from the Band.

1 Like

Thanks! I downloaded it and will look into it. As I use LibreOffice, it seems that it does not work right out of the box, but I will investigate.

I confirm that I have the identical issue with 1 hour no data after the sync. I have no idea, but is this not an issue on the Mi Band side, as the sync just fetches the data that the Band has saved since the last one…

Hi

There is a small Macro but 99% of the Excel program should work anyway.

What you shall correct is the xLookUp. It is at very good new function in Excel, what you have to do is to combine a vLookUp with a ……. cannot remember :blush:

I have created a case on https://github.com/piggz/harbour-amazfish/issues/136 concerning the 1 hour gap and piggz have been looking at it but it has not been solved, so maybe it is not that easy