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

Failed setup #99

Closed
cjr222 opened this issue Aug 4, 2024 · 30 comments
Closed

Failed setup #99

cjr222 opened this issue Aug 4, 2024 · 30 comments
Labels
bug Something isn't working

Comments

@cjr222
Copy link

cjr222 commented Aug 4, 2024

I keep getting failed setup after configuring the integration. I've checked the logs but other than beginning setup I don't see any logs. Any ideas what might be happening?

@Expl0dingBanana
Copy link
Collaborator

Have you put hubspace into debug before inital setup? This may provide additional logs

logger:
  default: warning
  logs:
    custom_components.hubspace: debug

@cjr222
Copy link
Author

cjr222 commented Aug 4, 2024

I did the initial setup and debug through the UI. I can try the yaml config as well.

@cjr222
Copy link
Author

cjr222 commented Aug 4, 2024

I did get some debug logs to generate:
2024-08-04 14:30:54.872 DEBUG (MainThread) [hubspace_async.connection] Querying API for account id
2024-08-04 14:30:54.872 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-08-04 14:30:55.157 DEBUG (MainThread) [hubspace_async.auth] Successfully generated an auth code
2024-08-04 14:30:55.260 DEBUG (MainThread) [hubspace_async.auth] Successfully generated a refresh token
2024-08-04 14:30:55.261 DEBUG (MainThread) [hubspace_async.auth] Token has not been generated or is expired
2024-08-04 14:30:55.327 DEBUG (MainThread) [hubspace_async.auth] Token has been successfully generated
2024-08-04 14:30:55.523 DEBUG (MainThread) [hubspace_async.connection] Querying API for account id
2024-08-04 14:30:55.608 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data
2024-08-04 14:30:55.608 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-08-04 14:31:00.929 DEBUG (MainThread) [custom_components.hubspace.coordinator] Finished fetching hubspace data in 5.323 seconds (success: False)
2024-08-04 14:31:06.366 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data
2024-08-04 14:31:06.366 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-08-04 14:31:06.443 DEBUG (MainThread) [custom_components.hubspace.coordinator] Finished fetching hubspace data in 0.078 seconds (success: False)
2024-08-04 14:31:16.641 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data
2024-08-04 14:31:16.641 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-08-04 14:31:16.866 DEBUG (MainThread) [custom_components.hubspace.coordinator] Finished fetching hubspace data in 0.227 seconds (success: False)
2024-08-04 14:31:26.354 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Aug 4, 2024 via email

@cjr222
Copy link
Author

cjr222 commented Aug 4, 2024

v3.0.4

@Expl0dingBanana
Copy link
Collaborator

Not positive on this one other than failure to generate a token and not correctly raising an exception. I'll need to dive into it some more and create a dev release for you to try.

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Aug 6, 2024 via email

@cjr222
Copy link
Author

cjr222 commented Aug 6, 2024

No worries, I appreciate any help you can provide. This is the first time I've used the integration so I am not upgrading from any previous version.

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Aug 6, 2024 via email

@jdeath
Copy link
Owner

jdeath commented Aug 6, 2024

Maybe try the testhubspace.py . Perhaps the password is just wrong or has some special characters? Or can add some extra logging there.

@cjr222
Copy link
Author

cjr222 commented Aug 6, 2024

testhubspace.py seems to run successfully. I got a long output that includes details about the ceiling-fan-kensgrove-ii model I have.

@cjr222
Copy link
Author

cjr222 commented Aug 6, 2024

I also tried v3.0.3 and same setup error

@Expl0dingBanana
Copy link
Collaborator

I have added additional messages (HS_TRACE) when authenticating. Can you run install and run manually to see what you get back?

python -m pip install "hubspace-async==0.1.1"

After installed, run the following (but replace username / password):

import logging

import hubspace_async
import asyncio


# TRACE messages in logs
hubspace_async.logger.setLevel(logging.HS_TRACE)
hubspace_async.logger.addHandler(logging.StreamHandler())

try:
    loop = asyncio.get_event_loop()
except RunTimeError:
    loop = asyncio.new_event_loop()

username = "<username>"
password = "<password>"

async def get_devices(username, password):
    connection = hubspace_async.HubSpaceConnection(username, password)
    return await connection.devices


loop.run_until_complete(get_devices(username, password))

You will see log messages like these:

URL: https://accounts.hubspaceconnect.com/auth/realms/thd/login-actions/authenticate
Status code: 302

Please paste those in (not the other messages as it contains information that could log you in from another system). For example, my run looks like

Querying API for all data
Refresh token not present. Generating a new refresh token
URL: https://accounts.hubpaceconnect.com/auth/realms/thd/protocol/openid-connect/auth
Status code: 200

Generating code
URL: https://accounts.hubspaceconnect.com/auth/realms/thd/login-actions/authenticate
Status code: 302

Successfully generated an auth code
Generating refresh token
URL: https://accounts.hubspaceconnect.com/auth/realms/thd/protocol/openid-connect/token
Status code: 200

Successfully generated a refresh token
Token has not been generated or is expired
Generating token
URL: https://accounts.hubspaceconnect.com/auth/realms/thd/protocol/openid-connect/token
Status code: 200

Token has been successfully generated

@cjr222
Copy link
Author

cjr222 commented Aug 8, 2024

This could be an issue with the way I ran it but I get this:
/config/custom_components/hubspace/debugtest.py:14: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()

@Expl0dingBanana
Copy link
Collaborator

That warning is fine as long as an exception was not raised. I would continue to run the commands and get the logs.

@Expl0dingBanana
Copy link
Collaborator

@cjr222 Were you able to gather the information from the logs?

@cjr222
Copy link
Author

cjr222 commented Sep 2, 2024

I was not. I got the script to run but have no idea where the logs go. Tried in verbose mode, looked in the normal HA logs but not sure where to look.

@Expl0dingBanana
Copy link
Collaborator

Can you try with #104 to see if that helps at all? If not, well need to grab additional logs

@Expl0dingBanana Expl0dingBanana added the bug Something isn't working label Sep 3, 2024
@cjr222
Copy link
Author

cjr222 commented Sep 3, 2024

I had already deleted the integration during my last testing. So I downloaded the beta code first and now get this error when trying to add the integration, entering my username/password. It says connection timed out when reaching the server. In the HA logs I saw this.
`Logger: py.warnings
Source: custom_components/hubspace/config_flow.py:43
integration: Hubspace (documentation, issues)
First occurred: 7:39:24 AM (1 occurrences)
Last logged: 7:39:24 AM

/usr/local/lib/python3.12/site-packages/hubspace_async/auth.py:265: GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently. The code that caused this warning is on line 265 of the file /usr/local/lib/python3.12/site-packages/hubspace_async/auth.py. To get rid of this warning, pass the additional argument 'features="lxml"' to the BeautifulSoup constructor. auth_page = BeautifulSoup(page)`

@ngy42
Copy link

ngy42 commented Sep 3, 2024

I have a similar issue with failed setup. It was working previously with manual configuration.

2024-09-03 18:15:46.236 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data
2024-09-03 18:15:46.236 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-09-03 18:15:51.432 DEBUG (MainThread) [custom_components.hubspace.coordinator] Finished fetching hubspace data in 5.196 seconds (success: False)
2024-09-03 18:15:56.800 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data
2024-09-03 18:15:56.800 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-09-03 18:15:56.884 DEBUG (MainThread) [custom_components.hubspace.coordinator] Finished fetching hubspace data in 0.085 seconds (success: False)
2024-09-03 18:16:07.293 DEBUG (MainThread) [hubspace_async.connection] Querying API for all data
2024-09-03 18:16:07.293 DEBUG (MainThread) [hubspace_async.auth] Refresh token not present. Generating a new refresh token
2024-09-03 18:16:07.382 DEBUG (MainThread) [custom_components.hubspace.coordinator] Finished fetching hubspace data in 0.090 seconds (success: False)
2024-09-03 18:17:40.654 WARNING (MainThread) [custom_components.localtuya.common] [eb5...gln] Failed to connect to 10.0.0.34: [Errno 113] Connect call failed ('10.0.0.34', 6668)
2024-09-03 18:18:40.654 WARNING (MainThread) [custom_components.localtuya.common] [eb5...gln] Failed to connect to 10.0.0.34: [Errno 113] Connect call failed ('10.0.0.34', 6668)

@Expl0dingBanana
Copy link
Collaborator

Can you try to manually login to see what happens? Instructions can be found @ #103 (comment)

@ngy42
Copy link

ngy42 commented Sep 9, 2024

So I finally was able to run the manual login - I get an output similar to your example, but it ends with 'Token has been successfully generated'. Throughout the output I see other things like 'Successfully generated an auth code' and 'Successfully generated a refresh token'. Didn't want to post the entire output as I'm not sure if there's sensitive information there.

@Expl0dingBanana
Copy link
Collaborator

I have managed to replicate this (but not sure I got it in the same fashion). When logging in, if providing a valid username it can cause an issue with the initial setup but after an HA restart the problem goes away. I will continue to see why this is the case.

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 27, 2024

@cjr222 / @ngy42 Can yall redownload fix-config-flow (previously v3.1.1) and try again? This is a weird once since im not able to replicate the issue in the same way yall are experiencing it.

Goto hacs -> Hubspace Homeassistant -> Update Information -> Redownload -> select fix-config-flow

@cjr222
Copy link
Author

cjr222 commented Sep 27, 2024

I tried twice, even rebooted HA in between redownload but when adding the integration I get "Connection timed out when reaching the server." I've checked my traffic logs and I see a connection to accounts.hubspaceconnect.com

@ngy42
Copy link

ngy42 commented Sep 27, 2024

Running into a similar issue as @cjr222 after redownload and restarting HA. I'm receiving an error "cannot_connect" on the integration setup screen.

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 28, 2024

I have added the ability to customize the timeout when making the requests. By default, its 10000ms. Try adjusting this value higher to see if it solves your issue.

Try re-pulling fix-config-flow, restarting, and running the config flow.

This has been released with 3.2.0. Please let me know if that does not fix your issue!

@ngy42
Copy link

ngy42 commented Sep 30, 2024

this did the trick! the default timeout (10000) didn't work, so I increased it to 20000 and everything worked like a charm. thanks for your hard work @Expl0dingBanana

@cjr222
Copy link
Author

cjr222 commented Sep 30, 2024

increasing to 20000 worked for me as well. Thank you!!

@Expl0dingBanana
Copy link
Collaborator

Perfect! Glad this fixed yalls issues. Good ol connection differences 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants