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

Integration: Canada Login Error #316

Closed Ramorous closed 2 years ago

Ramorous commented 2 years ago

Version:

Canada: Sorento

Unable To Integrate

This error originated from a custom integration.

Logger: homeassistant.config_entries Source: custom_components/kia_uvo/init.py:207 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 7:04:35 AM (1 occurrences) Last logged: 7:04:35 AM

Error setting up entry eb@bet....... for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/kia_uvo/init.py", line 218, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/init.py", line 207, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes This error originated from a custom integration.

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:81 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 7:04:35 AM (1 occurrences) Last logged: 7:04:35 AM

kia_uvo - Exception in update : 'result' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 56, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 133, in get_cached_vehicle_status response = response["result"]["status"] KeyError: 'result'

To Reproduce Steps to reproduce the behavior:

  1. Go to Integrations
  2. Click on Add Integration
  3. Search Kia
  4. Login
  5. See error

Expected behavior Integration

cdnninja commented 2 years ago

Can you confirm your mobile app is working and has a car working in it?

On Apr 14, 2022, at 5:10 AM, Ramorous @.***> wrote:

 Version:

Canada: Sorento

Unable To Integrate

This error originated from a custom integration.

Logger: homeassistant.config_entries Source: custom_components/kia_uvo/init.py:207 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 7:04:35 AM (1 occurrences) Last logged: 7:04:35 AM

Error setting up entry @.*** for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/kia_uvo/init.py", line 218, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/init.py", line 207, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes This error originated from a custom integration.

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:81 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: 7:04:35 AM (1 occurrences) Last logged: 7:04:35 AM

kia_uvo - Exception in update : 'result' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 56, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 133, in get_cached_vehicle_status response = response["result"]["status"] KeyError: 'result'

To Reproduce Steps to reproduce the behavior:

Go to Integrations Click on Add Integration Search Kia Login See error Expected behavior Integration

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

Ramorous commented 2 years ago

Yes, I can confirm that.

cdnninja commented 2 years ago

Please turn on the debug logging and post those logs. Debug is outlined on the read me.

On Apr 14, 2022, at 7:43 AM, Ramorous @.***> wrote:

 Yes, I can confirm that.

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

Ramorous commented 2 years ago

2022-04-14 10:16:05 DEBUG (MainThread) [custom_components.kia_uvo] kia_uvo - async_setup_entry started - <homeassistant.config_entries.ConfigEntry object at 0x7f755addd400> 2022-04-14 10:16:05 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Received token into Vehicle Object {'valid_until': '2022-04-15 06:03:17.490740', 'access_token': 'xxx', 'refresh_token': 'xxx', 'device_id': None, 'vehicle_name': 'Sorento', 'vehicle_id': 'vehicle_id==', 'vehicle_regid': None, 'vehicle_model': 'Sorento', 'vehicle_registration_date': 'missing', 'stamp': 'NoStamp'} 2022-04-14 10:16:05 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Refresh token started 2022-04-15 06:03:17.490740 2022-04-14 10:16:05.737804 False 2022-04-14 10:16:06 DEBUG (SyncWorker_4) [custom_components.kia_uvo.KiaUvoApiCA] kia_uvo - get_cached_vehicle_status response {'error': {'errorCode': '7101', 'errorDesc': "We're sorry, but your request could not be processed. Please try again. If the issue persists call Customer assistance at 1-877-542-2886."}, 'responseHeader': {'responseCode': 1}} 2022-04-14 10:16:08 ERROR (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Exception in update : 'result' - traceback: Traceback (most recent call last): File "/config/custom_components/kia_uvo/Vehicle.py", line 56, in update self.vehicle_data = await self.hass.async_add_executor_job( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoApiCA.py", line 133, in get_cached_vehicle_status response = response["result"]["status"] KeyError: 'result' 2022-04-14 10:16:08 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry eb@mydomain.ca for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/kia_uvo/init.py", line 218, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/init.py", line 207, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

cdnninja commented 2 years ago

I just removed and re-added on my 2019 Kia Sorento in Canada and it works. What year is the car? Can you check status such as doors in the app without issue? Is your UVO subscription active?

cdnninja commented 2 years ago

Also what version of HA are you running and on what OS?

Ramorous commented 2 years ago

Kia connect works for my 2020 Sorento without issue. This worked prior to me putting this in. I did fully remove the add-on and restart etc....

System Health

version core-2022.4.4
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.9
os_name Linux
os_version 5.10.108
arch x86_64
timezone America/Toronto
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4937 Installed Version | 1.24.5 Stage | running Available Repositories | 1099 Downloaded Repositories | 9
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | April 21, 2022, 8:00 PM relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | us-east-1-3.ui.nabu.casa can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 7.6 -- | -- update_channel | stable supervisor_version | supervisor-2022.04.0 docker_version | 20.10.9 disk_total | 31.3 GB disk_used | 4.6 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | SSH & Web Terminal (10.1.1), MariaDB (2.4.0), Studio Code Server (4.2.0), Node-RED (11.1.1), Home Assistant Google Drive Backup (0.106.2)
Dashboards dashboards | 2 -- | -- resources | 1 views | 1 mode | storage
cdnninja commented 2 years ago

Which worked prior to putting this in? Did it work previously and stopped? Which add on are you referencing? Kia_uvo is an integration not an add on.

It looks like Kia servers don't like our query to access the cars. I would think to debug this we would need you to watch what query they send to the servers via a web browser. This can be done via: https://github.com/fuatakgun/kia_uvo/wiki/How-to-sniff-API-via-MS-Edge

once we have that I can give you a line that will add something to the logs showing what we send. In theory it should be the same.

Ramorous commented 2 years ago

It's an integration, sorry for not using the right term. But it worked for about 5 days then stopped reporting. That's when I saw the errors and just tried to log back in, remove and re-add, all my usual troubleshooting steps for an infrastructure guy like me.

cdnninja commented 2 years ago

Gotcha. For some reason Kia doesn't like the request we are sending them. Please sniff the traffic using a web browser. You are looking for the payload hitting "lstvhclsts" which is the cached vehicle status.

Add_LOGGER.debug(f"{DOMAIN} - get_cached_vehicle_status headers {headers}")

to the kiauvoapica.py file on line 129. In theory our headers should roughly match your sniffed headers.

Ramorous commented 2 years ago

I was able to resolve the issue by removing the integration and leaving it out. Logged in and it failed (bad username/password) then it worked. Go figure.