home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.22k stars 29.85k forks source link

Error during setup of component dyson: api.cp.dyson.com: Failed to establish a new connection: [Errno -2] Name does not resolve' #26653

Closed homekitter closed 4 years ago

homekitter commented 5 years ago

Home Assistant release with the issue: Home Assistant 0.98.5

Last working Home Assistant release (if known): Home Assistant 0.98.5 (Unchanged)

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io

Component/platform: Dyson

Description of problem: Error during setup of component dyson

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant): From: configuration.yaml

dyson: !include dyson.yaml

From: dyson.yaml

username: !secret dyson_username
password: !secret dyson_password
language: !secret dyson_language

From: secrets.yaml

dyson_username: <<redacted>>
dyson_password: <<redacted>>
dyson_language: GB

Traceback (if applicable):

Additional information:

2019-09-14 17:58:05 ERROR (MainThread) [homeassistant.setup] Error during setup of component dyson
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 344, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 843, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 316, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x72912a10>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.cp.dyson.com', port=443): Max retries exceeded with url: /v1/userregistration/authenticate?country=GB (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x72912a10>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 172, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/dyson/__init__.py", line 54, in setup
    logged = dyson_account.login()
  File "/usr/local/lib/python3.7/site-packages/libpurecool/dyson.py", line 54, in login
    DYSON_API_URL, self._country), request_body, verify=False)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.cp.dyson.com', port=443): Max retries exceeded with url: /v1/userregistration/authenticate?country=GB (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x72912a10>: Failed to establish a new connection: [Errno -2] Name does not resolve'))
homekitter commented 5 years ago

I think dyson may have changed the name of their api server…

Tried resolving api.cp.dyson.com elsewhere without success.

homekitter commented 5 years ago

Took a look at my pi-hole instance after opening the app and saw an entry for a1u2wvl3e2lrc4-ats.iot.eu-west-1.amazonaws.com

homekitter commented 5 years ago

Dyson app on my phone updated on Sept 3. They may have decommissioned old api server?

homekitter commented 5 years ago

It seems that 'api.cp.dyson.com' is back…

Am now getting new errors…

Our Cli: $ hassio help ➜ ~ cd config ➜ config grep -i dyson home-assistant.log 2019-09-15 09:21:52 INFO (MainThread) [homeassistant.setup] Setting up dyson 2019-09-15 09:21:52 INFO (SyncWorker_3) [homeassistant.components.dyson] Creating new Dyson component 2019-09-15 09:21:53 ERROR (SyncWorker_3) [homeassistant.components.dyson] Not connected to Dyson account. Unable to add devices 2019-09-15 09:21:54 INFO (MainThread) [homeassistant.setup] Setup of domain dyson took 1.6 seconds. 2019-09-15 09:21:54 ERROR (MainThread) [homeassistant.setup] Setup failed for dyson: Integration failed to initialize. ➜ config

RomRider commented 5 years ago

Same issue here. It is still working in the app though. I checked within the libpurecool code and when I'm issuing the same request as here, it returns with the proper message:

curl -X POST -H "Content-Type: application/json" -k \
  'https://api.cp.dyson.com/v1/userregistration/authenticate?country=FR' \
  -d '{"Email": "xxx@zzz.com", "Password": "SuperPassword"}'

Returns:
{"Account":"xxxxxx","Password":"yyyyyyy"}

Don't quite understand what is happening...

I tried multiple times with a wrong request and now I'm receiving 503 Service Unavailable (My public IP seems banned... Hopefully it's only temporary). With a new IP it works again.

Also some kind of rate limiting seems to be in place (don't know if it was the case before or not)

homekitter commented 5 years ago

Seemingly self corrected a moment ago.

RomRider commented 5 years ago

I think actually their service is crashing in the backend as it randomly works/doesn't work anymore using curl

stale[bot] commented 4 years ago

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.