nitobuendia / oura-custom-component

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

Request: Installation document clarification needed #3

Closed nikkolade closed 3 years ago

nikkolade commented 3 years ago

It looks like setting up this custom component with the latest Home Assistant versions needs a small clarification into the documentation.

Currently, unless you change this:

diff --git a/custom_components/oura/api.py b/custom_components/oura/api.py
index 7d4b235..2ce25f3 100644
--- a/custom_components/oura/api.py
+++ b/custom_components/oura/api.py
@@ -10,7 +10,7 @@ from . import views
 from . import hass_helper

 # Oura API config.
-_TOKEN_FILE = 'oura-token-cache-{}'
+_TOKEN_FILE = '<write here your home assistant home-directory path, for example>/oura-token-cache-{}'
 _OURA_API = 'https://api.ouraring.com/v1'
 _OURA_CLOUD = 'https://cloud.ouraring.com'
 _MAX_API_RETRIES = 3

The step 4 in the "Installation" step will most likely fail, as the Home Assistant will not be trying to to write the oura-token-cache file into a directory that it has write access. Clicking the permanent notification will not be succesfull as the latest token is not written to the correct location.

4. If the code was installed and configured properly, you will get a permanent notification. See Notifications section on the Home-Assistant menu.

nitobuendia commented 3 years ago

Thanks for reporting. Let me have a look.

I would prefer the user not to need to touch the file (unless they want so), so I will see if that can be fixed in a different way.

nitobuendia commented 3 years ago

Hi @nikkolade , I have changed the function that retrieves the path to also include the absolute path. You can see the changes here. This should now solve the issue that you have indicated without the user having to make any changes to the Python files (and therefore without needing to change the configuration).

You can copy/paste the code change into your installation and this should solve it. Although if you had added /config/ you may need to remove it.

Additional warning: just before that change, I decided to move the token from oura-token-cache-{} to data/oura-token-cache-{}.conf. Hence, if you copy the whole api.py then you may need to either re-authorize oura on your Home-Assistance instance or simply move the file to config/data/ and add .conf as the extension. I've added an incremented version to indicate this "breaking" change.

Thanks for reporting. I know it took some time to fix! Let me know if you have any other issues.