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
433 stars 85 forks source link

Retrying setup: Config Not Ready: list index out of range #535

Closed terrycalderbank closed 1 year ago

terrycalderbank commented 1 year ago

Please check Services, Known Bug / Issues and Troubleshooting over here first: https://github.com/fuatakgun/kia_uvo/blob/master/README.md Region and Brand of car Canada, 2021 Hyundai Ioniq EV Preferred Trim

Version of the integration V2.2.1

Describe the bug As stated in issue title. At some point in the last year, my integration stopped working. I updated each time a new version came out, but at this point I feel it's probably best to work with you guys on this.

Debug logs if an error occurred

Outlined here: https://github.com/fuatakgun/kia_uvo/blob/master/README.md

2022-12-23 15:17:10.947 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: list index out of range
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 93, in check_and_refresh_token
    self.initialize()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 55, in initialize
    self.update_all_vehicles_with_cached_state()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 62, in update_all_vehicles_with_cached_state
    self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 65, in update_vehicle_with_cached_state
    self.api.update_vehicle_with_cached_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 140, in update_vehicle_with_cached_state
    self._update_vehicle_properties_charge(vehicle, charge)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 600, in _update_vehicle_properties_charge
    vehicle.ev_charge_limits_ac = [x['level'] for x in state if x['plugType'] == 1][-1]
IndexError: list index out of range
2022-12-23 15:17:23.410 WARNING (SyncWorker_6) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get vehicle location failed
2022-12-23 15:17:23.878 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: list index out of range
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 93, in check_and_refresh_token
    self.initialize()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 55, in initialize
    self.update_all_vehicles_with_cached_state()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 62, in update_all_vehicles_with_cached_state
    self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 65, in update_vehicle_with_cached_state
    self.api.update_vehicle_with_cached_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 140, in update_vehicle_with_cached_state
    self._update_vehicle_properties_charge(vehicle, charge)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 600, in _update_vehicle_properties_charge
    vehicle.ev_charge_limits_ac = [x['level'] for x in state if x['plugType'] == 1][-1]
IndexError: list index out of range`

To Reproduce I could share my credentials with a main developer if needed.

Expected behavior

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

terrycalderbank commented 1 year ago

I just tried removing the configured integration, removing the HACS integration, and re-installing/re-configuring. Received the same message.

cdnninja commented 1 year ago

Please download the latest using hacs, select in the version menu "master". Then enable debug logs as outlined on the readme and post the debug logs? In particular I am looking for a line that states. "- Received get_charge_limits:" and what follows it.

terrycalderbank commented 1 year ago

Looks like the daily limit of remote service requests has been exceeded. Will get another debug log tomorrow. For now I have this:

2022-12-23 22:56:54.726 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Vehicles Response {"responseHeader":{"responseCode":0,"responseDesc":"Success"},"result":{"vehicles":[{"vehicleId":"XkfhdHMVuCM2Ir4ss1Ju3Q==","nickName":"Hyundai Ioniq","modelCode":"IO15EFEME800","modelName":"IONIQ EV","modelYear":"2021","fuelKindCode":"E","trim":"EV Preferred -","engine":"","exteriorColor":"WAW","dtcCount":0,"subscriptionStatus":"A","subscriptionEndDate":"20240717","mileageForNextService":11662.2,"daysForNextService":"20230604","overviewMessage":"","defaultVehicle":true,"enrollmentStatus":"4","genType":"G2.5","valetParkingModeOn":0,"vin":"KMHC75LJ2MU081961"}]}}
2022-12-23 22:56:54.965 WARNING (MainThread) [homeassistant.components.binary_sensor] Updating ping binary_sensor took longer than the scheduled update interval 0:00:00.500000
2022-12-23 22:56:55.140 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20221223231838', 'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '00H', 'unit': 0}, 'defrost': False, 'acc': False, 'evStatus': {'batteryCharge': False, 'batteryStatus': 68, 'batteryPlugin': 0, 'remainTime2': {'etc1': {'value': 0, 'unit': 1}, 'etc2': {'value': 0, 'unit': 1}, 'etc3': {'value': 155, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'gasModeRange': {'value': 0.0, 'unit': 1}, 'evModeRange': {'value': 173.0, 'unit': 1}, 'totalAvailableRange': {'value': 173.0, 'unit': 1}}, 'type': 2}], 'batteryPreconditiong': False}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'dte': {}, 'tirePressureLamp': {'tirePressureLampAll': 0}, 'battery': {'batSoc': 84, 'sjbDeliveryMode': 1, 'batSignalReferenceValue': {}}, 'remoteIgnition': True, 'seatHeaterVentInfo': {}, 'sleepModeCheck': False, 'lampWireStatus': {'headLamp': {}, 'stopLamp': {}, 'turnSignalLamp': {}}, 'windowOpen': {}, 'engineRuntime': {}}}}
2022-12-23 22:56:55.140 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Old Vehicle Last Updated: 0001-01-01 00:00:00
2022-12-23 22:56:55.141 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - before 20221223231838
2022-12-23 22:56:55.141 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - last_updated_at - after 2022-12-23 23:18:38+00:00
2022-12-23 22:56:55.141 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Current Vehicle Last Updated: 2022-12-23 23:18:38+00:00
2022-12-23 22:56:55.467 WARNING (MainThread) [homeassistant.components.binary_sensor] Updating ping binary_sensor took longer than the scheduled update interval 0:00:00.500000
2022-12-23 22:56:55.595 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'msopServiceOdometer': 23114.0, 'msopServiceOdometerUnit': 1, 'mtspServiceDate': '20221204', 'imatServiceOdometer': 35114.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20230604', 'currentOdometer': 23451.8, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 12000.0, 'serviceDaysDuration': 181, 'serviceMonthsThreshold': 6}}}
2022-12-23 22:56:56.002 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'uqIxyfOzwkaSMjBUWpLBYFwhLqTAFkkP'}}
2022-12-23 22:56:56.397 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Vehicle Location {'error': {'errorCode': '6534', 'errorDesc': 'We are unable to process your current request as you have reached the daily limit of remote service requests.'}, 'responseHeader': {'responseCode': 1, 'responseDesc': 'Failure'}}
2022-12-23 22:56:56.397 WARNING (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get vehicle location failed
2022-12-23 22:56:56.786 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: list index out of range
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 93, in check_and_refresh_token
    self.initialize()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 55, in initialize
    self.update_all_vehicles_with_cached_state()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 62, in update_all_vehicles_with_cached_state
    self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 65, in update_vehicle_with_cached_state
    self.api.update_vehicle_with_cached_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 140, in update_vehicle_with_cached_state
    self._update_vehicle_properties_charge(vehicle, charge)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiCA.py", line 600, in _update_vehicle_properties_charge
    vehicle.ev_charge_limits_ac = [x['level'] for x in state if x['plugType'] == 1][-1]
IndexError: list index out of range
cdnninja commented 1 year ago

I just put a fix in that should help with this. Please update in HACS to the latest and let me know how it goes!

terrycalderbank commented 1 year ago

Awesome, looks like everything is working now. Thanks a bunch!

cdnninja commented 1 year ago

Great glad to hear it! The issue we are facing is probably still. The error was related to getting your target charge levels. So if interested still post data on this to see if we can sort this out.