skodaconnect / homeassistant-myskoda

Homeassistant integration for MySkoda.
73 stars 10 forks source link

Unexpected error fetching myskoda data #16

Closed sonar98 closed 1 month ago

sonar98 commented 1 month ago

With release 1.2.7 after a while all the sensors and entities become unavailable in HA. When doing a reload of the integration everything is available again.

The logs are showing the following error:


Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.myskoda
Bron: helpers/update_coordinator.py:354
integratie: MySkoda (documentatie, problemen)
Eerst voorgekomen: 10:44:30 (1 gebeurtenissen)
Laatst gelogd: 10:44:30

Unexpected error fetching myskoda data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/myskoda/__init__.py", line 81, in _async_update_data
    "vehicles": await self.hub.get_all_vehicles(),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/myskoda/rest_api.py", line 193, in get_all_vehicles
    return await gather(*[self.get_vehicle(vehicle) for vehicle in await self.list_vehicles()])
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/myskoda/rest_api.py", line 165, in list_vehicles
    headers=await self._headers(),
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/myskoda/rest_api.py", line 196, in _headers
    return {"authorization": f"Bearer {await self.idk_session.get_access_token(self.session)}"}
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/myskoda/authorization.py", line 96, in get_access_token
    await self.perform_refresh(session)
  File "/usr/local/lib/python3.12/site-packages/myskoda/authorization.py", line 81, in perform_refresh
    data = json.loads(await response.text())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
WebSpider commented 1 month ago

Yes, I have the same and have been debugging since yesterday afternoon. It's probably related to the authentication, but I haven't managed to figure out what is going on here.

sonar98 commented 1 month ago

I think it must be something that has changed in the latest version. As far as I know I did not have this problem with the previous version.

Version of myskoda changed: myskoda = "^0.2.3" myskoda = "^0.3.0"

WebSpider commented 1 month ago

I have had it since 0.2.2, the first version I tested ;)

sonar98 commented 1 month ago

Tried version 1.2.6 (with myskoda 0.2.3) and this one indeed has the same problem.

jrjuniortkf commented 1 month ago

I am receiving the following error message when I try to use this plugin.

pydantic.error_wrappers.ValidationError: 1 validation error for Info specification -> body value is not a valid enumeration member; permitted: 'SUV', 'Combi' (type=type_error.enum; enum_values=[<BodyType.SUV: 'SUV'>, <BodyType.COMBI: 'Combi'>])

Version 1.2.7 from the repository Prior99/myskoda works well.

dvx76 commented 1 month ago

@jrjuniortkf please log a separate issue for separate errors. Include what car model you have and possible more lines of the error - it should include the value you are getting.

sonar98 commented 1 month ago

I tried with version 1.2.4 (uses myskoda 0.1.5) this seems to be working.

When checking the differences between 0.1.5 and 0..2.0 I saw these changes: 0.1.5: expiry = datetime.fromtimestamp(cast(float, meta.get("exp"))) if datetime.now() + timedelta(minutes=10) > expiry: 0.2.0: expiry = datetime.fromtimestamp(cast(float, meta.get("exp")), tz=UTC) if datetime.now(tz=UTC) + timedelta(minutes=10) > expiry:

Could it be that by adding the timezone the expiry is not working correctly anymore?

dvx76 commented 1 month ago

Should be fixed by https://github.com/skodaconnect/myskoda/pull/7

sonar98 commented 1 month ago

Unfortunately not fixed with the prerelease version.