Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HEALTH 7.0.1] SLEEP_AWAKE returning all types of sleep information(Rem, Light, deep,awake) #774

Closed
Kam5678 opened this issue Jul 19, 2023 · 4 comments
Assignees
Labels
bugfix a bug fix

Comments

@Kam5678
Copy link

Kam5678 commented Jul 19, 2023

After doing some intensive debugging it seems like following function call returns all types of sleep data in its list: while what its suppose to return is only awake data

await health.getHealthDataFromTypes(leftBound, rightBound, [HealthDataType.SLEEP_AWAKE]);

Full snippets of code:

     for (int i = dropdownValue!; i > 0; i -= 1) {
        DateTime leftBound = now.subtract(Duration(days: i));
        DateTime rightBound = now.subtract(Duration(days: i - 1));
        
...
      List<HealthDataPoint> awakeData = await health
          .getHealthDataFromTypes(
              leftBound, rightBound, [HealthDataType.SLEEP_AWAKE]);
   

I printed out the list information data:

  for(int i=0 ; i< awakeData.length ; i++){

              print(awakeData[i]);

            }

To get the following output:

I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 13.000016666666667,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 03:46:00.000,
I/flutter (15294):     dateTo: 2023-07-15 03:59:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 26.000016666666667,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 03:59:00.000,
I/flutter (15294):     dateTo: 2023-07-15 04:25:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 3.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 04:25:00.000,
I/flutter (15294):     dateTo: 2023-07-15 04:28:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 3.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 04:28:00.000,
I/flutter (15294):     dateTo: 2023-07-15 04:31:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 6.000016666666666,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 04:31:00.000,
I/flutter (15294):     dateTo: 2023-07-15 04:37:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 16.000016666666667,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 04:37:00.000,
I/flutter (15294):     dateTo: 2023-07-15 04:53:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 3.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 04:53:00.000,
I/flutter (15294):     dateTo: 2023-07-15 04:56:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 12.000016666666667,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 04:56:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:08:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 3.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:08:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:11:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 7.000016666666666,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:11:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:18:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 1.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:18:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:19:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 15.000016666666667,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:19:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:34:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 4.000016666666666,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:34:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:38:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 3.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:38:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:41:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 12.000016666666667,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:41:00.000,
I/flutter (15294):     dateTo: 2023-07-15 05:53:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 7.000016666666666,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 05:53:00.000,
I/flutter (15294):     dateTo: 2023-07-15 06:00:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 6.000016666666666,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 06:00:00.000,
I/flutter (15294):     dateTo: 2023-07-15 06:06:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness
I/flutter (15294): HealthDataPoint -
I/flutter (15294):     value: 1.0000166666666668,
I/flutter (15294):     unit: MINUTE,
I/flutter (15294):     dateFrom: 2023-07-15 06:06:00.000,
I/flutter (15294):     dateTo: 2023-07-15 06:07:00.001,
I/flutter (15294):     dataType: SLEEP_AWAKE,
I/flutter (15294):     platform: PlatformType.ANDROID,
I/flutter (15294):     deviceId: RP1A.200720.012,
I/flutter (15294):     sourceId: ,
I/flutter (15294):     sourceName: com.google.android.apps.fitness

To Confirm that it was returning data related to all Sleep Data I double checked with the HealthConnect App, to see if the data aligns:

unnamed

By Comparison you can see that it specifies the dataType is SLEEP_AWAKE, yet the data seems to be returning all types of SLEEP.

In the case I am doing something wrong or missing something PLEASE LET ME KNOW. Since this SLEEP data is essential for what I am working on.

Flutter Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.19045.3208], locale en-CA)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.5)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.79.1)
[√] Connected device (5 available)
[√] Network resources

• No issues found!

Device Used: Galaxy Tab A, Android Version 11 API33

Any help would be much appreciated!!

@Kam5678 Kam5678 added the bugfix a bug fix label Jul 19, 2023
@hoffmatteo hoffmatteo self-assigned this Jul 20, 2023
@itsamk
Copy link

itsamk commented Jul 26, 2023

Same issue. When I request data for these types [HealthDataType.SLEEP_DEEP, HealthDataType.SLEEP_AWAKE, HealthDataType.SLEEP_ASLEEP, HealthDataType.SLEEP_REM] using health.getHealthDataFromTypes(), I get duplicate entries for all of them meaning - if I get a 14 min entry from 2:00 PM to 2:14 PM - I will see 4 entries for all mentioned sleep types identical in values of duration and time and just differing in type - which shouldn't be. If I try to get SLEEP_SESSION in Android and add that to this list, it works perfect. Another fact, Sum of all entries for any of these data types will equal to the actual duration of sleep sessions in that time.

@hoffmatteo
Copy link
Contributor

Thank your for submission, this bug was due to the stages not being filtered properly, and will be fixed in the upcoming release!

@hoffmatteo
Copy link
Contributor

Closed as fixed it in the latest release.

@Kam5678
Copy link
Author

Kam5678 commented Aug 14, 2023

Sounds good thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix a bug fix
Projects
None yet
Development

No branches or pull requests

3 participants