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

Integration fails #103

Closed
Talonpoint opened this issue Aug 28, 2024 · 19 comments
Closed

Integration fails #103

Talonpoint opened this issue Aug 28, 2024 · 19 comments
Assignees
Labels
bug Something isn't working

Comments

@Talonpoint
Copy link

I have been using the old version and tried to upgrade and everything stopped working. I have tried to troubleshoot on my own, including deleting and reinstalling the custom repository, trying to go back to old version, many Home Assistant restarts. I get to the stage where I try to Add Integration, provide my username and password and submit. At that point Home Assistant generates the following log entry and the integration returns an Unknown error occurred message.

The Home Assistant Logs keep returning the following when I try to add the integration.

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:433
First occurred: 7:16:52 PM (4 occurrences)
Last logged: 7:40:01 PM

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
return await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 366, in async_configure
result = await self._async_configure(flow_id, user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 413, in _async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 527, in _async_handle_step
if result.get("preview") is not None:
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Aug 29, 2024

Thats an interesting one. What version of HA are you running? I may need to dig into their source to figure out whats going on as the exception doesnt provide much information.

@Talonpoint
Copy link
Author

Home Assistant
Core 2024.8.3
Frontend 20240809.0
I am running it in a Docker installation on a Synology Diskstation running DSM 7.1.1-42962 Update 6
The Hubspace integration was working fine until the August updates. I just got around to testing and troubleshooting today.

@Expl0dingBanana Expl0dingBanana self-assigned this Sep 1, 2024
@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 1, 2024

What docker image are you using for HA? I have done all my testing from a Synology NAS using docker.io/linuxserver/homeassistant:latest@sha256:12289b32df4eec21e727c60a87599a047138d502889497e70afa67188fe17505 without any issues.

Edit: Let me test with the official container @ ghcr.io/home-assistant/home-assistant:stable

@Expl0dingBanana
Copy link
Collaborator

I was able to reproduce the issue with the following steps:

  • Add HubSpace-HomeAssistant to HACs
  • Add the integration HubSpace-HomeAssistant
  • Enter an incorrect login
  • Observe the issue above

@Expl0dingBanana Expl0dingBanana added the bug Something isn't working label Sep 1, 2024
@Expl0dingBanana
Copy link
Collaborator

I believe this has been fixed with #104 . Please review the testing instructions within that PR and post any comments within that PR.

@Talonpoint
Copy link
Author

Talonpoint commented Sep 2, 2024 via email

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 3, 2024

Refer to #103 (comment)

I am wondering if this is something with the login or config flow. Lets manually run the login to see what happens

``` * Get access to a python3.10 or above environment * You can use the HomeAssistant if you can access terminal * Run locally * Install python3.12 locally * https://www.python.org/downloads/release/python-3125/ * Install hubspace-async * `pip install "hubspace-async==0.3.1"` * Run `python3.12` * Execute the following within the python terminal and replace username / password python

from hubspace_async import connection
import asyncio

conn = connection.HubSpaceConnection("", "")
loop = asyncio.get_event_loop()
loop.run_until_complete(conn.get_account_id())

If the login is successful, you should see your account id printed to the terminal. If unsuccessful, an exception will be raised. I would be curious to see how long it takes to complete too.

@cjr222
Copy link

cjr222 commented Sep 4, 2024

Ok, this could very well be my lack of python knowledge but when trying to run this code interactively this is what it looks like. Yes, I did replace my username and password, just replaced here for security.
`330f1202f9d0:/config# python
Python 3.12.4 (main, Jun 22 2024, 12:49:21) [GCC 13.2.1 20240309] on linux
Type "help", "copyright", "credits" or "license" for more information.

from hubspace_async import connection
import asyncio

conn = connection.HubSpaceConnection("", "")
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.12/site-packages/hubspace_async/connection.py", line 55, in init
self.client = websession or ClientSession()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 294, in init
loop = loop or asyncio.get_running_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
loop = asyncio.get_event_loop()
:1: DeprecationWarning: There is no current event loop
loop.run_until_complete(conn.get_account_id())
Traceback (most recent call last):
File "", line 1, in
NameError: name 'conn' is not defined
`

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 4, 2024 via email

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 4, 2024

I have created an easier way to run the tests by adding a CLI tool to hubspace-async. Here is the updated commands

python -m hubspace_async.cli --username "<username>" --password "<password>" auth-flow

If the auth is successful, you should not see any error messages. If that works, lets try to connect to gather the account ID.
To test connectivity, run the following command:

python -m hubspace_async.cli --username "<username>" --password "<password>" hs-conn

If successful, an account id with several hyphens will appear.

Below is an example of an auth failure:

python -m hubspace_async.cli --username a --password b auth-flow
/home/cdohmen/git/fun/hubspace-async/src/hubspace_async/cli.py:60: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()
Refresh token not present. Generating a new refresh token
Challenge information: AuthChallenge(challenge='ypATd2rvBNJzJsoU4qrmwCV5uXrHwzanpCBpBim1-_w', verifier='64f64zT1BattBydzM16ijDNXykzNBCaT8D3ThXzbRGjqRZQm12V6Q')
URL: https://accounts.hubspaceconnect.com/auth/realms/thd/protocol/openid-connect/auth
        params: {'response_type': 'code', 'client_id': 'hubspace_android', 'redirect_uri': 'hubspace-app://loginredirect', 'code_challenge': 'ypATd2rvBNJzJsoU4qrmwCV5uXrHwzanpCBpBim1-_w', 'code_challenge_method': 'S256', 'scope': 'openid offline_access'}
Status Code: 200
WebApp Login:
        Session Code: LFMcMnqiIY_GiakHDhpJEEs0dPa9KAXW8dFxDbjHea4
        Execution: 3d17da1d-df31-42cd-8aa1-a3555b457e26
        Tab ID:njZogLaTnqI
Generating code
URL: https://accounts.hubspaceconnect.com/auth/realms/thd/login-actions/authenticate
        params: {'session_code': 'LFMcMnqiIY_GiakHDhpJEEs0dPa9KAXW8dFxDbjHea4', 'execution': '3d17da1d-df31-42cd-8aa1-a3555b457e26', 'client_id': 'hubspace_android', 'tab_id': 'njZogLaTnqI'}
        data: {'username': 'a', 'password': 'b', 'credentialId': ''}
        headers: {'Content-Type': 'application/x-www-form-urlencoded', 'user-agent': 'Dart/2.15 (dart:io)'}
Status Code: 200
Unable to auth
Traceback (most recent call last):
  File "/home/cdohmen/git/fun/hubspace-async/src/hubspace_async/cli.py", line 26, in run_workflow_auth
    await hs_auth.token(sess)
  File "/home/cdohmen/git/fun/hubspace-async/src/hubspace_async/auth.py", line 250, in token
    self._refresh_token = await self.perform_initial_login(client)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cdohmen/git/fun/hubspace-async/src/hubspace_async/auth.py", line 241, in perform_initial_login
    code: str = await self.webapp_login(challenge, client)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cdohmen/git/fun/hubspace-async/src/hubspace_async/auth.py", line 117, in webapp_login
    return await self.generate_code(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cdohmen/git/fun/hubspace-async/src/hubspace_async/auth.py", line 179, in generate_code
    raise InvalidResponse(
hubspace_async.auth.InvalidResponse: Unable to process the result from https://accounts.hubspaceconnect.com/auth/realms/thd/login-actions/authenticate?session_code=LFMcMnqiIY_GiakHDhpJEEs0dPa9KAXW8dFxDbjHea4&execution=3d17da1d-df31-42cd-8aa1-a3555b457e26&client_id=hubspace_android&tab_id=njZogLaTnqI: 200

@cjr222
Copy link

cjr222 commented Sep 4, 2024

Both of those commands end with Token has been successfully generated.
Anything else you need me to look for in the output or is seeing the success enough?

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 4, 2024 via email

@allstarnz
Copy link

FWIW I have similar issues as OP. I too was able to generate both tokens. This integration was working flawlessly until recently. It stopped working for a while and then started again. Now it doesn't work at all.

I am still on HACS 1.34.0 I don't know if this matters?

@allstarnz
Copy link

FWIW I have similar issues as OP. I too was able to generate both tokens. This integration was working flawlessly until recently. It stopped working for a while and then started again. Now it doesn't work at all.

I am still on HACS 1.34.0 I don't know if this matters?

And of course, it randomly starts working again 🤔

@Expl0dingBanana
Copy link
Collaborator

Expl0dingBanana commented Sep 27, 2024

@Talonpoint Can yall redownload 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

@Expl0dingBanana
Copy link
Collaborator

@allstarnz a previous dev version of 3.1.1 had an issue where HA had to be restarted for it to start working. I wonder if thats what you experienced.

@engyew
Copy link

engyew commented Sep 28, 2024

@Talonpoint Can yall redownload 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

I redownloaded 3.1.0 and signed in again, and it now works. I gonna stay on this version

@Expl0dingBanana
Copy link
Collaborator

This may be solved with 3.2.0 + latest HA. Please let me know if the problem still persists!

@Expl0dingBanana
Copy link
Collaborator

Closing due to inactivity. Please re-open the issue if you still encounter the problem.

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

5 participants