core icon indicating copy to clipboard operation
core copied to clipboard

Neato Botvac Integration Problem

Open Klimpen91 opened this issue 2 years ago • 31 comments

The problem

I can't integrate Neato botvac.

I have created an app at neato developer network and when I try to integrate in home assistant. I can authorize and then I get to the page asking to link account to home assistant and I've put in my duckdns.org adress under "Your instance URL" and then I come back to home assistant and it says "Error".

What am I doing wrong?

What version of Home Assistant Core has the issue?

2022.9.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Neato Botvac

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?

Logger: aiohttp.server
Source: helpers/config_entry_oauth2_flow.py:205
First occurred: 22:55:42 (3 occurrences)
Last logged: 22:57:16

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, 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 60, 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 82, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 169, 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 280, 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 303, in async_step_creation
    token = await self.flow_impl.async_resolve_external_data(self.external_data)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 169, in async_resolve_external_data
    return await self._token_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 205, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://beehive.neatocloud.com/oauth2/token')

Additional information

No response

Klimpen91 avatar Sep 14 '22 21:09 Klimpen91

neato documentation neato source (message by IssueLinks)

Hey there @dshokouhi, @santobert, mind taking a look at this issue as it has been labeled with an integration (neato) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Looks like you are using the wrong URL. Did you look at the docs on how to set this up correctly?

https://www.home-assistant.io/integrations/neato#prerequisites

dshokouhi avatar Sep 15 '22 14:09 dshokouhi

I am using https://my.home-assistant.io/redirect/oauth as the redirected URL and I am using my duckdns adress when I link my account to home assistant.

Klimpen91 avatar Sep 16 '22 06:09 Klimpen91

Is that wrong?

Klimpen91 avatar Sep 20 '22 13:09 Klimpen91

I've just upgraded HA to the latest and neato integration asked to reconfigure as the token has expired. I've deleted the old integration and tried adding a new one but when I click the "Open Website" button I get "The redirect uri included is not valid." error. When I look at the URL HA generated I can see this - "redirect_uri=https://my.home-assistant.io/redirect/oauth". This is wrong as I have in my configuration.yaml external_url: "https://XXXX.duckdns.org" and I'm accessing HA via that external url when trying to add this integration. Further on, I've edited that URL by hand putting "redirect_uri=https%3A%2F%2FXXXX.duckdns.org%2Fauth%2Fexternal%2Fcallback". Now I'm getting to the authorisation page on the neato's website. However when I click Authorise button I just get 500 response. Any suggestions how I can fix it?

antonoal avatar Oct 09 '22 10:10 antonoal

The My Home Assistant link is not the wrong URL to use. It is just a redirect once you set it up.

dshokouhi avatar Oct 09 '22 14:10 dshokouhi

I have t set it up and frankly speaking I’d rather didn’t. Besides the documentation to the integration doesn’t say anything about the necessity to set it up. In any case the problem is not in the redirect url itself. Rather in the 500 response. move tried in the meantime suggested on the community forum to explicitly add the 443 port to the redirect url but still getting error in HA once I authorise in neato.

antonoal avatar Oct 09 '22 14:10 antonoal

The My Home Assistant link is not the wrong URL to use. It is just a redirect once you set it up.

The my home assistant link is actually wrong as it’s not even escaped.

antonoal avatar Oct 12 '22 08:10 antonoal

I am also seeing the 401 unauthorized issue, as well as the 500 server error. Similar to @antonoal, I didn't see anything in the documentation specifying that we needed to configure anything with my.home-assistant.com, and there is a section for manual configuration which highlights using the auth/external/callback URI if necessary. This error is easily reproducable, so I am unsure why @dshokouhi is acting like this is a user error. For whatever reason, the auth token is never getting handed off properly and so that is why we are getting the 401 errors. It would be great if the devs could ask for more helpful information instead of being so dismissive. I understand that this is something that you are doing in your free time, and really appreciate the effort that y'all put in.

Here is the log for the 500:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, 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 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 222, 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 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 433, in get
    await hass.config_entries.flow.async_configure(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 263, in async_configure
    raise UnknownFlow
homeassistant.data_entry_flow.UnknownFlow

gcardy avatar Oct 15 '22 18:10 gcardy

Have been messing around a bit too with this. Some things to take into account:

  • The "redirect URL" is not used at all by Neato or HA. It's just a fictuous URL that you need to specify. So you don't need to use the DuckDNS or your actual URL that can be used to reach your HA installation from the public internet.
  • So basically, just create the new Neato App with literally "https://my.home-assistant.io/redirect/oauth" (as per the documentation) at the Neato developer network.
  • Remove any old Application Credentials from Home Assistant
  • Add again the Neato integration.

jacobstim avatar Oct 22 '22 10:10 jacobstim

Have been messing around a bit too with this. Some things to take into account:

  • The "redirect URL" is not used at all by Neato or HA. It's just a fictuous URL that you need to specify. So you don't need to use the DuckDNS or your actual URL that can be used to reach your HA installation from the public internet.
  • So basically, just create the new Neato App with literally "https://my.home-assistant.io/redirect/oauth" (as per the documentation) at the Neato developer network.
  • Remove any old Application Credentials from Home Assistant
  • Add again the Neato integration.

Did that exactly as you described. Got this:

Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.

antonoal avatar Oct 27 '22 14:10 antonoal

as descript above works like a charm but don't for get to activate "my home assistant" in your config https://www.home-assistant.io/integrations/my

axeltbraun avatar Oct 30 '22 08:10 axeltbraun

Ok, I must be doing something wrong. Therefore I’ve just made a screen recording on my iPad where I’m trying to add it as described and it’s failing.

https://youtu.be/yzKetHlUOTI

Can someone help me understand where I’m off the happy path?

Thanks, Alex

antonoal avatar Oct 30 '22 11:10 antonoal

There is some confusion here. In fact, the integration is currently broken, IF one doesn't have "My Home Assistant" activated. If you attempt to setup the integration with a local redirect URL, e.g https://192.168.1.1:8123/auth/external/callback as outlined in the docs when you click the "I have manually disabled My Home Asisstant", it will not work, because despite a local redirct url configured, it will pass on "https://my.home-assistant.io/redirect/oauth" as redirect URL to he Neato Website, and that doesn't match the configuration there, hence triggers the redirect error.

infocfc avatar Nov 01 '22 17:11 infocfc

As far as I understand myhomeassistant is enabled by default and I’ve never disabled it. As can be seen in the video I actually use it to get to my HA instance. Yet even with it in place I can’t make the integration work.

antonoal avatar Nov 01 '22 17:11 antonoal

And of course, then there is the next issue: Once you've reached the point of the configuration that redirects to the Neato website, you're stuck. You can't delete the integration and start over, as it doesn't show in the integrations tab. When you try to add it again, you immediately get redirected to the neato website.

infocfc avatar Nov 01 '22 17:11 infocfc

I found the solution in another topic, you have to use the following URL:

https://my.home-assistant.io/redirect/oauth

for me also the same problem, I always get the error: The redirect uri included is not valid. it always worked perfect, but after updating homeassistant it is not working anymore

skywalker-750 avatar Nov 07 '22 18:11 skywalker-750

Does not work (2022.11.x, 2022.12.x), no matter if "my" is enabled or not. Manual substitution of URL ends up in error 500:

File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://beehive.neatocloud.com/oauth2/token')

Can this be related to external URL not having default (443) port?

lazyoldbear avatar Dec 24 '22 01:12 lazyoldbear

I have exactly the same issue, no more able to integrate Neato

McLP11 avatar Dec 24 '22 17:12 McLP11

Я нашел решение в другой теме, вы должны использовать следующий URL-адрес:

https://my.home-assistant.io/redirect/oauth

для меня также та же проблема, я всегда получаю сообщение об ошибке: включенный uri перенаправления недействителен. он всегда работал отлично, но после обновления homeassistant больше не работает

Thanks! It's work!!!

pervolianinen avatar Dec 26 '22 19:12 pervolianinen

I'm using the mentioned link but still not working for me...

McLP11 avatar Dec 26 '22 20:12 McLP11

I have the same issue. Integration seems to be broken for the moment.

EDIT: It isn't broken, just a bit confusing. I have a custom domain for my HA installation and thought I would have to use the "I have disabled the My ..." way. But I didn't. Just followed the documentation and everything works fine.

derVicthor avatar Dec 26 '22 22:12 derVicthor

Greetings, I too have a similar problem with this integration:

  1. I created "application" from neato site: https://developers.neatorobotics.com/applications
  2. I have duckdns as an external url, with an active and functioning ssl certificate
  3. I removed all previous credentials from HA, including the integration, and tried to re-integrate it

... but when the authorization is confirmed from the site (after opening the web page from the neato integration), the HA simply says "ERROR". Cattura

In the HA log, this comes out:

Logger: aiohttp.server
Source: helpers/config_entry_oauth2_flow.py:205
First occurred: 02:25:57 (3 occurrences)
Last logged: 02:38:53

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, 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 60, 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 81, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, 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 281, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 303, in async_step_creation
    token = await self.flow_impl.async_resolve_external_data(self.external_data)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 169, in async_resolve_external_data
    return await self._token_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 205, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://beehive.neatocloud.com/oauth2/token')

I also "fixed" the part of the link that opens the authorization integration -the Redirect URI- https://my.home-assistant.io/redirect/oauth with https://myname.duckdns.org:8123/auth/external/callbacks but after confirming the authorization, it gives me that error.

advice?

---- I have a neato D4 ----

-------------- UPDATE -------------->>>>>

update: as written above by @skywalker-750 , in the Neato site https://developers.neatorobotics.com/applications, after creating the application, in the Redirect URI, you must put https://my.home-assistant.io/redirect/oauth and not our custom. So accept it and move on. all ok now!

Jones1982 avatar Dec 29 '22 01:12 Jones1982

And of course, then there is the next issue: Once you've reached the point of the configuration that redirects to the Neato website, you're stuck. You can't delete the integration and start over, as it doesn't show in the integrations tab. When you try to add it again, you immediately get redirected to the neato website.

I'm having the same issue, did you figure out a way around this? I tried restarting HA but it still won't let me start the configuration flow from the beginning.

eagleco avatar Jan 19 '23 19:01 eagleco

Finally have fixed the intergation. For me it didn’t work even though I recreated the app in netatmorobotics with https://my.home-assistant.io/redirect/oauth redirect url. Turned out I’d had stale credentials cached by HA. I found it in Settings -> Devices & Services -> Three vertical dots in the top right corner -> Application Credentials After I removed neato creds and vent through set up integration process, I was requested client id and secret that I copied from the neato’s application. eventually it worked.

antonoal avatar Jan 20 '23 10:01 antonoal

This is not exactly directly an issue with this integration - but when I attempt to log in to the Neato Developer page to set up the API, I'm not able to log in. I've seen a lot of complaints about support, so just wanted to check if others are able to actually log in to the developer page and access the API still - before I put more time into trying to figure this out. I'm a US citizen living overseas - in account creation, if I entered my country of residence vs. USA, anyone know if that would screw up my ability to use my Neato account at the developer site?

t21wolves avatar Jan 29 '23 03:01 t21wolves

I am experiencing this issue as well. Deleting the credentials inside Home Assistant did not make it better. It still tries to redirect my to https://my-homeas... even though i have set up another url in neato.

Christian-PK avatar Mar 06 '23 19:03 Christian-PK

I am experiencing this issue as well. Deleting the credentials inside Home Assistant did not make it better. It still tries to redirect my to https://my-homeas... even though i have set up another url in neato.

I believe that wouldn’t work. You must use my-homeassistant in neato.

antonoal avatar Mar 07 '23 08:03 antonoal

I am experiencing this issue as well. Deleting the credentials inside Home Assistant did not make it better. It still tries to redirect my to https://my-homeas... even though i have set up another url in neato.

I believe that wouldn’t work. You must use my-homeassistant in neato.

I have had it previously working without my homeasstiant and there is also a section in the documentation that describes how to do it. So I think it should be able to do it.

Christian-PK avatar Mar 07 '23 08:03 Christian-PK