home-assistant/core

Toon integration stops working every couple of days

alleknalle opened this issue · 7 comments

The problem

Every couple of days my Toon integration stops working. In Home Assistant it just shows that it can't setup the integration. The only way to make it work again is to delete the integration and create it again with the exact same configuration. Then it works for a couple of days, but then it stops again.

I've used the integration for years without issues, but on March 14th it stopped working for the first time. After some searching on the internet I've deleted my Toon configuration and created a new app on developer.toon.eu. Then I added the configuration with the new keys and then it worked again. This was March 27th.
Then on April 6th it stopped working again. Then I only deleted the integration and re-added it again after which it was working again.
But then today (April 9th) it stopped working again. I've done the same things as on April 6th and now it works again
I don't want to fix the integration every couple of days, so I hope someone can help me fix this :-)

I always keep my Home Assistant up-to-date, so I guess the first time it stopped working was in core-2024.3.0 or core-2024.3.1.

The error in my log file of today:

2024-04-09 17:07:22.777 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry XXXXXXXXX for toon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 93, in async_setup_entry
    await coordinator.toon.activate_agreement(
  File "/usr/local/lib/python3.12/site-packages/toonapi/toon.py", line 161, in activate_agreement
    await self.agreements()
  File "/usr/local/lib/python3.12/site-packages/toonapi/toon.py", line 182, in agreements
    agreements = await self._request(
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/toonapi/toon.py", line 79, in _request
    self.token = await self.token_refresh_method()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/coordinator.py", line 38, in async_token_refresh
    await session.async_ensure_token_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 523, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 94, in async_refresh_token
    new_token = await self._async_refresh_token(token)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 116, in _async_refresh_token
    new_token = await self._token_request(data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 135, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not found', url=URL('https://api.toon.eu/token')

What version of Home Assistant Core has the issue?

core-2024.4.2

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

Toon

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-04-09 17:07:22.777 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry XXXXXXXXX for toon
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 93, in async_setup_entry
    await coordinator.toon.activate_agreement(
  File "/usr/local/lib/python3.12/site-packages/toonapi/toon.py", line 161, in activate_agreement
    await self.agreements()
  File "/usr/local/lib/python3.12/site-packages/toonapi/toon.py", line 182, in agreements
    agreements = await self._request(
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/toonapi/toon.py", line 79, in _request
    self.token = await self.token_refresh_method()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/coordinator.py", line 38, in async_token_refresh
    await session.async_ensure_token_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 523, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 94, in async_refresh_token
    new_token = await self._async_refresh_token(token)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 116, in _async_refresh_token
    new_token = await self._token_request(data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 135, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not found', url=URL('https://api.toon.eu/token')

Additional information

No response