cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
527 stars 625 forks source link

[health 3.0.5] An extra value comes to SLEEP_ASLEEP from Apple Health kit #330

Open ViktorQA97 opened 3 years ago

ViktorQA97 commented 3 years ago

Remember to specify the plugin name in the title! health 3.0.5

Device and OS

Describe the bug

In the "Apple Health kit" app, my indicator of sleep is 6 hours and 15 minutes (375 minutes awake) on 04/07/21(screenshot 1 and 3)

Today (04/07/21) received data on sleep via your "health" library for Flutter. However, more data on sleep came (screenshot 2)

{"value": 374.98333333333335, "unit": "HealthDataUnit.MINUTES", "dateFrom": "2021-04-07 03: 40: 00.000", "dateTo": "2021-04-07 09: 54: 59.000" , "dataType": "HealthDataType.SLEEP_ASLEEP", "platform": "PlatformType.IOS"}, 
{"value": 433.98333333333335, "unit": "HealthDataUnit.MINUTES", "dateFrom": "2021-04-07 03 : 39: 00.000 "," dateTo ":" 2021-04-07 10: 52: 59.000 "," dataType ":" HealthDataType.SLEEP_ASLEEP "," platform ":" PlatformType.IOS "}

In the data of the past days, I also noticed the presence of one extra value (usually it is the largest one).

Actual behavior

The main problem is that when adding the SLEEP_ASLEEP data, I get the total asleep value more than expected.

Expected behavior

After adding all the data of the SLEEP_ASLEEP type, I get the correct total value in minutes as in the "Apple Health kit" application

Screenshots

  1. screenshot 1
  2. screenshot 2
  3. screenshot 3
mehraj-numen commented 2 years ago

I am facing same issue with steps data [IOS], getting value more than expected.

@ViktorQA97 Are you able to resolve this issue? if yes, please help me how to resolve this issue.

jonchui commented 1 year ago

I ran into this too

This is probably b/c IOS records sleep from all apps, and often times the samples overlap in time

so you'll have to filter out by a certain source, OR decide by time (if the sources overlap)

ibrahimbroachwala commented 1 year ago

@jonchui I am fetching sleep_in_bed data from HealthKit. It's fetching from iPhone and Apple watch both as sources and adding extra sleep minutes. Can you share a snippet how can we filter by source ? I couldn't find any identifier to match to filter the source. I tried some code to remove the overlapped time, still the total minutes are different in my app vs Health app on iOS. Any help is appreciated. Thanks.