CJNE / ha-porscheconnect

Porsche Connect custom component for Home Assistant
MIT License
29 stars 12 forks source link

Problem to start/create the integration: KeyError: 'access_token' / TypeError: 'HassLogger' object is not callable #185

Closed browetd closed 1 year ago

browetd commented 1 year ago

Version of the custom_component

0.0.14

Configuration

Through the integration (no yaml)

Describe the bug

Impossible to start the integration or even reload it... If I recreate the integration, I cannot login... so no debug log available as the integration has been removed and no way to recreate it...

Debug log

2023-06-15 08:26:59.223 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for porscheconnect doing blocking calls at custom_components/porscheconnect/__init__.py, line 94: access_tokens = await controller.getAllTokens()
2023-06-15 08:27:02.022 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for porscheconnect doing blocking calls at custom_components/porscheconnect/__init__.py, line 94: access_tokens = await controller.getAllTokens()
2023-06-15 08:27:04.918 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <email_removed> for porscheconnect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/porscheconnect/__init__.py", line 94, in async_setup_entry
    access_tokens = await controller.getAllTokens()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/client.py", line 32, in getAllTokens
    return await self._connection.getAllTokens()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 204, in getAllTokens
    token = await self._requestToken(application)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 229, in _requestToken
    jwt = self.jwt_payload_decode(token_data["access_token"])
                                  ~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'access_token'

If I try to reload the integration, I am getting this error

2023-06-15 08:28:29.874 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry <email_removed> for porscheconnect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/porscheconnect/__init__.py", line 94, in async_setup_entry
    access_tokens = await controller.getAllTokens()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/client.py", line 32, in getAllTokens
    return await self._connection.getAllTokens()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 204, in getAllTokens
    token = await self._requestToken(application)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 211, in _requestToken
    await self._login()
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 128, in _login
    _LOGGER("We already have a code in session, skip login")
TypeError: 'HassLogger' object is not callable
CJNE commented 1 year ago

I just pushed version 0.0.15 that should fix the login problems, I haven't seen the HassLogger error but hopefully it should not be a problem with this version.

browetd commented 1 year ago

Problem fixed... Thank you for the very quick fix !!!