RobertD502 / home-assistant-flair

Custom component for Home Assistant Core for Flair pucks, vents, rooms, structures, and minisplits
MIT License
87 stars 12 forks source link

Unknown Error Occurred when trying to enable integration #14

Closed Melachiah closed 2 years ago

Melachiah commented 2 years ago

When trying to add this integration into HASS for the first time. Every time I enter my API credentials I receive the following error: Screenshot_20220105-195525

I've tested this both with the flair integration added via HACS and manually in my custom components. I've tried the last 5 published versions (v0.0.4.6, v0.0.4.5, v0.0.4.4, v0.0.4.3, and v0.0.4.2). I'm currently on HASS 2021.12.8, installed in a docker container.

I've confirmed my API key works with curl requests. And I'm using the v1 API key from Flair.

Nothing is getting written to the logs from the failed attempt.

I've tested adding other integrations to confirm it wasn't some larger issue with adding integrations via the UI. Other integrations can be added without issue.

RobertD502 commented 2 years ago

I honestly won't know until I try your credentials on the backend. If you could let me know an e-mail address you can be reached at, I'll shoot you a message to get your credentials to test.

RobertD502 commented 2 years ago

@Melachiah I tested adding the integration with my own credentials on 2021.12.8 and had no issues. There have been issues in the past with Flair's servers that I've been able to uncover with users' credentials and reported the findings to Flair. I'm certain something similar is going on in your case, but won't be able to confirm without the credentials.

smcpeck commented 2 years ago

@Melachiah Are you trying to use the OAuth2 credentials? If so, they won't work.

~~Notice here: https://github.com/RobertD502/hass-flair-helper/blob/main/flair/flair_helper.py#L48 The Flair API Helper that's in use hits the legacy OAuth endpoint for authentication. Your e-mail from Flair with your API credentials should have two different ID/secret pairs.~~

Have you tried both?

Just re-read your message and see you mention using the v1 id/secret.

In your HA logs, you should be able to see the error that is occurring upon initialization. That would help troubleshoot this further. As the integration enumerates all your Flair objects via the API, it may be running into something that is different from what the code is expecting.

Can you check the logs?

Melachiah commented 2 years ago

As mentioned, there's notably nothing in the logs concerning the failure. Even when enabling debug logging. Everything else logs as expected. Just not this particular integration. I realize that isn't the most helpful. In the interim I've created REST template sensors and my own python script to issue commands to flair. Which works fine for now.

RobertD502 commented 2 years ago

@Melachiah I have just pushed out 0.0.5.0 which has increased logging during the onboarding process. Try it out and let's see if we can get to the bottom of the issue.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

dkmcgowan commented 2 years ago

I get this same error, also with oauth1 creds, just unknown error then it shows "failed to load" on the integration, you can delete it and restart and try again, same issue, also see nothing in the logs

dkmcgowan commented 2 years ago

ok, my log level was wrong, did it again... this is how far it makes it, I'm not posting earlier logs like loading the custom integration, etc...

[custom_components.hacs] <Integration RobertD502/home-assistant-flair> Getting repository information [custom_components.hacs] <Integration RobertD502/home-assistant-flair> Running checks against 0.0.5.0 [homeassistant.setup] Setting up flair [homeassistant.setup] Setup of domain flair took 0.0 seconds [custom_components.flair] Initializing the Flair API

Then that's it, nothing else with the word flair, I looked manually through the logs and I didn't see an exception from core that looked like it was related, just stuff all about other integrations, etc...

dkmcgowan commented 2 years ago

if you get me your email I can send you creds to test, and then just have Flair create me new ones once we figure it out

dkmcgowan commented 2 years ago

you could also email me at davidkmcgowan <.com>

RobertD502 commented 2 years ago

@dkmcgowan was able to hunt down the problem on his end which seems to be related to self-hosted reverse proxies. He was able to add the integration by accessing Home Assistant using his local URL instead of the external URL.

From my own testing, this problem does not occur when adding the integration using a Nabu Casa external URL.

@Melachiah Can you please report back if you are using Nabu Casa and, if not, if you were trying to add the integration while accessing Home Assistant from your external URL. If this is the case, accessing HA through your local URL and then adding the Flair integration may resolve the problem you are having.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.