nitobuendia / oura-custom-component

Oura Custom Component for Home-Assistant. Adds Oura Ring sleep information.
108 stars 25 forks source link

[Bug] 0d missing on sleep periods sensor #27

Closed nitobuendia closed 1 year ago

nitobuendia commented 1 year ago

Originally posted by @akeslo in https://github.com/nitobuendia/oura-custom-component/issues/10#issuecomment-1379645988

My Config

  - platform: oura
    access_token: XXXXREMOVEDXXXXX
    scan_interval: 7200
    sensors:
     sleep:
       name: oura_sleep_metrics
       max_backfill: 0
       monitored_dates:
        - 0d_ago
        - 1d_ago
        - 7d_ago 
     sleep_periods:
       name: oura_sleep_periods
       max_backfill: 0
       monitored_dates:
        - 0d_ago
        - 1d_ago
        - 7d_ago       
     sleep_score:
       name: oura_sleep_score
       max_backfill: 0 
       monitored_dates:
        - 0d_ago
        - 1d_ago
        - 7d_ago

sleep_periods (oura_sleep)

nitobuendia commented 1 year ago

I can reproduce this bug. In my case, 0d_ago works but 1d_ago data was missing and this is what I see on my sleep_periods

0d_ago: 
- day: '2023-01-15'
  total_sleep_duration_in_hours: 6.07

2d_ago: 
- day: '2023-01-13'
  total_sleep_duration_in_hours: 5.95

1d_ago is missing because there was no data found. This has nothing to do with the 0d but with the fact that there was no data for that given day and can affect any dates.

nitobuendia commented 1 year ago

I think this should be fixed now @akeslo. You can redownload the latest component code or do the changes manually, it should be only one line of code anyway. Thanks for your help!

akeslo commented 1 year ago

@nitobuendia hmm, I am still seeing null here but I do have data for today and even for yesterday in the cloud ui. API is also returning data for today (see json output from #26)

image

nitobuendia commented 1 year ago

Null is expected is there's no data. What was not expected is not having the day at all. The null appearing is the default sensor when no data is present.

On why you're missing data, this would be what we're looking at on #26