skodaconnect / homeassistant-myskoda

Homeassistant integration for MySkoda.
79 stars 12 forks source link

Values become 'unavailable' after a couple of hours. #26

Closed mhaket closed 1 month ago

mhaket commented 1 month ago

When I initiate the mySkoda device (using HA version 2024.9.2, mySkoda 1.2.7, Skoda on 3.7), the different sensor values are populated with real values. After a couple of hours, all sensors become unavailable and the error log shows the following message:

Logger: custom_components.myskoda
Source: helpers/update_coordinator.py:354
integration: MySkoda ([documentation](https://github.com/skodaconnect/homeassistant-myskoda/blob/main/README.md), [issues](https://github.com/skodaconnect/homeassistant-myskoda/issues))
First occurred: September 21, 2024 at 13:11:58 (339 occurrences)
Last logged: 18:11:57

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)

After reloading the device, the values become populated again.

dvx76 commented 1 month ago

Thanks. It's a known issue we're working on in skodaconnect/myskoda#13. Closing as dup.