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
440 stars 88 forks source link

Version 2.0 #219

Closed fuatakgun closed 1 year ago

fuatakgun commented 2 years ago

https://pypi.org/project/hyundai-kia-connect-api/ https://github.com/fuatakgun/hyundai_kia_connect_api

repository is set to generate a new release for each commit and deploy each new release into pypi

cdnninja commented 2 years ago

A draft of this exists here: https://github.com/fuatakgun/kia_uvo/tree/externalAPI

Manual install will be required for this.

Key warnings to be aware of for those that want to try it:

  1. It deletes all existing sensors and recreates them. This means existing dashboards won't work.
  2. It doesn't support services yet, so no remote start, lock unlock etc. (EDIT: most services added, missing remote start)
  3. It is missing some sensors. Some we are aware of others we probably aren't since our cars don't have them. Some will be very easy to fix in the new model.
  4. It migrates your configuration automatically. If you want to revert back you will need to reconfigure the integration.

Now the good.

  1. It supports multiple cars per account and multiple accounts!
  2. It is much easier to support regions and brands.
  3. It is code that has been submitted to core. Helping test brings us closer to being in home assistant core!
cdnninja commented 2 years ago

@MrDadoo I have added all those missing sensors you have mentioned except the AC one. Services are still ongoing.

Raptor607 commented 2 years ago

I now have 2 US Kia's and would be happy to help with testing. 2020 Telluride & 2022 K5. Currently both are on same account.

cdnninja commented 2 years ago

Awesome! This is the one un-tested region so help would be greatly appreciated. To "install" copy the full contents of the externalAPI data replacing the files currently in home assistant. Please make sure you are aware of the risks above. I fully expect an error on the first attempt. Please enable debug logs and provide them. At which point I will correct the item and move on to the next error.

Raptor607 commented 2 years ago
2022-02-02 10:55:14 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'Token' object has no attribute 'vehicle_regid'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 196, in update_vehicle_with_cached_state
state = self._get_cached_vehicle_state(token, vehicle.id)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 327, in _get_cached_vehicle_state
"vinKey": [token.vehicle_regid],
AttributeError: 'Token' object has no attribute 'vehicle_regid'
2022-02-02 10:55:14 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 2.380 seconds (success: False)
2022-02-02 10:55:25 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'Token' object has no attribute 'vehicle_regid'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 196, in update_vehicle_with_cached_state
state = self._get_cached_vehicle_state(token, vehicle.id)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 327, in _get_cached_vehicle_state
"vinKey": [token.vehicle_regid],
AttributeError: 'Token' object has no attribute 'vehicle_regid'
2022-02-02 10:55:25 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.649 seconds (success: False)
2022-02-02 10:55:46 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: 'Token' object has no attribute 'vehicle_regid'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 196, in update_vehicle_with_cached_state
state = self._get_cached_vehicle_state(token, vehicle.id)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 327, in _get_cached_vehicle_state
"vinKey": [token.vehicle_regid],
AttributeError: 'Token' object has no attribute 'vehicle_regid'
2022-02-02 10:55:46 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.084 seconds (success: False)
cdnninja commented 2 years ago

Made some API updates to deal with that. The manifest.json file now should have the API as version: 1.21.7

Raptor607 commented 2 years ago

After the revised manifest.json:

2022-02-02 15:05:36 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: can't compare offset-naive and offset-aware datetimes
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in check_and_refresh_token
if self.token.valid_until <= dt.datetime.now(pytz.utc):
TypeError: can't compare offset-naive and offset-aware datetimes
2022-02-02 15:05:36 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 4.267 seconds (success: False)
2022-02-02 15:05:36 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Kia USA xxxx@xxxx.net' for kia_uvo integration not ready yet: can't compare offset-naive and offset-aware datetimes; Retrying in background
2022-02-02 15:05:41 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: can't compare offset-naive and offset-aware datetimes
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in check_and_refresh_token
if self.token.valid_until <= dt.datetime.now(pytz.utc):
TypeError: can't compare offset-naive and offset-aware datetimes
2022-02-02 15:05:41 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 4.732 seconds (success: False)
2022-02-02 15:05:55 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: can't compare offset-naive and offset-aware datetimes
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in check_and_refresh_token
if self.token.valid_until <= dt.datetime.now(pytz.utc):
TypeError: can't compare offset-naive and offset-aware datetimes
2022-02-02 15:05:55 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 3.761 seconds (success: False)
2022-02-02 15:06:19 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: can't compare offset-naive and offset-aware datetimes
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in check_and_refresh_token
if self.token.valid_until <= dt.datetime.now(pytz.utc):
TypeError: can't compare offset-naive and offset-aware datetimes
2022-02-02 15:06:19 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 4.062 seconds (success: False)
cdnninja commented 2 years ago

1.22.1 is the next version.

Raptor607 commented 2 years ago

1.22.1 results below (and just verifying all I'm changing is the manifest.json file which calls the api's?)

2022-02-02 18:10:41 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: expected string or bytes-like object
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 202, in update_vehicle_with_cached_state
vehicle.last_updated_at = self.get_last_updated_at(
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 313, in get_last_updated_at
m = re.match(r"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", value)
File "/usr/local/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
2022-02-02 18:10:41 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 3.021 seconds (success: False)
2022-02-02 18:10:41 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Kia USA xxxx@xxxx.xxx' for kia_uvo integration not ready yet: expected string or bytes-like object; Retrying in background
2022-02-02 18:10:43 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: expected string or bytes-like object
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 202, in update_vehicle_with_cached_state
vehicle.last_updated_at = self.get_last_updated_at(
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 313, in get_last_updated_at
m = re.match(r"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", value)
File "/usr/local/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
2022-02-02 18:10:43 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 2.685 seconds (success: False)
2022-02-02 18:10:56 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: expected string or bytes-like object
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 202, in update_vehicle_with_cached_state
vehicle.last_updated_at = self.get_last_updated_at(
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 313, in get_last_updated_at
m = re.match(r"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", value)
File "/usr/local/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
2022-02-02 18:10:56 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 2.820 seconds (success: False)
2022-02-02 18:11:19 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: expected string or bytes-like object
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 202, in update_vehicle_with_cached_state
vehicle.last_updated_at = self.get_last_updated_at(
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 313, in get_last_updated_at
m = re.match(r"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", value)
File "/usr/local/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
2022-02-02 18:11:19 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 2.703 seconds (success: False)
2022-02-02 18:12:02 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: expected string or bytes-like object
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/kia_uvo/coordinator.py", line 81, in _async_update_data
await self.async_check_and_refresh_token()
File "/config/custom_components/kia_uvo/coordinator.py", line 104, in async_check_and_refresh_token
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 86, in check_and_refresh_token
self.initialize()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 51, in initialize
self.update_all_vehicles_with_cached_state()
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 58, in update_all_vehicles_with_cached_state
self.update_vehicle_with_cached_state(self.get_vehicle(vehicle_id))
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 61, in update_vehicle_with_cached_state
self.api.update_vehicle_with_cached_state(self.token, vehicle)
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 202, in update_vehicle_with_cached_state
vehicle.last_updated_at = self.get_last_updated_at(
File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 313, in get_last_updated_at
m = re.match(r"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", value)
File "/usr/local/lib/python3.9/re.py", line 191, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
2022-02-02 18:12:02 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 3.120 seconds (success: False)
cdnninja commented 2 years ago

Yes that is correct just the manifest file. We know the actual new integration works on new regions so this is just getting the API packaged addressed for Kia USA.

1.22.2 is uploaded now. Good news is based on this last error we are past the login and moving into data mapping.

Raptor607 commented 2 years ago

image

2022-02-02 19:41:35 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 32.858 seconds (success: True)

I don't see anything else in log :-)

Haven't looked at the entities yet, but looking good so far!

Raptor607 commented 2 years ago

Great work BTW - thanks for your efforts!

Some "very quick" observations re: entities. As you expected, some minor work to do here.

image

image image

cdnninja commented 2 years ago

Temp unit and lock should be fixed in 1.22.3. The data entity was removed as the Core Home Assistant team requested it be removed in our core submission. The code you are running is modeled after that but closer to feature parity. Did you use the data entity before? I am starting to wonder if the core submission will get approved or if we continue on here.

cdnninja commented 2 years ago

Could you browse through these two files and see what sensors your a missing that you have data in debug logging for? https://github.com/fuatakgun/kia_uvo/blob/externalAPI/custom_components/kia_uvo/binary_sensor.py https://github.com/fuatakgun/kia_uvo/blob/externalAPI/custom_components/kia_uvo/sensor.py

Enable debug logging for the new API is outlined here at the bottom: https://github.com/fuatakgun/kia_uvo/tree/externalAPI it is a new line in the config.

Raptor607 commented 2 years ago

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

Entity In single-vehicle app In multi-vehicle app
     
Fuel level % Yes No
Range by Fuel Yes No
Air Conditioner Yes No
Location Yes No
Odometer Yes No
Smart Key Battery Warning Yes No
Tire Pressure All Yes No
Washer fluid warning Yes No

Set Temp and lock verified corrected with 1.22.3

On the one hand, I could live without the data entity as the same info is in the debug log (just not nicely formatted). On the other, if sometime down the road I had a desire to extract one of those values that you hadn’t made a entity, I could simply add it as a manual sensor. There’s probably some way for me to pull it from the debug log to do the same, but it wouldn’t be nearly as easy…).

Had an internet outage today and the app did not recover (ie. showed all data unavailable) after internet was restored . Reloading the integration appears to have fixed.

2022-02-03 06:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - last_updated_at - before 20220203103656 2022-02-03 06:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - last_updated_at - after 2022-02-03 10:36:56+00:00 2022-02-03 06:16:27 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 75.578569 2022-02-03 06:16:27 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 2371.578569 2022-02-03 06:16:27 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 4.606 seconds (success: True) 2022-02-03 06:46:27 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 1875.001683 2022-02-03 06:46:27 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 4171.001683 2022-02-03 06:46:27 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.003 seconds (success: True) 2022-02-03 07:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 07:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 07:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id 1ab5789e-1f26-405a-ba29-bd1fb055f50d 2022-02-03 07:16:27 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] time diff - 3675.786312 2022-02-03 07:16:27 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] time diff - 5971.786312 2022-02-03 07:16:27 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.780 seconds (success: True) 2022-02-03 07:46:27 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 5475.001731 2022-02-03 07:46:27 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 7771.001731 2022-02-03 07:46:27 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.002 seconds (success: True) 2022-02-03 08:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 7275.002111 2022-02-03 08:16:27 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 9571.002111 2022-02-03 08:16:27 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.002 seconds (success: True) 2022-02-03 08:46:27 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 08:46:28 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 08:46:28 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id de51da79-e757-4bb1-aee0-f8ef53a4da28 2022-02-03 08:46:28 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 9076.160261 2022-02-03 08:46:28 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 11372.160261 2022-02-03 08:46:28 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.158 seconds (success: True) 2022-02-03 09:16:28 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 10876.010792 2022-02-03 09:16:28 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 13172.010792 2022-02-03 09:16:28 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.001 seconds (success: True) 2022-02-03 09:46:28 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 12676.004166 2022-02-03 09:46:28 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 14972.004166 2022-02-03 09:46:28 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 09:46:28 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 09:46:28 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 09:46:28 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Error requesting kia_uvo data: 2022-02-03 09:46:28 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.652 seconds (success: False) 2022-02-03 10:16:28 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 10:16:29 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 10:16:29 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id 452f9534-b1ff-494f-b5cb-c0349d5989b4 2022-02-03 10:16:29 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] time diff - 14477.010719 2022-02-03 10:16:29 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 10:16:29 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 10:16:29 ERROR (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 10:16:29 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.783 seconds (success: False) 2022-02-03 10:46:29 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] time diff - 16277.001057 2022-02-03 10:46:29 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 10:46:29 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 10:46:29 ERROR (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 10:46:29 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.762 seconds (success: False) 2022-02-03 11:16:29 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 18077.001835 2022-02-03 11:16:29 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 11:16:29 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 11:16:29 ERROR (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 11:16:29 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.758 seconds (success: False) 2022-02-03 11:46:29 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 11:46:29 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 11:46:29 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id 3e33250a-c1b8-4ba1-a6e6-e305e5b48a70 2022-02-03 11:46:29 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 19877.845896 2022-02-03 11:46:29 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 11:46:30 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 11:46:30 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 11:46:30 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.403 seconds (success: False) 2022-02-03 12:16:30 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 21678.001869 2022-02-03 12:16:30 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 12:16:30 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 12:16:30 ERROR (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 12:16:30 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.797 seconds (success: False) 2022-02-03 12:46:30 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 12:46:31 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 12:46:31 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id aa5f17b8-4fbb-4114-937d-ca5e7f260b74 2022-02-03 12:46:31 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 23479.038407 2022-02-03 12:46:31 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 12:46:31 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 12:46:31 ERROR (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 12:46:31 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.583 seconds (success: False) 2022-02-03 13:16:31 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.VehicleManager] time diff - 25279.002061 2022-02-03 13:16:31 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 13:16:31 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 13:16:31 ERROR (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 13:16:31 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.756 seconds (success: False)

Lost internet connectivity around this time <<<<<<<<<<<<<

2022-02-03 13:46:31 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 27079.002177 2022-02-03 13:46:31 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 13:46:36 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 5.009 seconds (success: False) 2022-02-03 14:16:35 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/hacs/base.py", line 696, in recurring_tasks_installed await self.handle_critical_repositories() File "/config/custom_components/hacs/base.py", line 630, in handle_critical_repositories critical = await self.async_github_get_hacs_default_file("critical") File "/config/custom_components/hacs/base.py", line 442, in async_github_get_hacs_default_file response = await self.async_github_api_method( File "/config/custom_components/hacs/base.py", line 479, in async_github_api_method raise HacsException(_exception) custom_components.hacs.exceptions.HacsException: Request exception for 'https://api.github.com/repos/hacs/default/contents/critical' with - Cannot connect to host api.github.com:443 ssl:default [Try again] 2022-02-03 14:16:36 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 14:16:41 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 5.010 seconds (success: False) 2022-02-03 14:16:58 ERROR (MainThread) [custom_components.hacs] <Integration fuatakgun/kia_uvo> Cannot connect to host api.github.com:443 ssl:default [Try again] 2022-02-03 14:46:41 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 14:46:41 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 14:46:41 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id d8019f46-748d-4f53-9ee1-e84e872432a8 2022-02-03 14:46:41 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 30689.768504 2022-02-03 14:46:41 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 14:46:42 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 14:46:42 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 14:46:42 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.289 seconds (success: False) 2022-02-03 15:16:42 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 32490.003509 2022-02-03 15:16:42 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 15:16:43 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 15:16:43 ERROR (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 15:16:43 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.099 seconds (success: False) 2022-02-03 15:46:43 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 15:46:43 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 15:46:43 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id 6e51920d-b00e-48ec-8c6b-a387e920b74b 2022-02-03 15:46:43 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 34291.811387 2022-02-03 15:46:43 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 15:46:44 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 15:46:44 ERROR (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 15:46:44 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.329 seconds (success: False) 2022-02-03 16:16:44 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 36092.00276 2022-02-03 16:16:44 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 16:16:44 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 16:16:44 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 16:16:44 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.553 seconds (success: False) 2022-02-03 16:46:44 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 16:46:44 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 16:46:44 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id 6e557e28-0311-4461-a2e0-a36cf01dc0a5 2022-02-03 16:46:44 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 37892.619993 2022-02-03 16:46:44 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 16:46:45 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 16:46:45 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 16:46:45 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.050 seconds (success: False) 2022-02-03 17:16:45 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] time diff - 39693.00252 2022-02-03 17:16:45 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 17:16:45 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 17:16:45 ERROR (SyncWorker_3) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 17:16:45 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.620 seconds (success: False) 2022-02-03 17:46:45 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired 2022-02-03 17:46:45 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-03 17:46:45 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id 9257d3c9-306e-43fe-a214-3d3e1631547c 2022-02-03 17:46:45 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 41493.845125 2022-02-03 17:46:45 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 17:46:46 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 17:46:46 ERROR (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 17:46:46 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.338 seconds (success: False) 2022-02-03 18:16:46 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] time diff - 43294.0017 2022-02-03 18:16:46 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-03 18:16:46 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 18:16:46 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-03 18:16:46 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.750 seconds (success: False)

cdnninja commented 2 years ago

1.22.4 should fix a few of the sensors. The ones aren't in the API yet are location, and AC. I do thing smart key needs to be updated in this repo still so I don't expect it to work yet. I will spend a bit more time on that this weekend hopefully. As for that error - thanks for reporting it. I think I have an idea on fixing it but will take a bit of time.

On the data sensor I am tempted to add it back - even if just here in the custom version since it is handy for testing.

Raptor607 commented 2 years ago

1.22.4 installed. Later in the day sensors showed unavailable again. No corresponding loss of internet connection today though.

Raptor607 commented 2 years ago

A reload did not correct this time. The logs show successful connection/retrieval of the data but sensors show as "unavailable" and integration shows "Not loaded". Restarting HA corrected it.

cdnninja commented 2 years ago

Yes I think I have an idea on what is the cause for that. Basically some of the vehicle data is actually one time use yet we are storing it with the vehicle data.

cdnninja commented 2 years ago

I just updated to 1.22.5. After a token expiry it refreshes the session specific data. This may fix this issue.

Raptor607 commented 2 years ago

I've updated as well & will report back.

Raptor607 commented 2 years ago

Issue persists:

2022-02-05 08:05:04 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Refresh token expired

2022-02-05 08:05:04 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}}

2022-02-05 08:05:04 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id a58a2fa1-5ad4-4757-a9d5-720742837e20

2022-02-05 08:05:05 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Get Vehicles Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleSummary": (**** note: vehicle data removed for posting)

2022-02-05 08:05:05 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: can't subtract offset-naive and offset-aware datetimes

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, 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.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 66, in check_and_force_update_vehicles f"time diff - {(started_at_utc - vehicle.last_updated_at).total_seconds()}" TypeError: can't subtract offset-naive and offset-aware datetimes

2022-02-05 08:05:05 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.636 seconds (success: False)

cdnninja commented 2 years ago

1.22.5 builds on the work in the last commit. The good news is the above code isn't the API failing but rather lacking data when it checks. 1.22.5 uses a bit of a different approach so hopefully will solve it. Kia USA has a pretty unique scheme for authentication.

Raptor607 commented 2 years ago

I'm assuming you meant 1.22.6? Hope so because that's what I'm using... which is good because it's been solid for over 4 hours so far.

Raptor607 commented 2 years ago

Still good, so 1.22.6 seems to have fixed the unavailable sensor issue :-)

Tried locking the doors and received this error:

2022-02-06 06:31:06 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] Action for lock is: Vehicle(id='118295', name='K5', model='K5', registration_date=None, year=None, VIN=None, key='xxxxxxxxxx', _total_driving_distance=None, _total_driving_distance_value=None, _total_driving_distance_unit='mi', _odometer=95.5, _odometer_value=95.5, _odometer_unit='mi', car_battery_percentage=63, engine_is_running=False, last_updated_at=datetime.datetime(2022, 2, 6, 11, 9, 57, tzinfo=datetime.timezone.utc), smart_key_battery_warning_is_on=False, washer_fluid_warning_is_on=False, brake_fluid_warning_is_on=None, _air_temperature='72', _air_temperature_value='72', _air_temperature_unit='°F', defrost_is_on=False, steering_wheel_heater_is_on=0, back_window_heater_is_on=0, side_mirror_heater_is_on=0, front_left_seat_heater_is_on=None, front_right_seat_heater_is_on=None, rear_left_seat_heater_is_on=None, rear_right_seat_heater_is_on=None, is_locked=False, front_left_door_is_open=0, front_right_door_is_open=0, back_left_door_is_open=0, back_right_door_is_open=0, trunk_is_open=0, hood_is_open=0, tire_pressure_all_warning_is_on=0, tire_pressure_rear_left_warning_is_on=None, tire_pressure_front_left_warning_is_on=None, tire_pressure_front_right_warning_is_on=None, tire_pressure_rear_right_warning_is_on=None, _next_service_distance=None, _next_service_distance_value=None, _next_service_distance_unit='mi', _last_service_distance=None, _last_service_distance_value=None, _last_service_distance_unit='mi', ev_battery_percentage=None, ev_battery_is_charging=None, ev_battery_is_plugged_in=None, _ev_driving_distance=None, _ev_driving_distance_value=None, _ev_driving_distance_unit='mi', _ev_estimated_current_charge_duration=None, _ev_estimated_current_charge_duration_value=None, _ev_estimated_current_charge_duration_unit='m', _ev_estimated_fast_charge_duration=None, _ev_estimated_fast_charge_duration_value=None, _ev_estimated_fast_charge_duration_unit='m', _ev_estimated_portable_charge_duration=None, _ev_estimated_portable_charge_duration_value=None, _ev_estimated_portable_charge_duration_unit='m', _ev_estimated_station_charge_duration=None, _ev_estimated_station_charge_duration_value=None, _ev_estimated_station_charge_duration_unit='m', _fuel_driving_distance=None, _fuel_driving_distance_value=None, _fuel_driving_distance_unit='mi', fuel_level=89, fuel_level_is_low=False, engine_type=None, data={'vehicleStatus': {'climate': {'airCtrl': False, 'defrost': False, 'airTemp': {'value': '72', 'unit': 1}, 'heatingAccessory': {'steeringWheel': 0, 'sideMirror': 0, 'rearWindow': 0}, 'heatVentSeat': {'driverSeat': {'heatVentType': 0, 'heatVentLevel': 1}, 'passengerSeat': {'heatVentType': 0, 'heatVentLevel': 1}, 'rearLeftSeat': {'heatVentType': 0, 'heatVentLevel': 1}, 'rearRightSeat': {'heatVentType': 0, 'heatVentLevel': 1}}}, 'engine': False, 'doorLock': False, 'doorStatus': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0, 'trunk': 0, 'hood': 0}, 'lowFuelLight': False, 'ign3': False, 'transCond': True, 'distanceToEmpty': {'value': 375, 'unit': 3}, 'tirePressure': {'all': 0}, 'dateTime': {'utc': '20220206110959', 'offset': -8}, 'syncDate': {'utc': '20220206110957', 'offset': -8}, 'batteryStatus': {'stateOfCharge': 63, 'deliveryMode': 1, 'warning': 65, 'powerAutoCutMode': 2}, 'sleepMode': False, 'lampWireStatus': {'headLamp': {'headLampStatus': False, 'lampLL': False, 'lampRL': False, 'lampLH': False, 'lampRH': False, 'lampLB': False, 'lampRB': False}, 'stopLamp': {'leftLamp': False, 'rightLamp': False}, 'turnSignalLamp': {'lampLF': False, 'lampRF': False, 'lampLR': False, 'lampRR': False}}, 'windowStatus': {'windowFL': 0, 'windowFR': 0, 'windowRL': 0, 'windowRR': 0}, 'smartKeyBatteryWarning': False, 'fuelLevel': 89, 'washerFluidStatus': False, 'brakeOilStatus': False, 'engineOilStatus': False, 'engineRuntime': {}, 'valetParkingMode': 0, 'tirePressureLamp': {'tirePressureLampAll': 0}, 'airCtrlOn': False, 'defrost': False, 'sideBackWindowHeat': 0, 'sideMirrorHeat': 0, 'steerWheelHeat': 0, 'airTemp': {'value': '72', 'unit': 1}}, 'odometer': {'value': 95.5, 'unit': 3}, 'vehicleLocation': {'coord': {'lat': xxxxxxxxx, 'lon': -xxxxxxxx, 'alt': 447, 'type': 0, 'altdo': 0}, 'head': 339, 'speed': {'value': 0, 'unit': 1}, 'accuracy': {'hdop': 8, 'pdop': 14}, 'syncDate': {'utc': '20220206100827', 'offset': -8}}}) 2022-02-06 06:31:06 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] Calling unlock 2022-02-06 06:31:06 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/door/unlock request 2022-02-06 06:31:06 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140690300028720] get_request_with_logging_and_active_session() got an unexpected keyword argument 'vehicle' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, 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 109, in async_lock_vehicle await self.hass.async_add_executor_job(self.vehicle_manager.lock, vehicle_id) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, self.kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 101, in lock return self.api.lock_action(self.token, self.get_vehicle(vehicle_id), VEHICLE_LOCK_ACTION.LOCK) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 463, in lock_action response = self.get_request_with_logging_and_active_session( File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 30, in request_with_active_session_wrapper return func(*args, *kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 60, in request_with_logging_wrapper response = func(args, kwargs) TypeError: get_request_with_logging_and_active_session() got an unexpected keyword argument 'vehicle'

Raptor607 commented 2 years ago

I spoke too soon. 11 minutes later the sensors went unavailable - maybe related to the attempt to lock the doors?

2022-02-06 06:42:02 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 1925.001606 2022-02-06 06:42:02 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.VehicleManager] time diff - 177305.001606 2022-02-06 06:42:02 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/rvs request with {'requestType': 0} 2022-02-06 06:42:02 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1003,"errorMessage":"Session Key is either invalid or expired"}} 2022-02-06 06:42:02 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: session invalid 2022-02-06 06:42:02 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] got invalid session, attempting to repair and resend 2022-02-06 06:42:02 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Unexpected error fetching kia_uvo data: login() missing 2 required positional arguments: 'username' and 'password' Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 30, in request_with_active_session_wrapper return func(*args, *kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 71, in request_with_logging_wrapper raise AuthError hyundai_kia_connect_api.KiaUvoAPIUSA.AuthError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, 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.9/concurrent/futures/thread.py", line 52, in run result = self.fn(self.args, **self.kwargs) File "/usr/local/lib/python3.9/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.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 82, in force_refresh_vehicle_state self.api.force_refresh_vehicle_state(self.token, vehicle) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 438, in force_refresh_vehicle_state self.post_request_with_logging_and_active_session( File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 36, in request_with_active_session_wrapper new_token = self.login() TypeError: login() missing 2 required positional arguments: 'username' and 'password' 2022-02-06 06:42:02 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.536 seconds (success: False)

Raptor607 commented 2 years ago

and all was good again, until a few minutes ago...

One commonality in both this and the last unavailable was that I opened the Android app. Could that be causing a problem?

cdnninja commented 2 years ago

Ahh yes I think that was a known item. I did a fix in 1.22.8 that should solve the lock issue. It also works toward fixing that app issue but I don't think it will fully resolve that.

Raptor607 commented 2 years ago

Stable so far since this morning, after using the app.

Another lock issue though:

2022-02-07 18:56:12 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] Calling unlock 2022-02-07 18:56:12 DEBUG (SyncWorker_1) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/door/unlock request 2022-02-07 18:56:12 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139684012260176] 'VEHICLE_LOCK_ACTION' object has no attribute 'key' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, 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 112, in async_unlock_vehicle await self.hass.async_add_executor_job(self.vehicle_manager.unlock, vehicle_id) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, self.kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 104, in unlock return self.api.lock_action(self.token, self.get_vehicle(vehicle_id), VEHICLE_LOCK_ACTION.UNLOCK) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 462, in lock_action response = self.get_request_with_logging_and_active_session( File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 30, in request_with_active_session_wrapper return func(*args, *kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 59, in request_with_logging_wrapper response = func(args, kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 148, in get_request_with_logging_and_active_session headers = self.authed_api_headers(token, vehicle) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 132, in authed_api_headers headers["vinkey"] = vehicle.key AttributeError: 'VEHICLE_LOCK_ACTION' object has no attribute 'key'

cdnninja commented 2 years ago

1.26.1 made some changes to the lock method. It should solve that. FYI the app invalidating the token is still on my to do list.

Raptor607 commented 2 years ago

Updated to 1.26.1 yesterday. As of this evening, no issues to report with unavailability or lock functions.

Raptor607 commented 2 years ago

Noticed today that the K5 door lock status doesn't appear to be correct. The Telluride seems to be fine. Will monitor this more closely over the next few days to see if its really an issue...

Any new changes that need to be tested?

I'm somewhat considering moving to 2 separate accounts for our Kia's. I saw some threads mentioning that capability at some point but wondered what the current status is?

cdnninja commented 2 years ago

Keep me posted on what you find on the locks. This integration scans at a set interval so if it changes it won't catch it right away. On the to do list is to make this new version scan after something like a lock command is used so it will reflect it right away.

As for new changes, I implemented almost all services with the exception of remote start. Those could be tested. I think the other thing would be looking through and comparing your log data to the following two files to see if we have a sensor that is missing that you have the data for:

https://github.com/fuatakgun/kia_uvo/blob/externalAPI/custom_components/kia_uvo/sensor.py https://github.com/fuatakgun/kia_uvo/blob/externalAPI/custom_components/kia_uvo/binary_sensor.py

This is getting really close to feature parity at which point I will release a beta through HACS for wider testing.

As for two accounts yes this new version supports that too! I don't think it has been tested yet - since I own a single car KIA.

cdnninja commented 2 years ago

Remote start should now work. I haven't tested yet. It also needs lots of error checking added plus the heated seats and other items like that.

Raptor607 commented 2 years ago

sounds good - what version should I change to?

Raptor607 commented 2 years ago

Agree with the scan after lock/unlock and for START control as well. Which made me think... the KIA app shows engine running/stopped - this would be nice for an automation to notify start was successful or not! Not sure what data element that might be yet...

Using 1.28.0, I'm not seeing any controls for remote start or update, force update, etc. - just lock/unlock.

Still missing the sensors below

image

cdnninja commented 2 years ago

Thanks for checking!

Those items were added with changes to the externalAPI branch not the api version. Are you able to make sure to update the integration files?

On Feb 12, 2022, at 5:38 PM, Raptor607 @.***> wrote:

 Agree with the scan after lock/unlock and for START control as well. Which made me think... the KIA app shows engine running/stopped - this would be nice for an automation to notify start was successful or not! Not sure what data element that might be yet...

Using 1.28.0, I'm not seeing any controls for remote start or update, force update, etc. - just lock/unlock.

Still missing the sensors below

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.

Raptor607 commented 2 years ago

Copied new files and have all the services now (haven't tried using them yet)

Missing:

cdnninja commented 2 years ago

Just updated to 1.29.2 that may fix these. They are both mapping issues. Here is what I am trying:

https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/commit/5ec710f4e9acb4926870e97190adcad0790f1cca

So I am assuming data for range is vehicleStatus.distanceToEmpty.value for KIA USA, for location "location.coord.lat", not sure if you have a time variable on the location data.

Raptor607 commented 2 years ago

the Fuel DTE is now working. Location is not. Here's a snip of log:

2022-02-13 18:12:23 DEBUG (SyncWorker_5) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleInfoList":[{"vinKey":"xxxxxxxxxx","vehicleConfig":{"vehicleDetail":{"vehicle":{"vin":"xxxxxxxxxxxxx","trim":{"modelYear":"2020","salesModelCode":"J4442","optionGroupCode":"010","modelName":"TELLURIDE","factoryCode":"S9","projectCode":"ON","trimName":"EX","driveType":"2","transmissionType":"1","ivrCategory":"5","btSeriesCode":"J"},"telematics":1,"mileage":"26131.8","mileageSyncDate":"20220213050357","exteriorColor":"SANGRIA","exteriorColorCode":"MOM","fuelType":1,"invDealerCode":"PA077","testVehicle":"0","supportedApps":[{"appType":"0"},{"appType":"5","appImage":{"imageName":"uvo-app.png","imagePath":"/content/dam/kia/us/owners/image/common/app/access/","imageType":"2","imageSize":{"length":"100","width":"100","uom":0}}}],"activationType":2},"images":[{"imageName":"2020-telluride-ex-m2r.png","imagePath":"/content/dam/kia/us/owners/image/vehicle-app/2020/telluride/ex/","imageType":"1","imageSize":{"length":"100","width":"100","uom":0}}],"device":{"launchType":"0","swVersion":"ON.USA.S5W_M.V003.002.190813","telematics":{"generation":"3","platform":"1","tmsCenter":"1","billing":true},"versionNum":"GASOLINE","headUnitType":"0","hdRadio":"X40HAF","ampType":"NA","modem":{"meid":"xxxxxxxx","mdn":"6xxxxxxxx","iccid":"x"},"headUnitName":"avn5w","bluetoothRef":"20","headUnitDesc":"AVN5.0W"}},"maintenance":{"nextServiceMile":3868.1992,"maintenanceSchedule":[7500,15000,22500,30000,37500,45000,52500,60000,67500,75000,82500,90000,97500,105000,112500]},"billingPeriod":{"freeTrial":{"value":12,"unit":0},"freeTrialExtension":{"value":12,"unit":1},"servicePeriod":{"value":60,"unit":1}}},"lastVehicleInfo":{"vehicleNickName":"Telluride","preferredDealer":"PA099","customerType":0,"enrollment":{"provStatus":"4","enrollmentStatus":"1","enrollmentType":"0","registrationDate":"20190907","expirationDate":"20200907","expirationMileage":"100000","freeServiceDate":{"startDate":"20190907","endDate":"20200907"}},"activeDTC":{"dtcActiveCount":"1","dtcCategory":[{"system":"2","systemName":"SAFETY","activeCount":1,"dtcDetail":[{"ecuId":"05A2","dtcCode":"B1493","dtcDate":{"utc":"20220213193502","offset":-5},"carMessage":"A possible condition with your Airbag??System has been detected. A full system check is recommended to be done soon. Please contact your local dealership to schedule an appointment.","webMessage":"<strong>Issue Description:</strong><br />A possible condition with your Airbag??System has been detected.<br /><br /><strong>Recommendation:</strong><br /> A full system check is recommended to be done soon. Please contact your local dealership to schedule an appointment.<br />","ttsMessage":"A possible condition with your Airbag??System has been detected. A full system check is recommended to be done soon. Please contact your local dealership to schedule an appointment.","systemName":"SAFETY","subSystemName":"Airbag","dtcPriority":"2A","image":{"imageName":"pc_06_airbag_warning_light.png","imagePath":"/content/dam/kia/us/owners/image/feature/maintenance/MIL","imageType":"2"}}]}],"lastDTCDate":{"utc":"20220213193502","offset":-5}},"vehicleStatusRpt":{"statusType":"2","reportDate":{"utc":"20220213231222","offset":-8},"vehicleStatus":{"climate":{"airCtrl":false,"defrost":false,"airTemp":{"value":"72","unit":1},"heatingAccessory":{"steeringWheel":0,"sideMirror":0,"rearWindow":0},"heatVentSeat":{"driverSeat":{"heatVentType":0,"heatVentLevel":0},"passengerSeat":{"heatVentType":0,"heatVentLevel":0},"rearLeftSeat":{"heatVentType":0,"heatVentLevel":0},"rearRightSeat":{"heatVentType":0,"heatVentLevel":0}}},"engine":false,"doorLock":false,"doorStatus":{"frontLeft":0,"frontRight":0,"backLeft":0,"backRight":0,"trunk":0,"hood":0},"lowFuelLight":false,"ign3":false,"transCond":true,"distanceToEmpty":{"value":280,"unit":3},"tirePressure":{"all":0},"dateTime":{"utc":"20220213231222","offset":-8},"syncDate":{"utc":"20220213224748","offset":-8},"batteryStatus":{"stateOfCharge":70,"sensorStatus":0,"deliveryMode":1},"lampWireStatus":{"headLamp":{},"stopLamp":{},"turnSignalLamp":{}},"windowStatus":{},"engineRuntime":{},"valetParkingMode":0}},"location":{"coord":{"lat":xx.xxxxxxxx,"lon":-xx.xxxxxxxxxx,"alt":458,"type":0,"altdo":0},"head":22,"speed":{"value":0,"unit":1},"accuracy":{"hdop":12,"pdop":21},"syncDate":{"utc":"20220213200357","offset":-8}},"financed":true,"financeRegistered":true,"linkStatus":0}}]}}

Raptor607 commented 2 years ago

*** Update: lock worked after downloading updating manifest file.

Lock not working on this version. Log follows:

2022-02-13 18:14:36 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] Action for lock is: VEHICLE_LOCK_ACTION.LOCK 2022-02-13 18:14:36 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] Calling Lock 2022-02-13 18:14:36 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/door/lock request 2022-02-13 18:14:37 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1003,"errorMessage":"Session Key is either invalid or expired"}} 2022-02-13 18:14:37 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: session invalid 2022-02-13 18:14:37 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got invalid session, attempting to repair and resend 2022-02-13 18:14:38 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] hyundai_kia_connect_api - Sign In Response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"}} 2022-02-13 18:14:38 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got session id e6c80b6f-7f41-41c1-b990-c7356d868d07 2022-02-13 18:14:38 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] old token:7ce37d03-48fc-4fb4-925f-575fc3b1a0ac, new token:e6c80b6f-7f41-41c1-b990-c7356d868d07 2022-02-13 18:14:38 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/rems/door/lock request 2022-02-13 18:14:38 DEBUG (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] got response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-13 18:14:38 ERROR (SyncWorker_4) [hyundai_kia_connect_api.KiaUvoAPIUSA] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}} 2022-02-13 18:14:38 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140464421724416] Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 30, in request_with_active_session_wrapper return func(*args, kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 70, in request_with_logging_wrapper raise AuthError hyundai_kia_connect_api.KiaUvoAPIUSA.AuthError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 190, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 668, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 705, 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 109, in async_lock_vehicle await self.hass.async_add_executor_job(self.vehicle_manager.lock, vehicle_id) File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, *self.kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 101, in lock return self.api.lock_action(self.token, self.get_vehicle(vehicle_id), VEHICLE_LOCK_ACTION.LOCK) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 483, in lock_action response = self.get_request_with_logging_and_active_session( File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 45, in request_with_active_session_wrapper response = func(args, kwargs) File "/usr/local/lib/python3.9/site-packages/hyundai_kia_connect_api/KiaUvoAPIUSA.py", line 72, in request_with_logging_wrapper raise RequestException requests.exceptions.RequestException

Raptor607 commented 2 years ago

Also just so I don't send you down any rabbit holes - please let me know when any changes require updating of files vs. just changing the version #.

cdnninja commented 2 years ago

1.29.3 may fix location. Those logs are exactly what I needed. As for lock that error occurs when the token is invalidated on the vehicle side. I am still thinking on how to fix that. It is a USA KIA specific issue. It should work next token refresh which is hourly.

Raptor607 commented 2 years ago

1.29.3 location seems to be working ( I say seems because there was a 1 hour period where the K5 showed as being at my work address, when it was actually here at home) Will keep an eye on this.

tazzytazzy commented 2 years ago

Has progress on this stalled? I really would like to add our 3 Kia's. Telly, K5, and EV6. :-)

cdnninja commented 2 years ago

It works in its current state. I think more testing is required before I push it as the main branch. I haven’t spent much time on it lately.

On Jun 17, 2022, at 10:32 PM, tazzytazzy @.***> wrote:

 Has progress on this stalled? I really would like to add our 3 Kia's. Telly, K5, and EV6. :-)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.

tazzytazzy commented 2 years ago

It works in its current state. I think more testing is required before I push it as the main branch. I haven’t spent much time on it lately.

Which branch is supporting this? I wish I could help you, but the code is all over my head. :\

cdnninja commented 2 years ago

I am trying to shift effort back to this now that fall has come! I made a release that HACS can access to help us test! So if you "re-download" the integration with the beta toggle on 2.0 will show. Any testing and issues opened is appreciated. New issues is ideal so we can nock them off. Once the volume of concerns drop we can promote this to GA.

Raptor607 commented 2 years ago

Welcome back! Running v2.0.1 now.

  1. Able to lock vehicles, but attempts to set climate/start vehicle via developer/call service page fail.

  2. Both Telluride and K5 are gas powered vehicles but AC & DC charging limit controls are displayed.

Logger: homeassistant.setup Source: setup.py:320 First occurred: 6:51:25 AM (1 occurrences) Last logged: 6:51:25 AM Unable to prepare setup for platform kia_uvo.climate: Platform not found (Exception importing custom_components.kia_uvo.climate)

Logger: homeassistant.loader Source: loader.py:739 First occurred: 6:51:25 AM (1 occurrences) Last logged: 6:51:25 AM Unexpected exception importing platform custom_components.kia_uvo.climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 722, in get_platform cache[full_name] = self._import_platform(platform_name) File "/usr/src/homeassistant/homeassistant/loader.py", line 739, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 879, in exec_module File "", line 1017, in get_code File "", line 947, in source_to_code File "", line 241, in _call_with_frames_removed File "/config/custom_components/kia_uvo/climate.py", line 216 self.vehicle.air_control_is_on = True IndentationError: unexpected indent

Logger: homeassistant.components.number Source: components/number/init.py:117 Integration: Number (documentation, issues) First occurred: 6:51:25 AM (3 occurrences) Last logged: 6:51:25 AM • custom_components.kia_uvo.number is setting deprecated attributes on an instance of NumberEntityDescription, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom integration author. • custom_components.kia_uvo.number::HyundaiKiaChargingLimitNumber is overriding deprecated methods on an instance of NumberEntity, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom integration author.

Logger: homeassistant.components.number Source: custom_components/kia_uvo/number.py:79 Integration: Number (documentation, issues) First occurred: 6:51:25 AM (2 occurrences) Last logged: 6:51:25 AM • Error adding entities for domain number with platform kia_uvo • Error while setting up kia_uvo platform for number Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 691, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 777, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/number/init.py", line 352, in state return self.value File "/config/custom_components/kia_uvo/number.py", line 79, in value return self._vehicle.ev_charge_limits.ac AttributeError: 'NoneType' object has no attribute 'ac'

Logger: homeassistant.components.number Source: components/number/init.py:249 Integration: Number (documentation, issues) First occurred: 6:51:25 AM (4 occurrences) Last logged: 6:51:25 AM Entity None (<class 'custom_components.kia_uvo.number.HyundaiKiaChargingLimitNumber'>) is using deprecated NumberEntity features which will be unsupported from Home Assistant Core 2022.10, please report it to the custom integration author.

jwefers commented 2 years ago

Ah, here is the current progress. In the next weeks, i will also shift to this official release and continue my efforts in contributing to the externalAPI branch