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
73.56k stars 30.74k forks source link

Litter-Robot integration stopped working, "Cannot reopen a client instance, once it has been closed." #58205

Closed Aephir closed 3 years ago

Aephir commented 3 years ago

The problem

For a while now, Home Assistant has not had access to the Litter Robot (see log below, though it's quite minimal).

The mobile app works fine, so the litter robot is online. I've seen some of the other (closed) issues, e.g. #56716, but neither a disable/enable, a full remove/re-add, Hass system restart or litter robot power cycling made any difference.

This has been an issue on several Home Assistant Core versions. Unfortunately, it is not an integration I have used that much, so I'm not sure exactly when this started (which version). But it has worked at some point, so I'm pretty sure it was set up correctly.

What is version of Home Assistant Core has the issue?

core-2021.10.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Litter-Robot

Link to integration documentation on our website

https://www.home-assistant.io/integrations/litterrobot/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.config_entries
Source: config_entries.py:335
First occurred: 08:58:45 (1 occurrences)
Last logged: 08:58:45

Config entry 'MY_EMAIL' for litterrobot integration not ready yet: Cannot reopen a client instance, once it has been closed.; Retrying in background

Additional information

No response

probot-home-assistant[bot] commented 3 years ago

litterrobot documentation litterrobot source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years ago

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

natekspencer commented 3 years ago

@Aephir, this should have been resolved as of HA core-2021.8.2. Did you ever have the HACS version of the Litter-Robot integration installed? If so, it's possible you still have it and need to uninstall it or else it overrides the official integration.

Aephir commented 3 years ago

You're right, I did have the HACS version. I uninstalled that, restarted Home Assistant, and added the integration.

Short version, it works now. Although it first threw the error below (even after HASS reboot). I'm not sure if this is relevant, but I'll just add it in case it can help someone.

After retrying a handful of times (which included power cycling the Litter Robot), it seems to work now.

Logger: homeassistant.config_entries
Source: components/litterrobot/hub.py:46
First occurred: 10:03:15 (1 occurrences)
Last logged: 10:03:15

Error setting up entry MY_EMAIL for litterrobot
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 61, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 281, in handle_async_request
    ) = await self._pool.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 234, in handle_async_request
    response = await connection.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 148, in handle_async_request
    return await self.connection.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 128, in handle_async_request
    ) = await self._receive_response(timeout)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 189, in _receive_response
    event = await self._receive_event(timeout)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 225, in _receive_event
    data = await self.socket.read(self.READ_NUM_BYTES, timeout)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 63, in read
    raise ReadTimeout from None
httpcore.ReadTimeout

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/litterrobot/__init__.py", line 20, in async_setup_entry
    await hub.login(load_robots=True)
  File "/usr/src/homeassistant/homeassistant/components/litterrobot/hub.py", line 46, in login
    await self.account.connect(
  File "/usr/local/lib/python3.9/site-packages/pylitterbot/account.py", line 42, in connect
    await self._session.fetch_token(
  File "/usr/local/lib/python3.9/site-packages/pylitterbot/session.py", line 86, in fetch_token
    return await self._client.fetch_token(username=username, password=password)
  File "/usr/local/lib/python3.9/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 120, in _fetch_token
    resp = await self.post(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1825, in post
    return await self.request(
  File "/usr/local/lib/python3.9/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 94, in request
    return await super(AsyncOAuth2Client, self).request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1494, in request
    response = await self.send(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1586, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1616, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1655, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1699, in _send_single_request
    ) = await transport.handle_async_request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 276, in handle_async_request
    (
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 78, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ReadTimeout