ekutner / home-connect-hass

Alternative (and improved) Home Connect integration for Home Assistant
MIT License
577 stars 56 forks source link

Error when setting up #226

Closed danbayliss closed 1 year ago

danbayliss commented 1 year ago

Describe the bug

I'm having issues setting up the component. I've followed all the instructions and registered my address at my.home-assistant.io but when I click Link Account and it goes back to Home Assistant I just get a popup saying Error. My email address is all lowercase and I've tried my external and internal address and the same issue occurs. All my HC devices are working when I turn off WiFi on my phone.

The URL for the my.home-assistant.io screenshot is https://my.home-assistant.io/redirect/oauth/?code=eyJ4LXJlZyI6IkVVIiwieC1lbnYiOiJQUkQiLCJjcmVmIjoiOEYwNDlGRUIiLCJ0b2tlbiI6IjYwY2NiMzI0LWZiZjktNDA3Yi04NjkxLTI0NWVmYzIzZjY4MyIsImNsdHkiOiJwcml2YXRlIn0%3D&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbG93X2lkIjoiMGFjZDI2YjFkODAzMDg1ZDJjNGRlODE3MzRjZDcyMTYiLCJyZWRpcmVjdF91cmkiOiJodHRwczovL215LmhvbWUtYXNzaXN0YW50LmlvL3JlZGlyZWN0L29hdXRoIn0.vhsVW2gv7LFIXiGFr7VW2iX5nahixS-2tIaMdocaoVM&grant_type=authorization_code

And the URL for the Link Account option is http://192.168.0.4:8123/auth/external/callback?code=eyJ4LXJlZyI6IkVVIiwieC1lbnYiOiJQUkQiLCJjcmVmIjoiOEYwNDlGRUIiLCJ0b2tlbiI6IjYwY2NiMzI0LWZiZjktNDA3Yi04NjkxLTI0NWVmYzIzZjY4MyIsImNsdHkiOiJwcml2YXRlIn0%3D&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbG93X2lkIjoiMGFjZDI2YjFkODAzMDg1ZDJjNGRlODE3MzRjZDcyMTYiLCJyZWRpcmVjdF91cmkiOiJodHRwczovL215LmhvbWUtYXNzaXN0YW50LmlvL3JlZGlyZWN0L29hdXRoIn0.vhsVW2gv7LFIXiGFr7VW2iX5nahixS-2tIaMdocaoVM

Screenshots

vTdvewU 8CRC0yA

Version of the custom_component

Version 0.6.1 Home Assistant 2023.5

Configuration

home_connect_alt:
  client_id: XXXXX
  client_secret: XXXXX

Debug log

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 171, in get
    return await super().get(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 96, in get
    result = await self._flow_mgr.async_configure(flow_id)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 315, in async_step_creation
    token = await self.flow_impl.async_resolve_external_data(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 172, in async_resolve_external_data
    return await self._token_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 209, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://api.home-connect.com/security/oauth/token')
nheinemans commented 1 year ago

Same error here, with the same versions. I tried it several times, even created a new developer account to make sure the email address is all lowercase. Unfortunately, I can't get it to work.

ekutner commented 1 year ago

These errors are always a configuration error. Please triple check you followed the instructions to the letter. Also, make sure you start the process from the same URL you finish in i.e. http://192.168.0.4:8123 If you still have an issue please post a screenshot of the Home Connect app you created.

danbayliss commented 1 year ago

I've double checked everything and it all appears to be correct. I have tried adding the devices using my internal and external address and always use the same URL at the start and on my.home-assistant.io. Here is a screenshot of my app RoLhSsb

ekutner commented 1 year ago

The configuration seems fine. Please make sure again that both the developer account and the Home Connect registered in your mobile app (the homeconnect@xxx.co.uk) are actually registered in all lower case. You can also check these cases to see how others have fixed this issue: #166 #207 #210

nheinemans commented 1 year ago

Changing my email address in the Home Connect mobile app solved the issue. So it doesn't matter how the email looks like in the developer portal, you need to check it in the app and make sure it's all lower case.

danbayliss commented 1 year ago

Based on the above I decided to login and change my address to see if it resolves the issue. On the mobile app my email address shows as homeconnect@xxx.co.uk but when I requested to change it, it comes up as Homeconnect@xxx.co.uk. I tried to change it to homeconnect@xxx.co.uk but it wouldn't let me so I changed it to homeconnect2@xxx.co.uk and then back to homeconnect@xxx.co.uk and it's now fixed