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

Unable to get the integration to work #28

Closed
phillcoxon opened this issue Jan 15, 2023 · 4 comments
Closed

Unable to get the integration to work #28

phillcoxon opened this issue Jan 15, 2023 · 4 comments

Comments

@phillcoxon
Copy link

Hi there.

I've spent many hours trying to get this integration to work without success. I'm fully out of ideas as to what is going wrong and would be extremely grateful for any feedback and suggestions.

  • I have cloned the repo and copied the files in custom_component/oura/ folder into the custom_component/oura/ folder in Home Assistant.

  • I have tried many different variations of the config without success. The current version:

# Loads default set of integrations. Do not remove.
default_config:

################################################################################
# Oura Ring: Sleep data.
################################################################################

- platform: oura
  name: sleep_quality
  access_token: **TOKEN**
  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
    activity: {}
    heart_rate: {}
    readiness: {}
    workouts: {}     
  • I've tried turning on Logger but nothing shows up in the logs. The only reference to Oura in the Home Assistant Core logs is: 2023-01-15 22:20:29.143 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration oura which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. There is no other reference to Oura or sleep sensors etc.

  • I've confirmed the access token is working just fine with curl:

% curl --location --request GET 'https://api.ouraring.com/v2/usercollection/sleep?start_date=2023-01-01&end_date=2023-01-14' \
--header 'Authorization: Bearer **TOKEN**'
{"data":[{"average_breath":15.75,"average_heart_rate":60.125,"average_hrv":24,"awake_time":5430,"bedtime_end":"2023-01-02T07:32:02+13:00","bedtime_start":"2023-01-02T00:15:02+13:00","day":"2023-01-02","deep_sleep_duration":4950,"efficiency":79 [...]

Here's the list of files in config/custom_components/oura:

ls -l  config/custom_components/oura

total 84
-rw-r--r--    1 root     root            30 Jan 15 21:37 __init__.py
-rw-r--r--    1 root     root          3039 Jan 15 21:37 api.py
drwxr-xr-x    2 root     root          4096 Jan 15 21:37 helpers
-rw-r--r--    1 root     root           309 Jan 15 21:37 manifest.json
-rw-r--r--    1 root     root          2959 Jan 15 21:37 sensor.py
-rw-r--r--    1 root     root          3048 Jan 15 21:37 sensor_activity.py
-rw-r--r--    1 root     root         18688 Jan 15 21:37 sensor_base.py
-rw-r--r--    1 root     root          3201 Jan 15 21:37 sensor_bedtime.py
-rw-r--r--    1 root     root          3320 Jan 15 21:37 sensor_heart_rate.py
-rw-r--r--    1 root     root          2789 Jan 15 21:37 sensor_readiness.py
-rw-r--r--    1 root     root          2050 Jan 15 21:37 sensor_sessions.py
-rw-r--r--    1 root     root          5015 Jan 15 21:37 sensor_sleep.py
-rw-r--r--    1 root     root          4542 Jan 15 21:37 sensor_sleep_periods.py
-rw-r--r--    1 root     root          2483 Jan 15 21:37 sensor_sleep_score.py
-rw-r--r--    1 root     root          2011 Jan 15 21:37 sensor_workouts.py

Any suggestions on what I'm doing wrong here?

Thanks in advance!

@nitobuendia
Copy link
Owner

nitobuendia commented Jan 15, 2023

Hi @phillcoxon - without logs is very hard to know specially without being able to reproduce the issue. However, throwing a couple of ideas:

--

  1. Checking your configuration, it seems to be missing the sensor: key before setting up the overall oura sensor. Not sure if it's missing because it's cut, but making sure.
default_config:

sensor:
  - platform: oura
    name: sleep_quality
    access_token: **TOKEN**
    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
      activity: {}
      heart_rate: {}
      readiness: {}
      workouts: {}     

Can you kindly confirm that this is not the issue?


  1. When you did the API call, did you find data for January 14th (2023-01-14) and/or January 15th (2023-01-15)? The example you gave it only has 2023-01-02 on it, but I see the [...] indicating that perhaps we have more recent data.

  1. If none of the above is the issue, the only thing I can think of is to enable more logs by configuring the logger component on your configuration.yaml. I don't recall the exact syntax, but I think this would help:
logger:
  default: info
  logs:
    homeassistant.custom_components.oura: debug
    custom_components.oura: debug

@phillcoxon
Copy link
Author

And there it is! Thank you!

I did wonder if it would be something really simple that I was missing - I didn't have the sensor: in front of the config.

As a new person to Home Assistant this wasn't obvious. I had wondered if something was supposed to be in front but none of the config examples in this GitHub repo or the HA community thread included it. I had tried using oura: in my various config attempts but hadn't thought to try sensor:.

Can I suggest the documentation be updated to include sensor: ahead of the configuration example, or have a note to say the Oura configuration goes in the sensor: section of the configuration file?

Thank you so much for your help.

@phillcoxon
Copy link
Author

With regard to question 2: I used [...] to indicate there was a larger response but I had trimmed it for brevity.

@nitobuendia
Copy link
Owner

Thank you @phillcoxon - glad to know this solved your issue. I have improved the documentation as per your suggestion. I hope it's clearer now :)

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

No branches or pull requests

2 participants