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

Unexpected error fetching kia_uvo data: Server returned: 'No Data Found v2 - No Data Found v2' #514

Open alienato opened 1 year ago

alienato commented 1 year ago

hello, i've this error after updating module

Logger: custom_components.kia_uvo.coordinator Source: custom_components/kia_uvo/coordinator.py:158 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 19:54:52 (3 occurrences) Last logged: 19:55:22

Unexpected error fetching kia_uvo data: Server returned: 'No Data Found v2 - No Data Found v2' 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 101, in _async_update_data await self.async_check_and_refresh_token() File "/config/custom_components/kia_uvo/coordinator.py", line 158, 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 92, in check_and_refresh_token self.initialize() File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 54, in initialize self.update_all_vehicles_with_cached_state() File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, 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 64, 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/KiaUvoApiEU.py", line 232, in update_vehicle_with_cached_state state = self._get_cached_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 523, in _get_cached_vehicle_state _check_response_for_errors(response) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 73, in _check_response_for_errors raise APIError(f"Server returned: '{response['resMsg']}'") hyundai_kia_connect_api.exceptions.APIError: Server returned: 'No Data Found v2 - No Data Found v2'

cdnninja commented 1 year ago

Does it keep working and just have that error from time to time?

beniwohli commented 1 year ago

I get the same error. I tried multiple times to delete the integration and set it up again (with/without restarts of HA in between), always with the same error. This started to happen after updating from 1.8.5 to 2.0.45.

The error is permanent, no devices or entities are created.

cdnninja commented 1 year ago

Could you enable debug logs and post that?

alienato commented 1 year ago

logs found in /config/home-assistant.log

2022-12-20 15:52:28.144 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: Server returned: 'No Data Found v2 - No Data Found v2' 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 101, in _async_update_data await self.async_check_and_refresh_token() File "/config/custom_components/kia_uvo/coordinator.py", line 158, 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 92, in check_and_refresh_token self.initialize() File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 54, in initialize self.update_all_vehicles_with_cached_state() File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, 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 64, 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/KiaUvoApiEU.py", line 232, in update_vehicle_with_cached_state state = self._get_cached_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 523, in _get_cached_vehicle_state _check_response_for_errors(response) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 73, in _check_response_for_errors raise APIError(f"Server returned: '{response['resMsg']}'")

2022-12-20 15:52:59.131 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: Server returned: 'No Data Found v2 - No Data Found v2' 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 101, in _async_update_data await self.async_check_and_refresh_token() File "/config/custom_components/kia_uvo/coordinator.py", line 158, 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 92, in check_and_refresh_token self.initialize() File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 54, in initialize self.update_all_vehicles_with_cached_state() File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, 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 64, 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/KiaUvoApiEU.py", line 232, in update_vehicle_with_cached_state state = self._get_cached_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 523, in _get_cached_vehicle_state _check_response_for_errors(response) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 73, in _check_response_for_errors raise APIError(f"Server returned: '{response['resMsg']}'") hyundai_kia_connect_api.exceptions.APIError: Server returned: 'No Data Found v2 - No Data Found v2'

cdnninja commented 1 year ago

Is that with debug enabled for the api?

beniwohli commented 1 year ago

@cdnninja the debug logs contain all kinds of tokens, coordinates and other sensitive stuff, so I'm hesitant to post them here.

However, I might have an idea what happens here. I registered a total of 2 cars with bluelink. The first was in an accident, and I didn't have a chance to delete if from my profile (for some reason, deleting a car needs that car to be reachable). I asked bluelink support to delete it, which they kinda did. It still shows up in the vehicle selection in the bluelink app, clicking on it leads to errors. So I guess they still have some reference to the old car in their database.

Here's a redacted version of the debug logs:

2022-12-20 16:42:48.649 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - LoginFormSubmit 
2022-12-20 16:42:48.972 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Redirect User Id 
2022-12-20 16:42:49.304 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - silentsignin Response 
2022-12-20 16:42:49.304 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Access Token Data: 
2022-12-20 16:42:49.393 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Access Token Response: 
2022-12-20 16:42:49.393 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Access Token Value Bearer 
2022-12-20 16:42:49.393 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Refresh Token Data: 
2022-12-20 16:42:49.494 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Refresh Token Response: 
2022-12-20 16:42:49.632 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Vehicles Response: 
2022-12-20 16:42:49.633 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 
2022-12-20 16:42:49.765 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response: # Data from the new car
2022-12-20 16:42:49.766 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221218165616
2022-12-20 16:42:49.766 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-12-18 16:56:16+01:00
2022-12-20 16:42:49.766 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221218165616
2022-12-20 16:42:49.767 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-12-18 16:56:16+01:00
2022-12-20 16:42:49.767 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 
2022-12-20 16:42:50.053 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_driving_info 
2022-12-20 16:42:50.053 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 
2022-12-20 16:42:50.175 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_driving_info 
2022-12-20 16:42:50.177 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 
2022-12-20 16:42:50.403 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response: {'retCode': 'F', 'resCode': '5921', 'resMsg': 'No Data Found v2 - No Data Found v2', 'msgId': 'f601de43-3af2-449a-87a7-59a0618b5990'}
2022-12-20 16:42:50.404 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: Server returned: 'No Data Found v2 - No Data Found v2'

From what I can tell, it gets a list of vehicles. That list contains both my new and old Hyundai. It then fetches data for the first car, which succeeds. Then it fetches data for the second car, which fails.

Maybe the integration could ignore cars that return a "No Data Found v2" error message.

I'll also ask Bluelink support to delete the old car fully from my profile.

cdnninja commented 1 year ago

@beniwohli awesome! This is exactly what detail I needed. The new 2.X supports multiple cars which explains why we have this issue now. It wants to get data for all cars on the account where as the old one just looked at the first car in the list and ignored everything else.

I am going to think on this one. I see a few solutions:

  1. If that error code comes back don't throw an exception even though in general that is a catastrophic failure (not in this case since two cars)
  2. On setup start prompt to select the cars you want. I have heard this ask before.
cdnninja commented 1 year ago

@alienato for reference do you have two cars in your app as well with one erroring when clicked?

cdnninja commented 1 year ago

@beniwohli could we get your get_vehicles response? Feel free to pull any personal data. Trying to see if the car causing the issues has any flag it in showing it is offline or in that state. We could filter on that.

beniwohli commented 1 year ago

@cdnninja here you go

{
    "retCode": "S",
    "resCode": "0000",
    "resMsg": {
        "vehicles": [
            {
                "vin": "[REDACTED]",
                "vehicleId": "[REDACTED]",
                "vehicleName": "IONIQ 5",
                "type": "EV",
                "nickname": "IONIQ 5",
                "master": True,
                "carShare": 0,
                "regDate": "2022-08-23 15:29:05.110",
                "detailInfo": {
                    "inColor": "NNB",
                    "outColor": "W3T",
                    "saleCarmdlCd": "GI",
                    "bodyType": "2",
                    "saleCarmdlEnNm": "IONIQ 5"
                }
            },
            {
                "vin": "[REDACTED]",
                "vehicleId": "[REDACTED]",
                "vehicleName": "IONIQ 5",
                "type": "EV",
                "nickname": "IONIQ 5 Old",
                "master": True,
                "carShare": 0,
                "regDate": "2022-05-24 16:40:23.670",
                "detailInfo": {
                    "inColor": "NNB",
                    "outColor": "C5G",
                    "saleCarmdlCd": "GI",
                    "bodyType": "2",
                    "saleCarmdlEnNm": "IONIQ 5"
                }
            }
        ]
    },
    "msgId": "[REDACTED]"
}

From what I can see, there isn't any flag or other indication that could be used for filtering.

The nickname "IONIQ 5 Old" is set by me. I can still change it even though the car is offline. It might be an option to filter on that (e.g. document that any car that has the string "retired" in the nickname is filtered out. Not sure if that qualifies as great user experience, though...

cdnninja commented 1 year ago

Agreed that isn't ideal. As a starting point I made that error code not throw an exception so that may help. Could you download the new version as "master" in HACS and let me know if it allows setup to finish?

beniwohli commented 1 year ago

@cdnninja getting this with the master branch:

2022-12-22 18:43:48.198 ERROR (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - No Data Found, car may be offline
2022-12-22 18:43:48.201 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: string indices must be integers
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/KiaUvoApiEU.py", line 260, in update_vehicle_with_cached_state
    state = self._get_cached_vehicle_state(token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 552, in _get_cached_vehicle_state
    response = response["resMsg"]["vehicleStatusInfo"]
TypeError: string indices must be integers
alienato commented 1 year ago

@cdnninja getting this with the master branch:

2022-12-22 18:43:48.198 ERROR (SyncWorker_7) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - No Data Found, car may be offline
2022-12-22 18:43:48.201 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: string indices must be integers
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/KiaUvoApiEU.py", line 260, in update_vehicle_with_cached_state
    state = self._get_cached_vehicle_state(token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 552, in _get_cached_vehicle_state
    response = response["resMsg"]["vehicleStatusInfo"]
TypeError: string indices must be integers

same error for me

cdnninja commented 1 year ago

Do you have a second car listed in app that doesn't load as well?

alienato commented 1 year ago

Do you have a second car listed in app that doesn't load as well?

yes!

cdnninja commented 1 year ago

This will take me some time to sort out. I haven't forgot about it though.

beniwohli commented 1 year ago

I have since asked Bluelink support to remove the car completely from my account, which solved the issue for me.