Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
413 stars 85 forks source link

string indices must be integers #553

Closed hmmbob closed 1 year ago

hmmbob commented 1 year ago

Region and Brand of car Europe Hyundai

Version of the integration 2.4.1

Describe the bug Since 2.4.x I have several errors of string indices must be integers in my logs:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/kia_uvo/coordinator.py", line 102, in _async_update_data
    await self.async_check_and_refresh_token()
  File "/config/custom_components/kia_uvo/coordinator.py", line 159, in async_check_and_refresh_token
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 113, in check_and_refresh_token
    self.initialize()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in initialize
    self.token: Token = self.api.login(self.username, self.password)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 182, in login
    device_id = self._get_device_id(stamp)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 953, in _get_device_id
    device_id = response["resMsg"]["deviceId"]
TypeError: string indices must be integers

Not sure what is causing this & can't really find anything that looks broken.

cdnninja commented 1 year ago

Enable debug logs and post them.

hmmbob commented 1 year ago

Here you go

home-assistant_2023-01-07T17-27-24.467Z.log

cdnninja commented 1 year ago

It looks like the API errored out and then retried and worked fine. Does the integration work still? I have created a change to catch this error but that will just make the logs look a bit cleaner. Nothing beyond that.

hmmbob commented 1 year ago

It looks like the API errored out and then retried and worked fine. Does the integration work still? I have created a change to catch this error but that will just make the logs look a bit cleaner. Nothing beyond that.

All works fine indeed

cdnninja commented 1 year ago

Essentially the API is failing to respond correctly. Home assistant logs this since the data is now stale. It will retry, when it does often it works correctly and the integration continues on.

hmmbob commented 1 year ago

Makes sense. Thanks again for your great work!