nitobuendia/oura-custom-component

[Bug] 0d missing on sleep periods sensor

nitobuendia opened this issue · 4 comments

Originally posted by @akeslo in #10 (comment)

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)

  • 0d is not an attribute despite it being in the config.

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.

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!

@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

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