core icon indicating copy to clipboard operation
core copied to clipboard

Home Connect integration doesn't work.

Open scaglar78 opened this issue 1 year ago • 2 comments

The problem

I have spent many hours trying to install this integration without success. I have used all possible combinations of redirect urls and the url I used to access my HA. It just doesn't work. I have read many post about similar issues but no fix has helped so far.

I either get an unauthorized or a "bad request" error.

aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://api.home-connect.com/security/oauth/token')

What version of Home Assistant Core has the issue?

2023.3.1 / 9.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Home Connect

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

scaglar78 avatar Mar 13 '23 11:03 scaglar78

Hey there @davidmstraub, mind taking a look at this issue as it has been labeled with an integration (home_connect) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of home_connect can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign home_connect Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


home_connect documentation home_connect source (message by IssueLinks)

home-assistant[bot] avatar Mar 19 '23 14:03 home-assistant[bot]

Still no feedback. If you consider the existing issue posts related to this integration, it is obvious that there is something fundamentally wrong with the solution. You should consider pulling off this solution as it is causing more frustrations than any help.

scaglar78 avatar Mar 24 '23 10:03 scaglar78

If you consider the information in your issue post, it is obvious that there is not enough information to provide any help. You should consider closing the issue as it is causing more frustrations than any help.

DavidMStraub avatar Mar 24 '23 10:03 DavidMStraub

What information are you looking for? Buttom line is, you are not able to make a successful installation by following the documentation and the steps described herein. Have you seen the many posts from people having issues with this integration?

If you like I can provide you all the information you need.

scaglar78 avatar Mar 24 '23 10:03 scaglar78

The point of my comment was that an issue which contains "it does not work" as sole information is a waste of everyone's time, and if you want to motivate others to look into the issue, that (plus adding an impolite comment) will not work.

To be clear, I am not a maintainer or anything, I just provided the initial implementation of the integration long ago.

By the way, the integration is working fine for me.

DavidMStraub avatar Mar 24 '23 11:03 DavidMStraub

Sorry David I think I was a little too frustrated due to the amount of time I have spent fixing the issues. Another reason I didn’t provide any details is that there already is a lot posts with same or similar issues.

I will as soon as possible provide a detailed description of my HA setup, the installation process and finally the error messages.

Thanks.

Med venlig hilsen | Kind regards Süleyman Çağlar


From: David Straub @.> Sent: Friday, March 24, 2023 12:43:09 PM To: home-assistant/core @.> Cc: scaglar78 @.>; Author @.> Subject: Re: [home-assistant/core] Home Connect integration doesn't work. (Issue #89627)

The point of my comment was that an issue which contains "it does not work" as sole information is a waste of everyone's time, and if you want to motivate others to look into the issue, that (plus adding an impolite comment) will not work.

To be clear, I am not a maintainer or anything, I just provided the initial implementation of the integration long ago.

By the way, the integration is working fine for me.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/89627#issuecomment-1482670183, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG5EKQPQLWFAJO6FPPYLIPTW5WCE3ANCNFSM6AAAAAAVY6ZHTE. You are receiving this because you authored the thread.Message ID: @.***>

scaglar78 avatar Mar 24 '23 11:03 scaglar78

Hello @DavidMStraub, the problem is that the url the integration uses during the first setup for oauth is not the one, configured in the developer portal of home connect. This is the part of the url:

https://api.home-connect.com/security/oauth/authorize?response_type=code&client_id=4BB586607C31DAEFA796F6F7620FCA2C879558B81CFFB41C1C9BB976A9204DA2&r**edirect_uri=https://my.home-assistant.io/redirect/oauth**&state=

In the developer portal I configured: http://192.168.177.225:8123/auth/external/callback

So I get an "unauthorized client" error.

I disabled my.home-assistant so an external redirection is not possible. Kind regards and thanks for your help. Niklas

un1k77 avatar Apr 03 '23 04:04 un1k77

Hello,

I had the same problem with the setup as you @un1k77, the my.home-assistant.io address always appeared in the redirect although I don't use it. So i had the same error "unauthorized client".

You write that you have disabled it? How did you disable it? I found out that I had the parameter default_config in my configuration.yaml file, which automatically activates the my configuration. Unfortunately it can't be deactivated individually.

So, either set up the my.home-assistant.io or remove default_config from the configuration.yaml and manually set up the necessary integrations.

After removing the default_config parameter, I was able to complete the configuration setup successfully.

I hope this helps you with the setup.

w0vka avatar Apr 26 '23 15:04 w0vka

Hello @w0vka thanks for your great work. As you mentioned in your comment there is no way to disable the my configuration. The correct wording is to not use it. After removing the default_config the integration is functional but other things don't work. Is it possible to add all integrations included in the default_config manually? All except my ?

un1k77 avatar Apr 26 '23 16:04 un1k77

Hello @DavidMStraub, the problem is that the url the integration uses during the first setup for oauth is not the one, configured in the developer portal of home connect. This is the part of the url:

https://api.home-connect.com/security/oauth/authorize?response_type=code&client_id=4BB586607C31DAEFA796F6F7620FCA2C879558B81CFFB41C1C9BB976A9204DA2&r**edirect_uri=https://my.home-assistant.io/redirect/oauth**&state=

In the developer portal I configured: http://192.168.177.225:8123/auth/external/callback

So I get an "unauthorized client" error.

I disabled my.home-assistant so an external redirection is not possible. Kind regards and thanks for your help. Niklas

I copied the URL giving the error, replaced the '/my.home-assistant.io' part of the redirect_uti argument with the address of my home instance, and pasted it back in the browser. This brought me to the correct login page.

rspring avatar Apr 26 '23 19:04 rspring

Hello @w0vka thanks for your great work. As you mentioned in your comment there is no way to disable the my configuration. The correct wording is to not use it. After removing the default_config the integration is functional but other things don't work. Is it possible to add all integrations included in the default_config manually? All except my ?

Glad to have helped you out.

Yes, I also had the problem that all the integrations were missing and i had to add the missing integrations on my own.

So yes, it is possible to manually add these integrations. You "only" have to add the needed integrations (full available list) instead of the default_config into your configuration.yaml. I found a good example in this community post.

But you have to keep in mind that new integrations in the future always have to be added manually, as described very well in this community post. So I think this is something we have to live with.

@rspring I think this workaround will not work for long. In my case, the integration stopped receiving updates after a few hours. I guess that the integration has to update the "authentication" in the background and that would fail then.

@DavidMStraub please correct me if I got this wrong

w0vka avatar Apr 26 '23 20:04 w0vka

Hopefully the actual integration will be updated with a resolution to this concrete problem.


From: w0vka @.> Sent: Wednesday, April 26, 2023 10:25:32 PM To: home-assistant/core @.> Cc: scaglar78 @.>; Author @.> Subject: Re: [home-assistant/core] Home Connect integration doesn't work. (Issue #89627)

Hello @w0vkahttps://github.com/w0vka thanks for your great work. As you mentioned in your comment there is no way to disable the my configuration. The correct wording is to not use it. After removing the default_config the integration is functional but other things don't work. Is it possible to add all integrations included in the default_config manually? All except my ?

Glad to have helped you out.

Yes, I also had the problem that all the integrations were missing and i had to add the missing integrations on my own.

So yes, it is possible to manually add these integrations. You "only" have to add the needed integrations (full available listhttps://www.home-assistant.io/integrations/default_config/) instead of the default_config into your configuration.yaml. I found a good example in this community posthttps://community.home-assistant.io/t/convert-away-from-default-config/204333/6.

But you have to keep in mind that new integrations in the future always have to be added manually, as described very well in this community posthttps://community.home-assistant.io/t/how-can-i-turnoff-the-new-feature-assist/529037/2. So I think this is something we have to live with.

@rspringhttps://github.com/rspring I think this workaround will not work for long. In my case, the integration stopped receiving updates after a few hours. I guess that the integration has to update the "authentication" in the background and that would fail then.

@DavidMStraubhttps://github.com/DavidMStraub please correct me if I got this wrong

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/89627#issuecomment-1524002193, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG5EKQN2C2ZW657RYCQ5CELXDGADZANCNFSM6AAAAAAVY6ZHTE. You are receiving this because you authored the thread.Message ID: @.***>

scaglar78 avatar Apr 26 '23 20:04 scaglar78

Hello @DavidMStraub, the problem is that the url the integration uses during the first setup for oauth is not the one, configured in the developer portal of home connect. This is the part of the url: https://api.home-connect.com/security/oauth/authorize?response_type=code&client_id=4BB586607C31DAEFA796F6F7620FCA2C879558B81CFFB41C1C9BB976A9204DA2&r**edirect_uri=https://my.home-assistant.io/redirect/oauth**&state= In the developer portal I configured: http://192.168.177.225:8123/auth/external/callback So I get an "unauthorized client" error. I disabled my.home-assistant so an external redirection is not possible. Kind regards and thanks for your help. Niklas

I copied the URL giving the error, replaced the '/my.home-assistant.io' part of the redirect_uti argument with the address of my home instance, and pasted it back in the browser. This brought me to the correct login page.

I did exactly that and got 400 Bad Request in my HA logs (just "error" in the HA UI):

2023-05-14 14:37:32.075 ERROR (MainThread) [aiohttp.server] Error handling request
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 227, 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')

ptrsconsulting avatar May 14 '23 15:05 ptrsconsulting

Sorry David I think I was a little too frustrated due to the amount of time I have spent fixing the issues. Another reason I didn’t provide any details is that there already is a lot posts with same or similar issues. I will as soon as possible provide a detailed description of my HA setup, the installation process and finally the error messages. Thanks. Med venlig hilsen | Kind regards Süleyman Çağlar ________________________________ From: David Straub @.> Sent: Friday, March 24, 2023 12:43:09 PM To: home-assistant/core @.> Cc: scaglar78 @.>; Author @.> Subject: Re: [home-assistant/core] Home Connect integration doesn't work. (Issue #89627) The point of my comment was that an issue which contains "it does not work" as sole information is a waste of everyone's time, and if you want to motivate others to look into the issue, that (plus adding an impolite comment) will not work. To be clear, I am not a maintainer or anything, I just provided the initial implementation of the integration long ago. By the way, the integration is working fine for me. — Reply to this email directly, view it on GitHub<#89627 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG5EKQPQLWFAJO6FPPYLIPTW5WCE3ANCNFSM6AAAAAAVY6ZHTE. You are receiving this because you authored the thread.Message ID: @.***>

Hi again.. Now I have retried again (still no success) and noted down my findings.

A little bit about my setup. I have Home Assistant deployed in a VM running on a Synology NAS. I can access HA both locally using a local IP, but also using a Internet facing URL over https. The https connection to HA is ensured using Reverse Proxy functionality on Synology which maps oncoming https request to the internal http-url of the HA.

I have created three applications at bosch developer site with different redirect URLs. A) 1x Local IP as redirect URL B) 1x Internet facing URL as redirect URL C) 1x Standard "https://my.home-assistant.io/redirect/oauth" as redirect URL

Using A) and B) credentials during integration setup results in following error { "error": "unauthorized_client", "error_description": "request rejected by client authorization authority (developer portal)", "state": "eyJhbGciOiJI...TlFJ5T9Q3iw" }

In case of C) I was able to get to the Bosch login page and logged in successfully. Afterwards I got to the my.home-assistant.io mapping page. Here I tried mapping to local-URL http://192.168.XXX.XXX:8123 (while accessing the HA through local URL). This resulted in a "Error" pop-up in HA without any further details. Looking into Logs I found following message:

2023-05-24 12:31:31.325 ERROR (MainThread) [aiohttp.server] Error handling request 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/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')

Then I tried repeating previous step from HA logged in through Internet URL and tried mapping my.home-assistant.io to the Internet facing URL, but resulting in same error as above.

Replacing "my.home-assistant.io" with local-URL or Internet-URL in the browser didn't help either. I got same error as in A) and B) above.

So, any ideas? :-) Thanks.

scaglar78 avatar May 24 '23 11:05 scaglar78

Hi @scaglar78 , After your post I gave it another try, and this time it worked. These were the steps I took:

  • I opened "https://my.home-assistant.io/" where my home assistant instance was set to the external address of my HA.
  • In the home connect developer page I changed the redirect URIs to exactly "https://my.home-assistant.io/redirect/oauth"
  • I logged out developer account and I waited for 15 min.
  • I now successfully added the Home Connect integration in Home Assistant. (It was the 2nd step I never tried before, I only tried my internal and external addresses)

rspring avatar May 24 '23 19:05 rspring

Well, in my case, it just doesn’t work. The steps you have taken is already covered by one of the scenarios I have already tested. But I retried your exactly steps just to be sure.. still same problem..

/Süleyman

From: @.> Sent: Wednesday, 24 May 2023 21.23 To: @.> Cc: @.>; @.> Subject: Re: [home-assistant/core] Home Connect integration doesn't work. (Issue #89627)

Hi @scaglar78https://github.com/scaglar78 , After your post I gave it another try, and this time it worked. These were the steps I took:

  • I opened "https://my.home-assistant.io/" where my home assistant instance was set to the external address of my HA.
  • In the home connect developer page I changed the redirect URIs to exactly "https://my.home-assistant.io/redirect/oauth"
  • I logged out developer account and I waited for 15 min.
  • I now successfully added the Home Connect integration in Home Assistant.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/89627#issuecomment-1561807838, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG5EKQK5DAEMYH65VCTL5Z3XHZN3LANCNFSM6AAAAAAVY6ZHTE. You are receiving this because you were mentioned.Message ID: @.***>

scaglar78 avatar Jun 08 '23 08:06 scaglar78

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.