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

Integration unavailable #424

Closed rindlerblabla closed 1 year ago

rindlerblabla commented 1 year ago

EU EV6 2.0.20

Describe the bug Lately my car tends to be unavailable several times a day. Reloading the integration solves the issue.

Debug logs if an error occurred

Logger: custom_components.kia_uvo.coordinator Source: custom_components/kia_uvo/coordinator.py:82 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 12:07:20 (5 occurrences) Last logged: 13:08:10

Unexpected error fetching kia_uvo data: string indices must be integers Unexpected error fetching kia_uvo data: 'vehicleStatusInfo' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/kia_uvo/coordinator.py", line 82, in _async_update_data 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 73, in check_and_force_update_vehicles self.force_refresh_vehicle_state(vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 83, in force_refresh_vehicle_state self.api.force_refresh_vehicle_state(self.token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state state = self._get_forced_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 416, in _get_forced_vehicle_state return response["resMsg"]["vehicleStatusInfo"] TypeError: string indices must be integers

cdnninja commented 1 year ago

@fuatakgun Are you able to look at this one? It seems to be the same issue as https://github.com/fuatakgun/kia_uvo/issues/285 we had awhile back. My guess is part of the fix wasn't ported to the API. Same item is reported here: https://github.com/fuatakgun/kia_uvo/issues/385#issuecomment-1304634501

rindlerblabla commented 1 year ago

Don't know why, but haven't noticed this today and the integration has been available the whole day.

cdnninja commented 1 year ago

Seems to be from time to time the API doesn't respond well. Our integration also really doesn't like it. I did add some exception handling a few releases ago that should just throw an error in into warnings but hard for me to test. It could simple be that.

holdestmade commented 1 year ago

Just tried 2.0.26, Failed to set up. Error messages below. 1.8.0 works fine and no errors.

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:92
Integration: Hyundai / Kia Connect ([documentation](https://github.com/fuatakgun/kia_uvo), [issues](https://github.com/fuatakgun/kia_uvo/issues))
First occurred: 8:26:02 AM (2 occurrences)
Last logged: 8:29:37 AM

Unexpected error fetching kia_uvo data: name 'UpdateFailed' is not defined
Traceback (most recent call last):
  File "/config/custom_components/kia_uvo/coordinator.py", line 86, in _async_update_data
    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 74, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 84, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state
    state = self._get_forced_vehicle_state(token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 420, in _get_forced_vehicle_state
    return response["resMsg"]["vehicleStatusInfo"]
TypeError: string indices must be integers

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/kia_uvo/coordinator.py", line 92, in _async_update_data
    UpdateFailed(f"Error communicating with API: {err}")
NameError: name 'UpdateFailed' is not defined
Logger: hyundai_kia_connect_api.KiaUvoApiEU
Source: /usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py:401
First occurred: 8:25:56 AM (2 occurrences)
Last logged: 8:29:37 AM

hyundai_kia_connect_api - _get_location failed
cdnninja commented 1 year ago

Just tried 2.0.26, Failed to set up. Error messages below. 1.8.0 works fine and no errors.

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:92
Integration: Hyundai / Kia Connect ([documentation](https://github.com/fuatakgun/kia_uvo), [issues](https://github.com/fuatakgun/kia_uvo/issues))
First occurred: 8:26:02 AM (2 occurrences)
Last logged: 8:29:37 AM

Unexpected error fetching kia_uvo data: name 'UpdateFailed' is not defined
Traceback (most recent call last):
  File "/config/custom_components/kia_uvo/coordinator.py", line 86, in _async_update_data
    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 74, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 84, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state
    state = self._get_forced_vehicle_state(token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 420, in _get_forced_vehicle_state
    return response["resMsg"]["vehicleStatusInfo"]
TypeError: string indices must be integers

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/kia_uvo/coordinator.py", line 92, in _async_update_data
    UpdateFailed(f"Error communicating with API: {err}")
NameError: name 'UpdateFailed' is not defined
Logger: hyundai_kia_connect_api.KiaUvoApiEU
Source: /usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py:401
First occurred: 8:25:56 AM (2 occurrences)
Last logged: 8:29:37 AM

hyundai_kia_connect_api - _get_location failed

Fixed this update failed error. It seems the API sometimes doesn't respond properly so trying to make it so home assistant retries at a later time.

cdnninja commented 1 year ago

Any more issues?

rindlerblabla commented 1 year ago

The integration has been unavailable most time last days. Obviously there'sanother error code now.

Logger: custom_components.kia_uvo.coordinator Source: custom_components/kia_uvo/coordinator.py:92 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 13 november 2022 02:16:09 (208 occurrences) Last logged: 06:52:26

Unexpected error fetching kia_uvo data: name 'UpdateFailed' is not defined Traceback (most recent call last): File "/config/custom_components/kia_uvo/coordinator.py", line 86, in _async_update_data 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 74, in check_and_force_update_vehicles self.force_refresh_vehicle_state(vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 84, in force_refresh_vehicle_state self.api.force_refresh_vehicle_state(self.token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state state = self._get_forced_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 420, in _get_forced_vehicle_state return response["resMsg"]["vehicleStatusInfo"] KeyError: 'vehicleStatusInfo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/kia_uvo/coordinator.py", line 92, in _async_update_data UpdateFailed(f"Error communicating with API: {err}") NameError: name 'UpdateFailed' is not defined

cdnninja commented 1 year ago

Which version? I think that error has been fixed somewhere along the way.

rindlerblabla commented 1 year ago

Okey, am on 2.0.24. Will update to latest and report back how it works.

holdestmade commented 1 year ago

Just updated to 2.0.29 still the same error and warning

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:102
Integration: Hyundai / Kia Connect ([documentation](https://github.com/fuatakgun/kia_uvo), [issues](https://github.com/fuatakgun/kia_uvo/issues))
First occurred: 2:41:02 PM (12 occurrences)
Last logged: 3:03:15 PM

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 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state
    state = self._get_forced_vehicle_state(token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 420, in _get_forced_vehicle_state
    return response["resMsg"]["vehicleStatusInfo"]
TypeError: string indices must be integers
Logger: hyundai_kia_connect_api.KiaUvoApiEU
Source: /usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py:401
First occurred: 2:41:01 PM (12 occurrences)
Last logged: 3:03:14 PM

hyundai_kia_connect_api - _get_location failed
cdnninja commented 1 year ago

Are you able to confirm your version? I don't think mi/km menu is back yet.

holdestmade commented 1 year ago

Are you able to confirm your version? I don't think mi/km menu is back yet.

Sorry forgot to restart after removing 1.8.0, see above

cdnninja commented 1 year ago

Could you enable debug logging as outlined at the bottom here: https://github.com/fuatakgun/kia_uvo/tree/v2.0

After that is done please post debug logs. In particular I am looking for the data following: "Received forced vehicle data"

https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/c9b82b741f48cdf2af703dc5b818aa1c2ff5ee5a/hyundai_kia_connect_api/KiaUvoApiEU.py#L419-L420

cdnninja commented 1 year ago

Could you please try v2.0.30 and let me know results? I expect an error or missing data but it will move it forward. This issue is triggered by a force update so a quick way to test is manually in developer services send a force update.

holdestmade commented 1 year ago

v2.0.31 installed ok now but, as you expected this error in log when doing a force_update. Do you still need my debug logs ?

Logger: homeassistant.core
Source: custom_components/kia_uvo/coordinator.py:120
Integration: Hyundai / Kia Connect ([documentation](https://github.com/fuatakgun/kia_uvo), [issues](https://github.com/fuatakgun/kia_uvo/issues))
First occurred: 9:51:23 AM (1 occurrences)
Last logged: 9:51:23 AM

Error executing service: <ServiceCall kia_uvo.force_update (c:XXXXXXXXXXXXXXXXXXXXXXXXXXXXX): device_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1762, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/kia_uvo/services.py", line 45, in async_handle_force_update
    await coordinator.async_force_update_all()
  File "/config/custom_components/kia_uvo/coordinator.py", line 120, in async_force_update_all
    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 84, in force_refresh_all_vehicles_states
    self.force_refresh_vehicle_state(self.get_vehicle(vehicle_id))
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 186, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment

Logger: hyundai_kia_connect_api.KiaUvoApiEU
Source: /usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py:402
First occurred: 9:51:23 AM (1 occurrences)
Last logged: 9:51:23 AM

hyundai_kia_connect_api - _get_location failed
cdnninja commented 1 year ago

Yes debug logs would help.

holdestmade commented 1 year ago

I'll enable debug logs later but on lock/unlock:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/kia_uvo/coordinator.py:138
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 8:35:33 AM (1 occurrences)
Last logged: 8:35:33 AM

[281472745204240] Object of type VEHICLE_LOCK_ACTION is not JSON serializable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/config/custom_components/kia_uvo/lock.py", line 54, in async_unlock
    await self.coordinator.async_unlock_vehicle(self.vehicle.id)
  File "/config/custom_components/kia_uvo/coordinator.py", line 138, in async_unlock_vehicle
    await self.hass.async_add_executor_job(self.vehicle_manager.unlock, vehicle_id)
  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 110, in unlock
    return self.api.lock_action(self.token, self.get_vehicle(vehicle_id), VEHICLE_LOCK_ACTION.UNLOCK)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 439, in lock_action
    response = requests.post(url, json=payload, headers=headers).json()
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request
    p.prepare(
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 371, in prepare
    self.prepare_body(data, files, json)
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 511, in prepare_body
    body = complexjson.dumps(json, allow_nan=False)
  File "/usr/local/lib/python3.10/site-packages/simplejson/__init__.py", line 412, in dumps
    **kw).encode(obj)
  File "/usr/local/lib/python3.10/site-packages/simplejson/encoder.py", line 296, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.10/site-packages/simplejson/encoder.py", line 378, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.10/site-packages/simplejson/encoder.py", line 272, in default
    raise TypeError('Object of type %s is not JSON serializable' %
TypeError: Object of type VEHICLE_LOCK_ACTION is not JSON serializable
holdestmade commented 1 year ago

Debug logs on startup

022-11-17 10:54:01.534 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 09:03:26.009000+00:00 120000 55 998 55.296043175
2022-11-17 10:54:02.009 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Device ID request {'ccsp-service-id': 'xxxxxxxxxxxx', 'ccsp-application-id': 'xxxxxxxxxxxx', 'Stamp': 'xxxxxxxxxxxxxxxx', 'Content-Type': 'application/json;charset=UTF-8', 'Host': 'prd.eu-ccapi.kia.com:8080', 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip', 'User-Agent': 'okhttp/3.12.0'} {'pushRegId': 1, 'pushType': 'GCM', 'uuid': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:54:02.010 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Device ID response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'deviceId': 'xxxxxxxxxxxxxxxxxxx'}, 'msgId': 'xxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:54:02.010 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get cookies request https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=xxxxxxxxxxxxxx&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect&lang=en
2022-11-17 10:54:02.242 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get cookies response {'xxxxxxxxxxxx': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'account': 'xxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:54:02.723 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Sign In Response {'redirectUrl': 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&state=test', 'popup': False, 'method': '', 'upgrade': False, 'integrated': False, 'deleteAccountLink': ''}
2022-11-17 10:54:02.723 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Access Token Data {'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==', 'Stamp': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Content-type': 'application/x-www-form-urlencoded', 'Host': 'prd.eu-ccapi.kia.com:8080', 'Connection': 'close', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'okhttp/3.12.0'}grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv1%2Fuser%2Foauth2%2Fredirect&code=xxxxxxxxxxxxxxxxxxx
2022-11-17 10:54:02.896 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Access Token Response {'access_token': 'xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxx-xxxxxxxxxx-xxxxxx-xxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx', 'token_type': 'Bearer', 'refresh_token': 'xxxxxxxxxxxxx-xxx', 'expires_in': 86400}
2022-11-17 10:54:02.896 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Access Token Value Bearer xxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2022-11-17 10:54:02.896 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Refresh Token Data grant_type=refresh_token&redirect_uri=https%3A%2F%2Fwww.getpostman.com%2Foauth2%2Fcallback&refresh_token=xxxxxxxxxxxxxxxxxxxxxxx-xxx
2022-11-17 10:54:03.078 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Refresh Token Response {'access_token': 'xxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx--xxxxxxxxxxxxxxxxxxx', 'token_type': 'Bearer', 'expires_in': 86400}
2022-11-17 10:54:03.078 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 09:03:26.009000+00:00 120000 55 998 55.xxxxxxxxxxxxxxxxxx
2022-11-17 10:54:04.122 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Vehicles Response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'vehicles': [{'vin': 'xxxxxxxxxxxxxxxx', 'vehicleId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxx', 'vehicleName': 'CEED (NEW) 18/21', 'type': 'GN', 'nickname': 'PROCEED', 'master': True, 'carShare': 0, 'regDate': '2020-09-08 08:55:59.193', 'detailInfo': {'inColor': 'WK', 'outColor': 'H8G', 'saleCarmdlCd': 'J7', 'bodyType': '1', 'saleCarmdlEnNm': 'ProCeed'}}]}, 'msgId': 'xxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:54:04.122 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 09:03:26.009000+00:00 120000 55 998 55.xxxxxxxxxxxxxxxxxx
2022-11-17 10:54:04.324 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxxxxxxxxx, 'lon': -0.xxxxxxxxxxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221113211733'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 84, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 64, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221117071426', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '65:02:49'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': 14566.3, 'unit': 1}}
2022-11-17 10:54:04.325 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 09:03:26.009000+00:00 120000 55 998 55.xxxxxxxxxxxxxxxxxx
2022-11-17 10:55:59.551 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4081', 'resMsg': 'Request timeout. - Request timeout.', 'msgId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:55:59.552 WARNING (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-17 10:55:59.559 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117071426
2022-11-17 10:55:59.560 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 07:14:26+01:00
2022-11-17 10:55:59.561 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-17 10:55:59.564 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.VehicleManager] time diff - 16893.564329
2022-11-17 10:55:59.565 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 09:03:26.009000+00:00 120000 56 998 56.279637725
2022-11-17 10:55:59.742 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:55:59.742 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 09:03:26.009000+00:00 120000 56 998 56.281115275000005
2022-11-17 10:55:59.950 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 10:55:59.950 WARNING (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-17 10:55:59.952 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'str' object does not support item assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 186, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment
2022-11-17 10:55:59.958 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 118.485 seconds (success: False)
cdnninja commented 1 year ago

Thank you for the logs! It looks like we are fighting multiple issues. Caused by different reasons. I have released v2.0.32 with a few tweaks that I am hoping will get us past some of the above errors.

Some of seems to be a force refresh failing. Could you let me know the behavior of the integration in this next round? Interested to here if it recovers on its own or not.

holdestmade commented 1 year ago

2.0.32, won't start. In the Integration page it is stuck on Initialising for a minute or so and then says

Retrying setup: Config Not Ready: 'str' object does not support item assignment

Start up logs

2022-11-17 16:29:49.623 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 103 998 103.54544685
2022-11-17 16:29:49.787 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Vehicles Response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'vehicles': [{'vin': 'xxxxxxxxxxxxx', 'vehicleId': 'xxxxxxxxxxxxxxxxxxx', 'vehicleName': 'CEED (NEW) 18/21', 'type': 'GN', 'nickname': 'PROCEED', 'master': True, 'carShare': 0, 'regDate': '2020-09-08 08:55:59.193', 'detailInfo': {'inColor': 'WK', 'outColor': 'H8G', 'saleCarmdlCd': 'J7', 'bodyType': '1', 'saleCarmdlEnNm': 'ProCeed'}}]}, 'msgId': 'xxxxxxxxxxxxxxxxxxxx'}
2022-11-17 16:29:49.788 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 103 998 103.54682098333333
2022-11-17 16:29:49.991 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221113211733'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 84, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 64, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221117124217', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '70:30:42'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': -1, 'unit': 1}}
2022-11-17 16:29:49.992 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117124217
2022-11-17 16:29:49.992 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 12:42:17+01:00
2022-11-17 16:29:49.993 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-17 16:29:49.993 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221113211733
2022-11-17 16:29:49.993 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-13 21:17:33+01:00
2022-11-17 16:29:49.997 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.VehicleManager] time diff - 17252.996965
2022-11-17 16:29:49.997 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 103 998 103.54856439166667

This repeats every 2 minutes (token parts not included)

2022-11-17 16:42:39.950 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 109 998 109.9648357
2022-11-17 16:42:40.142 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Vehicles Response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'vehicles': [{'vin': 'xxxxxxxxxxxxxx', 'vehicleId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'vehicleName': 'CEED (NEW) 18/21', 'type': 'GN', 'nickname': 'PROCEED', 'master': True, 'carShare': 0, 'regDate': '2020-09-08 08:55:59.193', 'detailInfo': {'inColor': 'WK', 'outColor': 'H8G', 'saleCarmdlCd': 'J7', 'bodyType': '1', 'saleCarmdlEnNm': 'ProCeed'}}]}, 'msgId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}
2022-11-17 16:42:40.144 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 109 998 109.966449625
2022-11-17 16:42:40.332 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221113211733'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 84, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 64, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221117124217', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '70:30:42'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': -1, 'unit': 1}}
2022-11-17 16:42:40.333 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117124217
2022-11-17 16:42:40.333 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 12:42:17+01:00
2022-11-17 16:42:40.333 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-17 16:42:40.334 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221113211733
2022-11-17 16:42:40.334 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-13 21:17:33+01:00
2022-11-17 16:42:40.337 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.VehicleManager] time diff - 18023.337587
2022-11-17 16:42:40.338 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 109 998 109.968068275
2022-11-17 16:44:35.481 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'F', 'resCode': '4081', 'resMsg': 'Request timeout. - Request timeout.', 'msgId': '5d81704c-6a91-43ce-bbf5-daa026a219bf'}
2022-11-17 16:44:35.481 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 110 998 110.92759958333333
2022-11-17 16:44:35.709 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': '94be2252-85fb-4aa0-8054-9725e899b57e'}
2022-11-17 16:44:35.709 WARNING (SyncWorker_6) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-17 16:44:35.714 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'str' object does not support item assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 186, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment
2022-11-17 16:44:35.717 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 116.938 seconds (success: False)
cdnninja commented 1 year ago

It looks like the get location and force refresh always fails for you with 'Request timeout. - Request timeout.'

Yet that wasn't reported by @rindlerblabla. Does force refresh and force update location work for you in the mobile app? I am wondering if it can't contact your car.

Whats happening for you:

  1. Force update fails so the variable isn't setup correctly.
  2. Location fails and can't add to the variable because it wasn't setup due to the last call also failing.

I can make it so the variable is setup in advance but it would then refresh with blank data as both calls fail anyway. It may allow the setup to finish but no sensors would report until a cached data corrects it.

I am trying to gauge if this is a Kia/Hyundai API issue or not. Seems it isn't impacting everyone.

holdestmade commented 1 year ago

About 45 minutes later, it seems to be working now:

2022-11-17 17:29:30.031 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] time diff - 1803.030815
2022-11-17 17:29:30.032 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 133 998 133.38218470833334
2022-11-17 17:29:30.641 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221117175929'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': False, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 70, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 60, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221117175927', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '01:36:32'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': -1, 'unit': 1}}
2022-11-17 17:29:30.641 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117175927
2022-11-17 17:29:30.642 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 17:59:27+01:00
2022-11-17 17:29:30.644 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-17 17:29:30.644 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117175929
2022-11-17 17:29:30.645 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 17:59:29+01:00
2022-11-17 17:29:30.646 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.632 seconds (success: True)
2022-11-17 17:59:30.004 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.VehicleManager] time diff - 3603.003935
2022-11-17 17:59:30.004 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 13:02:44.170000+00:00 120000 148 998 148.38195589166668
2022-11-17 17:59:30.596 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221117175929'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': False, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 70, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 60, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221117175927', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '01:36:32'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': 14645.2, 'unit': 1}}
2022-11-17 17:59:30.596 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117175927
2022-11-17 17:59:30.596 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 17:59:27+01:00
2022-11-17 17:59:30.597 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-17 17:59:30.597 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117175929
2022-11-17 17:59:30.597 DEBUG (SyncWorker_26) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 17:59:29+01:00
2022-11-17 17:59:30.599 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.597 seconds (success: True)
holdestmade commented 1 year ago

It looks like the get location and force refresh always fails for you with 'Request timeout. - Request timeout.'

Yet that wasn't reported by @rindlerblabla. Does force refresh and force update location work for you in the mobile app? I am wondering if it can't contact your car.

Whats happening for you:

  1. Force update fails so the variable isn't setup correctly.
  2. Location fails and can't add to the variable because it wasn't setup due to the last call also failing.

I can make it so the variable is setup in advance but it would then refresh with blank data as both calls fail anyway. It may allow the setup to finish but no sensors would report until a cached data corrects it.

I am trying to gauge if this is a Kia/Hyundai API issue or not. Seems it isn't impacting everyone.

It's odd because it works fine in 1.8.0 with no errors

rindlerblabla commented 1 year ago

Sorry missed that I should wait and see if it recovers on its own, hehe. Gotta charge the car though, will get back to you after that, since I need an available integration while doing it.

cdnninja commented 1 year ago

With 2.0.32:

2022-11-17 19:35:36.676 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 17:04:00.698000+00:00 120000 45 998 45.799818908333336
2022-11-17 19:35:52.056 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'S', 'resCode': '0000', 'resMsg': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '02H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'acc': False, 'evStatus': {'batteryCharge': False, 'batteryStatus': 29, 'batteryPlugin': 0, 'remainTime2': {'etc1': {'value': 33, 'unit': 1}, 'etc2': {'value': 600, 'unit': 1}, 'etc3': {'value': 135, 'unit': 1}, 'atc': {'value': 600, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'evModeRange': {'value': 121, 'unit': 1}, 'totalAvailableRange': {'value': 121, 'unit': 1}}, 'type': 2}], 'reservChargeInfos': {'reservChargeInfo': {'reservChargeInfoDetail': {'reservInfo': {'day': [9], 'time': {'time': '1200', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'airCtrl': 0, 'heating1': 0}}}, 'offpeakPowerInfo': {'offPeakPowerTime1': {'starttime': {'time': '1200', 'timeSection': 0}, 'endtime': {'time': '1200', 'timeSection': 0}}, 'offPeakPowerFlag': 0}, 'reserveChargeInfo2': {'reservChargeInfoDetail': {'reservInfo': {'day': [9], 'time': {'time': '1200', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'airCtrl': 0, 'heating1': 0}}}, 'reservFlag': 0, 'ect': {'start': {'day': 0, 'time': {'time': '0000', 'timeSection': 0}}, 'end': {'day': 0, 'time': {'time': '0000', 'timeSection': 0}}}, 'targetSOClist': [{'targetSOClevel': 80, 'dte': {'rangeByFuel': {'evModeRange': {'value': 369, 'unit': 1}, 'totalAvailableRange': {'value': 369, 'unit': 1}}, 'type': 2}, 'plugType': 0}, {'targetSOClevel': 60, 'dte': {'rangeByFuel': {'evModeRange': {'value': 269, 'unit': 1}, 'totalAvailableRange': {'value': 269, 'unit': 1}}, 'type': 2}, 'plugType': 1}]}, 'chargePortDoorOpenStatus': 2, 'batteryPreconditioning': False}, 'ign3': False, 'hoodOpen': False, 'transCond': False, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 88, 'batState': 0, 'sjbDeliveryMode': 0, 'batSignalReferenceValue': {'batWarning': 0}, 'powerAutoCutMode': 2}, 'lampWireStatus': {'stopLamp': {'stopLampStatus': False, 'leftLamp': False, 'rightLamp': False}, 'headLamp': {'headLampStatus': False, 'leftLowLamp': False, 'rightLowLamp': False, 'leftHighLamp': False, 'rightHighLamp': False, 'leftBifuncLamp': False, 'rightBifuncLamp': False}, 'turnSignalLamp': {'turnSignalLampStatus': False, 'leftFrontLamp': False, 'rightFrontLamp': False, 'leftRearLamp': False, 'rightRearLamp': False}}, 'windowOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'smartKeyBatteryWarning': False, 'washerFluidStatus': False, 'breakOilStatus': False, 'sleepModeCheck': False, 'time': '20221117193551', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '00:39:27'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'msgId': 'd50c47b1-27bb-464e-ab52-4c3f177c2eec'}
2022-11-17 19:35:52.056 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-17 17:04:00.698000+00:00 120000 45 998 45.927990691666665
2022-11-17 19:35:54.414 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'gpsDetail': {'coord': {'lat': 59.252803, 'lon': 15.231675, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221117183552'}, 'drvDistance': {'rangeByFuel': {'evModeRange': {'value': 121, 'unit': 1}, 'totalAvailableRange': {'value': 121, 'unit': 1}}, 'type': 2}}, 'msgId': '826c772c-775d-49e4-bb70-53d59ce32873'}
2022-11-17 19:35:54.415 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-17 19:35:54.415 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221117183552
2022-11-17 19:35:54.415 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-17 18:35:52+01:00
2022-11-17 19:35:54.421 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'
File "/config/custom_components/kia_uvo/coordinator.py", line 102, in _async_update_data
2022-11-17 19:35:54.491 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.071 seconds (success: False)

Thats a legit error I am working to fix. Force update doesn't give a timestamp for the update like a cached call does so I am trying to populate it with the current time to stop this.

cdnninja commented 1 year ago

It looks like the get location and force refresh always fails for you with 'Request timeout. - Request timeout.' Yet that wasn't reported by @rindlerblabla. Does force refresh and force update location work for you in the mobile app? I am wondering if it can't contact your car. Whats happening for you:

  1. Force update fails so the variable isn't setup correctly.
  2. Location fails and can't add to the variable because it wasn't setup due to the last call also failing.

I can make it so the variable is setup in advance but it would then refresh with blank data as both calls fail anyway. It may allow the setup to finish but no sensors would report until a cached data corrects it. I am trying to gauge if this is a Kia/Hyundai API issue or not. Seems it isn't impacting everyone.

It's odd because it works fine in 1.8.0 with no errors

Very odd. So something specific to your account / config is conflicting with 2.x where as the calls work for @rindlerblabla just with some mistakes on our side.

holdestmade commented 1 year ago

I opened the Kia app to check and for some reason was logged out. Logged back in and works ok but force update does not so looks like an issue on my end. Would be good if this integration could catch the error though.

cdnninja commented 1 year ago

Yes we need to manage the error better. From a user standpoint does the integration stay running? And what do the sensors do? Warnings or errors in the home assistant logs would be normal as an error did occur.

holdestmade commented 1 year ago

Yes once it's going it seems to keep going. Sensors all seem correct. On HA restart, this integration takes about 2 minutes to start, shown by the notification in the bottom left when starting up. But that's the same in 1.8.0.

cdnninja commented 1 year ago

Do you see any spots where it has a full stack trace? The first error you showed doesn't seem to have the trace of saying why it failed just a line number of where it failed.

rindlerblabla commented 1 year ago

I was on latest when that error occurred, however now there's a newer one. Will install it and see if that error is still there.

holdestmade commented 1 year ago

Looks like I'm getting only a few fails now. This is the only one in the past 24hrs. I've copied some of the log either side so you can see it working before and after every 30 mins

2022-11-21 04:22:41.001 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.VehicleManager] time diff - 12603.001768
2022-11-21 04:22:41.002 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-20 09:03:27.349000+00:00 120000 579 998 579.6137793
2022-11-21 04:22:41.451 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221119203156'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 47, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 59, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221121015238', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '31:25:30'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': 14666.9, 'unit': 1}}
2022-11-21 04:22:41.452 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221121015238
2022-11-21 04:22:41.452 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-21 01:52:38+01:00
2022-11-21 04:22:41.452 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-21 04:22:41.453 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221119203156
2022-11-21 04:22:41.453 DEBUG (SyncWorker_52) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-19 20:31:56+01:00
2022-11-21 04:22:41.455 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.455 seconds (success: True)
2022-11-21 04:52:41.001 DEBUG (SyncWorker_45) [hyundai_kia_connect_api.VehicleManager] time diff - 14403.001265
2022-11-21 04:52:41.002 DEBUG (SyncWorker_45) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-20 09:03:27.349000+00:00 120000 594 998 594.6137758583334
2022-11-21 04:54:36.146 DEBUG (SyncWorker_45) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'F', 'resCode': '4081', 'resMsg': 'Request timeout. - Request timeout.', 'msgId': 'a8e15cad-6d23-4e01-ba05-5e3af848e016'}
2022-11-21 04:54:36.146 DEBUG (SyncWorker_45) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-20 09:03:27.349000+00:00 120000 595 998 595.5733131916667
2022-11-21 04:54:36.640 DEBUG (SyncWorker_45) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': 'c173e11e-c9b4-43cd-bc00-02570208d35e'}
2022-11-21 04:54:36.641 WARNING (SyncWorker_45) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-21 04:54:36.644 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'str' object does not support item assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 186, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment
2022-11-21 04:54:36.646 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 115.646 seconds (success: False)
2022-11-21 05:24:36.001 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.VehicleManager] time diff - 16318.001037
2022-11-21 05:24:36.001 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-20 09:03:27.349000+00:00 120000 610 998 610.5721071666667
2022-11-21 05:24:48.447 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'S', 'resCode': '0000', 'resMsg': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': False, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 47, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 59, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221121062448', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '35:57:40'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'msgId': 'c8054ada-d38d-4078-a40b-0daa5b6df679'}
2022-11-21 05:24:48.448 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-20 09:03:27.349000+00:00 120000 610 998 610.6758290083333
2022-11-21 05:24:50.542 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '5031', 'resMsg': 'Unavailable remote control - Service Temporary Unavailable', 'msgId': '5572a67c-d647-4953-b8a8-5980a00c1c00'}
2022-11-21 05:24:50.542 WARNING (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-21 05:24:50.544 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-21 05:24:50.545 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-20 09:03:27.349000+00:00 120000 610 998 610.6933032666667
2022-11-21 05:24:50.737 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221119203156'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': False, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 47, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 59, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221121062448', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '35:57:40'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': 14666.9, 'unit': 1}}
2022-11-21 05:24:50.738 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221121062448
2022-11-21 05:24:50.738 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-21 06:24:48+01:00
2022-11-21 05:24:50.753 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-21 05:24:50.753 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221119203156
2022-11-21 05:24:50.754 DEBUG (SyncWorker_39) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-19 20:31:56+01:00
2022-11-21 05:24:50.756 INFO (MainThread) [custom_components.kia_uvo.coordinator] Fetching kia_uvo data recovered
2022-11-21 05:24:50.756 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 14.756 seconds (success: True)
holdestmade commented 1 year ago

This is in the log when trying to lock:

2022-11-21 17:07:16.625 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 13:04:29.698000+00:00 120000 121 998 121.391057825
2022-11-21 17:07:16.625 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Lock Action Request {'action': <VEHICLE_LOCK_ACTION.LOCK: 'close'>, 'deviceId': '1ed44050-ba30-44d9-bb09-7e51086fdab7'}
2022-11-21 17:07:16.630 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Object of type VEHICLE_LOCK_ACTION is not JSON serializable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/config/custom_components/kia_uvo/lock.py", line 51, in async_lock
    await self.coordinator.async_lock_vehicle(self.vehicle.id)
  File "/config/custom_components/kia_uvo/coordinator.py", line 133, in async_lock_vehicle
    await self.hass.async_add_executor_job(self.vehicle_manager.lock, vehicle_id)
  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 107, in lock
    return self.api.lock_action(self.token, self.get_vehicle(vehicle_id), VEHICLE_LOCK_ACTION.LOCK)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 436, in lock_action
    response = requests.post(url, json=payload, headers=headers)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 573, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 484, in prepare_request
    p.prepare(
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 371, in prepare
    self.prepare_body(data, files, json)
  File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 511, in prepare_body
    body = complexjson.dumps(json, allow_nan=False)
  File "/usr/local/lib/python3.10/site-packages/simplejson/__init__.py", line 412, in dumps
    **kw).encode(obj)
  File "/usr/local/lib/python3.10/site-packages/simplejson/encoder.py", line 296, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.10/site-packages/simplejson/encoder.py", line 378, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.10/site-packages/simplejson/encoder.py", line 272, in default
    raise TypeError('Object of type %s is not JSON serializable' %
TypeError: Object of type VEHICLE_LOCK_ACTION is not JSON serializable

EDIT: After update to 2.0.33

2022-11-21 17:30:33.094 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 13 998 13.5217978
2022-11-21 17:30:33.095 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Lock Action Request {'action': 'close', 'deviceId': '0e21aaa2-d7fb-401a-b90e-bc384bb81019'}
2022-11-21 17:30:33.645 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Lock Action Response <Response [200]>
holdestmade commented 1 year ago

Was going to try a force update service but can't find it, has it been removed ?

EDIT:

It seems to be there now and running a forced update had these errors (on v2.0.23)

2022-11-21 17:25:22.449 DEBUG (SyncWorker_18) [hyundai_kia_connect_api.VehicleManager] time diff - 14401.449257
2022-11-21 17:25:22.450 DEBUG (SyncWorker_18) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 10 998 10.93309175
2022-11-21 17:25:22.657 DEBUG (SyncWorker_18) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': 'f23144ef-9590-4e11-b8c1-c57fc74cc1c9'}
2022-11-21 17:25:22.658 DEBUG (SyncWorker_18) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 10 998 10.934825891666666
2022-11-21 17:25:22.888 DEBUG (SyncWorker_18) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': 'dd492acf-76f9-44ee-bb2b-3e1e8927b8e9'}
2022-11-21 17:25:22.888 WARNING (SyncWorker_18) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-21 17:25:22.895 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'str' object does not support item assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 187, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment
2022-11-21 17:25:22.900 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.455 seconds (success: False)
zulufoxtrot commented 1 year ago

I see several problems here:

rindlerblabla commented 1 year ago

With 2.0.33 I don't get any error when force updating. At least not the three times I have tried so far.

holdestmade commented 1 year ago

At 21:49 last night (force update) it fails:

2022-11-21 21:49:24.001 DEBUG (SyncWorker_25) [hyundai_kia_connect_api.VehicleManager] time diff - 15297.001538
2022-11-21 21:49:24.003 DEBUG (SyncWorker_25) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 142 998 142.94603309166664
2022-11-21 21:51:19.151 DEBUG (SyncWorker_25) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'F', 'resCode': '4081', 'resMsg': 'Request timeout. - Request timeout.', 'msgId': 'be79a768-0cc8-4353-bcfc-b58439c49acc'}
2022-11-21 21:51:19.152 DEBUG (SyncWorker_25) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 143 998 143.9056090916667
2022-11-21 21:51:19.387 DEBUG (SyncWorker_25) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': '4c8dec42-a479-4883-a442-9f611b525586'}
2022-11-21 21:51:19.387 WARNING (SyncWorker_25) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-21 21:51:19.390 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'str' object does not support item assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 187, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment
2022-11-21 21:51:19.392 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 115.392 seconds (success: False)

But at 03:25 (240 minutes later) it worked, kind of, Remote Control error and location failed. This may be KIA though as my APP doesn't work sometimes either:

2022-11-22 03:25:22.001 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.VehicleManager] time diff - 14403.001346
2022-11-22 03:25:22.002 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 310 998 310.9293589583333
2022-11-22 03:25:34.100 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'S', 'resCode': '0000', 'resMsg': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 47, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 59, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221122042534', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '57:58:26'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'msgId': 'ddb302cb-0370-4a81-bc04-ecc1fb0682c7'}
2022-11-22 03:25:34.101 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 311 998 311.03018784999995
2022-11-22 03:25:36.315 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '5031', 'resMsg': 'Unavailable remote control - Service Temporary Unavailable', 'msgId': '9b0e9d70-cc39-406e-abe4-745007d1a29e'}
2022-11-22 03:25:36.315 WARNING (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-22 03:25:36.317 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-22 03:25:36.318 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 17:03:30.479000+00:00 120000 311 998 311.0486612166667
2022-11-22 03:25:36.507 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxx, 'lon': -0.xxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221119203156'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 47, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 59, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221122042534', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '57:58:26'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': 14666.9, 'unit': 1}}
2022-11-22 03:25:36.507 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221122042534
2022-11-22 03:25:36.508 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-22 04:25:34+01:00
2022-11-22 03:25:36.511 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-22 03:25:36.511 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221119203156
2022-11-22 03:25:36.511 DEBUG (SyncWorker_22) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-19 20:31:56+01:00
2022-11-22 03:25:36.514 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 14.514 seconds (success: True)
cdnninja commented 1 year ago

Someone found a mistake in the code that may have impacted this. https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/issues/140

The latest version .35 fixes this.

rindlerblabla commented 1 year ago

Great! Then maybe this log from .34 is unnecessary. This not a force update using the service, but the wake up thing from the integration itself.

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:102
Integration: Kia Uvo / Hyundai Bluelink ([documentation](https://github.com/fuatakgun/kia_uvo), [issues](https://github.com/fuatakgun/kia_uvo/issues))
First occurred: 16:15:03 (5 occurrences)
Last logged: 17:15:20

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 205, 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.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 80, in c2022-11-22 16:15:03.002 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 13:04:29.698000+00:00 120000 785 998 785.2775352416667
2022-11-22 16:15:03.340 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: string indices must be integers
File "/config/custom_components/kia_uvo/coordinator.py", line 102, in _async_update_data
File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 182, in update_vehicle_with_cached_state
File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 377, in _get_cached_vehicle_state
2022-11-22 16:15:03.414 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.414 seconds (success: False)heck_and_force_update_ve
    self.update_vehicle_with_cached_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 63, 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 182, 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 377, in _get_cached_vehicle_state
    response = response["resMsg"]["vehicleStatusInfo"]
TypeError: string indices must be integers
2022-11-22 16:15:03.002 DEBUG (SyncWorker_8) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-21 13:04:29.698000+00:00 120000 785 998 785.2775352416667
2022-11-22 16:15:03.340 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: string indices must be integers
File "/config/custom_components/kia_uvo/coordinator.py", line 102, in _async_update_data
File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 182, in update_vehicle_with_cached_state
File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 377, in _get_cached_vehicle_state
2022-11-22 16:15:03.414 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.414 seconds (success: False)
holdestmade commented 1 year ago

This looks very hopeful, well spotted @zulufoxtrot

I tried 2.0.35 but the integration fails to setup and the integration is saying "retrying setup" every 10 seconds or so. This is showing in the logs as a complete login (with all the token lines) and it fails with duplicate request. I've removed the integration and I'll leave it for a bit to get rid of all the requests, I assume the KIA server is rejecting them as so many in short space of time.

rindlerblabla commented 1 year ago

I had no issues updating to .35 and force updating worked just fine (which it also did in .33). Will see how the automatic update works.

holdestmade commented 1 year ago

So uninstalled from HACS and removed the integration and started fresh with 2.0.35.

Only have one car

The integration is constantly at Initializingand Retrying setup: Config Not Ready: 'str' object does not support item assignment

The logs constantly repeating:

2022-11-23 10:19:22.209 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-23 09:02:59.887000+00:00 120000 38 998 38.18601771666667
2022-11-23 10:19:22.350 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Device ID request {'ccsp-service-id': 'xxxxxx-xxxx-xxxx-xxxx-xxxxx', 'ccsp-application-id': 'xxxxx-xxxx-xxxx-xxx-xxxxx', 'Stamp': 'xxxx/xxxx/g0/xxxxxx=', 'Content-Type': 'application/json;charset=UTF-8', 'Host': 'prd.eu-ccapi.kia.com:8080', 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip', 'User-Agent': 'okhttp/3.12.0'} {'pushRegId': 1, 'pushType': 'GCM', 'uuid': 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx'}
2022-11-23 10:19:22.350 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Device ID response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'deviceId': 'xxxxx-xxxx-xxxx-xxxx-xxxxxx'}, 'msgId': '69ea6f52-106c-4f80-8929-9201261f0351'}
2022-11-23 10:19:22.350 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get cookies request https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=xxxxxxxxx-xxxx-xxxx-xxxx-xxxx&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect&lang=en
2022-11-23 10:19:22.771 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get cookies response {'xxxxxxxxxxxxx': 'xxxxxxxxxxxxxx', 'account': 'xxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxx'}
2022-11-23 10:19:23.189 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Sign In Response {'redirectUrl': 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect?code=-xxxxxxxx-xxxxxxxxxx&state=test', 'popup': False, 'method': '', 'upgrade': False, 'integrated': False, 'deleteAccountLink': ''}
2022-11-23 10:19:23.189 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Access Token Data {'Authorization': 'Basic xxxxxxxxxx==', 'Stamp': 'xxxxxxxxxxxxxx/xxxxxxxxxxxxxxx/g0/xxxxxxxxxxxxx=', 'Content-type': 'application/x-www-form-urlencoded', 'Host': 'prd.eu-ccapi.kia.com:8080', 'Connection': 'close', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'okhttp/3.12.0'}grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv1%2Fuser%2Foauth2%2Fredirect&code=-xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxx
2022-11-23 10:19:23.325 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Access Token Response {'access_token': 'xxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxx', 'token_type': 'Bearer', 'refresh_token': 'R_xxxxxxxxxxxxxxxx', 'expires_in': 86400}
2022-11-23 10:19:23.325 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Access Token Value Bearer xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2022-11-23 10:19:23.325 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Refresh Token Data grant_type=refresh_token&redirect_uri=https%3A%2F%2Fwww.getpostman.com%2Foauth2%2Fcallback&refresh_token=R_xxxxxxxxxxxxxxxxxxxxxx
2022-11-23 10:19:23.487 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Refresh Token Response {'access_token': 'xxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxx', 'token_type': 'Bearer', 'expires_in': 86400}
2022-11-23 10:19:23.487 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-23 09:02:59.887000+00:00 120000 38 998 38.19667401666666
2022-11-23 10:19:23.636 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Get Vehicles Response {'retCode': 'S', 'resCode': '0000', 'resMsg': {'vehicles': [{'vin': 'xxxxxxxxxxxxxxxxxx', 'vehicleId': 'xxxxxxxxxxxxxxxx-xxxxxxxxx-xxxxxxxxxxxx-xxxx-xxxxxxxxxx', 'vehicleName': 'CEED (NEW) 18/21', 'type': 'GN', 'nickname': 'PROCEED', 'master': True, 'carShare': 0, 'regDate': '2020-09-08 08:55:59.193', 'detailInfo': {'inColor': 'WK', 'outColor': 'H8G', 'saleCarmdlCd': 'J7', 'bodyType': '1', 'saleCarmdlEnNm': 'ProCeed'}}]}, 'msgId': 'b778ede7-ba7d-4fb6-b049-c4338b48d277'}
2022-11-23 10:19:23.636 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-23 09:02:59.887000+00:00 120000 38 998 38.197913758333335
2022-11-23 10:19:23.801 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_cached_vehicle_status response {'vehicleLocation': {'coord': {'lat': 53.xxxxxx, 'lon': -0.xxxxxxx, 'alt': 0, 'type': 0}, 'head': 0, 'speed': {'value': 0, 'unit': 0}, 'accuracy': {'hdop': 0, 'pdop': 0}, 'time': '20221119203156'}, 'vehicleStatus': {'airCtrlOn': False, 'engine': False, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTemp': {'value': '00H', 'unit': 0, 'hvacTempType': 1}, 'defrost': False, 'lowFuelLight': False, 'acc': False, 'hoodOpen': False, 'transCond': False, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'dte': {'value': 47, 'unit': 3}, 'tirePressureLamp': {'tirePressureLampAll': 0, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 59, 'batState': 0}, 'sleepModeCheck': False, 'time': '20221122125545', 'remoteWaitingTimeAlert': {'remoteControlAvailable': 1, 'remoteControlWaitingTime': 168, 'elapsedTime': '66:28:38'}, 'systemCutOffAlert': 0, 'tailLampStatus': 0, 'hazardStatus': 0}, 'odometer': {'value': 14666.9, 'unit': 1}}
2022-11-23 10:19:23.802 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221122125545
2022-11-23 10:19:23.802 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-22 12:55:45+01:00
2022-11-23 10:19:23.802 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - SOC Levels couldn't be found. May not be an EV.
2022-11-23 10:19:23.802 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - before 20221119203156
2022-11-23 10:19:23.803 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - last_updated_at - after 2022-11-19 20:31:56+01:00
2022-11-23 10:19:23.804 DEBUG (SyncWorker_13) [hyundai_kia_connect_api.VehicleManager] time diff - 80618.804313
2022-11-23 10:19:23.805 DEBUG (SyncWorker_13) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-23 09:02:59.887000+00:00 120000 38 998 38.199316474999996
2022-11-23 10:21:18.970 DEBUG (SyncWorker_13) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - Received forced vehicle data {'retCode': 'F', 'resCode': '4081', 'resMsg': 'Request timeout. - Request timeout.', 'msgId': '2188c1d4-49bb-4cc6-8d9d-2a873093b233'}
2022-11-23 10:21:18.971 DEBUG (SyncWorker_13) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - get_stamp 2022-11-23 09:02:59.887000+00:00 120000 39 998 39.15903672500001
2022-11-23 10:21:19.188 DEBUG (SyncWorker_13) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location response {'retCode': 'F', 'resCode': '4004', 'resMsg': 'Duplicate request - Duplicate request', 'msgId': 'f612380e-7f6b-4aef-a3a4-c303e7d9164a'}
2022-11-23 10:21:19.188 WARNING (SyncWorker_13) [hyundai_kia_connect_api.KiaUvoApiEU] hyundai_kia_connect_api - _get_location failed
2022-11-23 10:21:19.192 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'str' object does not support item assignment
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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.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 77, in check_and_force_update_vehicles
    self.force_refresh_vehicle_state(vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state
    self.api.force_refresh_vehicle_state(self.token, vehicle)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 188, in force_refresh_vehicle_state
    state["vehicleLocation"] = self._get_location(token, vehicle)
TypeError: 'str' object does not support item assignment
2022-11-23 10:21:19.196 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 117.151 seconds (success: False)
rindlerblabla commented 1 year ago

I have had no issues since .35. Force updating using the service works fine, and so does the updates forced by the refresh interval.

rindlerblabla commented 1 year ago

With .36 I got

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:127
Integration: Kia Uvo / Hyundai Bluelink (documentation, issues)
First occurred: 23:36:39 (5 occurrences)
Last logged: 23:38:13

Unexpected error fetching kia_uvo data: 0
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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 127, 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 90, in check_and_refresh_token
    self.initialize()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 53, in initialize
    self.update_all_vehicles_with_cached_state()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 60, 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 63, 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 219, in update_vehicle_with_cached_state
    self._update_vehicle_properties(vehicle, state)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 238, in _update_vehicle_properties
    DISTANCE_UNITS[
KeyError: 0

The debug log consist of probably the whole Kia website, it looks. Hehe. Restarting the integration didn't solve the issue, however after updating the status in the Kia app and then restarting the integration it now works again.

cdnninja commented 1 year ago

With .36 I got

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:127
Integration: Kia Uvo / Hyundai Bluelink (documentation, issues)
First occurred: 23:36:39 (5 occurrences)
Last logged: 23:38:13

Unexpected error fetching kia_uvo data: 0
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, 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 127, 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 90, in check_and_refresh_token
    self.initialize()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 53, in initialize
    self.update_all_vehicles_with_cached_state()
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 60, 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 63, 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 219, in update_vehicle_with_cached_state
    self._update_vehicle_properties(vehicle, state)
  File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 238, in _update_vehicle_properties
    DISTANCE_UNITS[
KeyError: 0

The debug log consist of probably the whole Kia website, it looks. Hehe. Restarting the integration didn't solve the issue, however after updating the status in the Kia app and then restarting the integration it now works again.

Would need the contents of what is in the distance response to know what happened here. This is what it was looking for: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/49b7847964a4fea4d68248a641bbef2c2df209e9/hyundai_kia_connect_api/KiaUvoApiEU.py#L238-L242

1 is KM 3 is miles but it returned 0 by the sounds of it. So interested to know if all data was blank or just units.

cdnninja commented 1 year ago

@rindlerblabla your car isn't providing range remaining. It is reporting both distance and unit as 0 for all fields. I have created a fix for that. Please re-test in v2.0.37

rindlerblabla commented 1 year ago

@cdnninja It does provide that data in general, but for some reason some calls had that info missing. Last couple of hours it has been stable. Will try latest version though.

rindlerblabla commented 1 year ago

@cdnninja

Logger: custom_components.kia_uvo.coordinator
Source: custom_components/kia_uvo/coordinator.py:109
Integration: Kia Uvo / Hyundai Bluelink (documentation, issues)
First occurred: 21:07:05 (8 occurrences)
Last logged: 21:12:11

Unexpected error fetching kia_uvo data: name 'no_force_refresh_hour_finish' is not defined
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/kia_uvo/coordinator.py", line 109, in _async_update_data
    or current_hour >= no_force_refresh_hour_finish
NameError: name 'no_force_refresh_hour_finish' is not defined
cdnninja commented 1 year ago

Could you re-download v2.0.37? I had a mistake that your restriction hours triggered.

rindlerblabla commented 1 year ago

No issues at all on latest. Think this issue is solved, but will see if it will be stable for days.