Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
426 stars 85 forks source link

Commands stop working after the first few hours of initial setup #436

Closed terminusxx closed 1 year ago

terminusxx commented 1 year ago

Region and Brand of car USA, Hyundai Tuscon 2022

Describe the bug For the first hour after initial setup commands work with the car. After an hour or so commands no longer work but sensors continue to update correctly.

Debug logs if an error occurred

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:81 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: November 2, 2022 at 7:49:17 PM (103 occurrences) Last logged: 7:56:14 AM

kia_uvo - Exception in update : 'vehicleStatus' - 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.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/HyundaiBlueLinkAPIUSA.py", line 172, in get_cached_vehicle_status vehicle_status["vehicleStatus"] = response["vehicleStatus"] KeyError: 'vehicleStatus'

Logger: custom_components.kia_uvo.Vehicle Source: custom_components/kia_uvo/Vehicle.py:91 Integration: Kia Uvo / Hyundai Bluelink (documentation, issues) First occurred: November 2, 2022 at 7:49:47 PM (61 occurrences) Last logged: 7:56:14 AM

kia_uvo - Exception in update : 'vehicleStatus' - 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.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/HyundaiBlueLinkAPIUSA.py", line 172, in get_cached_vehicle_status vehicle_status["vehicleStatus"] = response["vehicleStatus"] KeyError: 'vehicleStatus'

Expected behavior A continued ability to send commands to the car.

Additional context I've tried reinstalling the component, using different account and nothing has worked.

cdnninja commented 1 year ago

Based on the error you are on the 1.8 branch?

How often do you see this error? It is stating it can't update the sensors. So since you say sensors still update I would assume this is occasional.

Does it recover on its own or do you need to restart the integration?

cdnninja commented 1 year ago

Also you say commands no longer work? Do you mean services? If so please provide that log.

terminusxx commented 1 year ago

Yes, I was on the 1.8 branch, those errors occurred whenever I would try using a service and it would not work until I deleted the car and readded it. It would then work for the first few hours after readding but after that all services would throw that error, but the car would continue to update the sensors.

I've just installed the latest beta release 2.0.26 and unlock and lock service works but also throws this error:

2022-11-12 14:53:23.001 WARNING (SyncWorker_5) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Unable to get vehicle location: {'errorSubCode': 'HT_533', 'systemName': 'HATA', 'functionName': 'findMyCar', 'errorSubMessage': 'HATA findMyCar service failed while performing the operation FindMyCar', 'errorMessage': 'Unable to send your request because a previous request is pending. Please wait and try again later.', 'errorCode': 502, 'serviceName': 'FindMyCar'} 2022-11-12 14:53:23.004 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.454 seconds (success: True)

Should I stay on the beta branch 2.0.26 or do you want to troubleshoot the 1.8 version?

cdnninja commented 1 year ago

I am thinking 2.x branch.

The error you showed simple is saying something else is currently running. Any service call right before that one? Or any call from your mobile app?

terminusxx commented 1 year ago

No calls from anywhere else or before, is it trying to get the location while it's sending the lock/unlock service call? Because the lock/unlock call goes through fine despite the error.

cdnninja commented 1 year ago

I'm a confused. You are saying no other service call yet your saying a lock command was issued? The log is a standard location update failing. If a lock command by chance was issued right before hand it could conflict.

terminusxx commented 1 year ago

The only service call that I made was the lock command. I'm assuming the integration made the call to get the car's location at the same time, but I only ever sent the lock command. To be clear, this error occurs any time I make a service call

cdnninja commented 1 year ago

Okay. Gotcha that helps. I will go through the logic. I bet we are trying to update state right after the lock command to show it was successful. Maybe not the best way to do it.

Really appreciate the detail. I'll take a look and get back to you.

terminusxx commented 1 year ago

No problem, I appreciate the great work you guys do. If you need me to run any test builds or try things I'm happy to help as well.

cdnninja commented 1 year ago

I can't find a reference to any logic that would cause this second update. Could you enable debug logs which is outlined at the bottom of this: https://github.com/fuatakgun/kia_uvo/tree/v2.0

and post the logs from the lock all the way to the error? As well what is your refresh and force update set to?

terminusxx commented 1 year ago

Refresh is 30 and Force is 240 2022-11-12 17:45:33.907 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Action for lock is: VEHICLE_LOCK_ACTION.LOCK 2022-11-12 17:45:33.907 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Calling Lock 2022-11-12 17:45:34.384 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Received lock_action response status code: 200 2022-11-12 17:45:34.384 DEBUG (SyncWorker_0) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Received lock_action response: 2022-11-12 17:45:34.387 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.VehicleManager] time diff - 9252.387208 2022-11-12 17:45:34.387 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - using API headers: {'content-type': 'application/json;charset=UTF-8', 'accept': 'application/json, text/plain, */*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36', 'host': 'api.telematics.hyundaiusa.com', 'origin': 'https://api.telematics.hyundaiusa.com', 'referer': 'https://api.telematics.hyundaiusa.com/login', 'from': 'SPA', 'to': 'ISS', 'language': '0', 'offset': '-10', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'same-origin', 'refresh': 'false', 'encryptFlag': 'false', 'brandIndicator': 'H', 'gen': '2', 'client_id': '*****', 'clientSecret': '*****', 'username': '*****@gmail.com', 'accessToken': '*****', 'vin': '*****', 'blueLinkServicePin': '*****', 'vehicleId': '**********', 'registrationId': '**********', 'APPCLOUD-VIN': '*****'} 2022-11-12 17:45:34.912 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - get_cached_vehicle_status response {'hataTID': '7o8ATdsiSV-hICaKsird0Q', 'vehicleStatus': {'dateTime': '2022-11-13T01:11:22Z', 'acc': False, 'fuelLevel': 78, 'defrostStatus': 'false', 'transCond': True, 'doorLockStatus': 'true', 'doorOpen': {'frontRight': 0, 'frontLeft': 0, 'backLeft': 0, 'backRight': 0}, 'washerFluidStatus': False, 'battery': {'powerAutoCutMode': 2, 'batSignalReferenceValue': {'batWarning': 65}, 'batSoc': 81, 'batState': 0, 'sjbDeliveryMode': 1}, 'seatHeaterVentInfo': {'rlSeatHeatState': 2, 'drvSeatHeatState': 2, 'rrSeatHeatState': 2, 'astSeatHeatState': 2}, 'vehicleLocation': {'coord': {'alt': 61.3, 'lon': -154.983079, 'type': 0, 'lat': 19.602371}}, 'ign3': False, 'ignitionStatus': 'false', 'lowFuelLight': False, 'sideBackWindowHeat': 0, 'dte': {'unit': 3, 'value': 0.0}, 'engine': False, 'hoodOpen': False, 'breakOilStatus': False, 'vehicleMovementHis': True, 'airConditionStatus': 'false', 'smartKeyBatteryWarning': False, 'steerWheelHeat': 0, 'trunkOpen': False, 'doorLock': True, 'engineRuntime': {'unit': 1, 'value': 0}, 'airCtrlOn': False, 'airTemp': {'unit': 1, 'hvacTempType': 1, 'value': '0EH'}, 'evStatus': {'valueDiff': 0, 'remainTime2': {'etc3': {'unit': 1, 'value': 0}, 'etc2': {'unit': 1, 'value': 0}, 'atc': {'unit': 1, 'value': 0}}, 'evIgnitionStatus': False, 'inletLockModeStatus': 0, 'batteryPlugin': 2, 'timeDiff': 0, 'batteryCharge': False, 'batteryStatus': 100, 'remainTime': [{'unit': 1, 'value': 0}], 'drvDistance': [{'rangeByFuel': {'gasModeRange': {'unit': 3, 'value': 64752.0}, 'totalAvailableRange': {'unit': 3, 'value': 239.0}, 'evModeRange': {'unit': 3, 'value': 1023.0}}, 'type': 1}], 'reservChargeInfos': {'targetSOClist': [{'rangeByFuel': {'gasModeRange': {'unit': 3, 'value': 64752}, 'totalAvailableRange': {'unit': 3, 'value': 239}, 'evModeRange': {'unit': 3, 'value': 1023}}, 'plugType': 1, 'targetSOClevel': 100, 'type': 1}], 'reservChargeInfo': {'dateTime': '2022/11/12T19:45:34Z', 'reservChargeInfoDetail': {'reservChargeSet': False, 'reservEndTime': '', 'reservFatcSet': {'defrost': False, 'airTemp': None, 'airCtrl': 0}, 'reservInfo': {'time': {'timeSection': 0, 'time': '1200'}, 'day': [1, 5, 6]}}}, 'reservFlag': 0, 'reserveChargeInfo2': {'reservChargeInfoDetail': {'reservChargeSet': False, 'reservEndTime': '', 'reservFatcSet': {'defrost': False, 'airTemp': None, 'airCtrl': 0}, 'reservInfo': {'time': {'timeSection': 0, 'time': '1200'}, 'day': [9]}}}, 'offpeakPowerInfo': {'offPeakPowerFlag': 0, 'offPeakPowerTime1': {'startTime': {'timeSection': 0, 'time': '0800'}, 'endTime': {'timeSection': 1, 'time': '0400'}}}}}, 'lampWireStatus': {'headLamp': {'rightBifuncLamp': False, 'headLampStatus': False, 'leftBifuncLamp': False}, 'stopLamp': {'stopLampStatus': False, 'rightLamp': False, 'leftLamp': False}, 'turnSignalLamp': {'rightRearLamp': False, 'turnSignalLampStatus': False, 'rightFrontLamp': False, 'leftRearLamp': False, 'leftFrontLamp': False}}, 'sleepModeCheck': True, 'defrost': False, 'tirePressureLamp': {'tirePressureWarningLampRearLeft': 0, 'tirePressureWarningLampFrontLeft': 0, 'tirePressureWarningLampFrontRight': 0, 'tirePressureWarningLampAll': 0, 'tirePressureWarningLampRearRight': 0}, 'trunkOpenStatus': 'false', 'engineOilStatus': False}} 2022-11-12 17:45:35.334 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Get Vehicles Response {"enrolledVehicleDetails":[{"packageDetails":[{"assetNumber":"*****","displayCategory":"Connected Care","packageId":"*****","term":"33","renewalDate":"20250213000000","packageType":"Connected Care","startDate":"20220517000000"},{"assetNumber":"*****","displayCategory":"Remote","packageId":"*****","term":"33","renewalDate":"20250213000000","packageType":"Remote","startDate":"20220517000000"}],"driverDetails":[{"driverAddressDetails":[{"city":"*****","postalCode":"*****","type":"PRIMARY","region":"HI"}],"driver":{"accountId":"*****","firstName":"*****","lastName":"*****","phonesOptIn":[],"tncId":"22","loginId":"**********@gmail.com","preferredDealerCode":"HI015","driverUserProfile":"N","phones":[],"idmId":"*****","userId":"**********@gmail.com","email":"**********@gmail.com"}}],"vehicleDetails":{"svrStatus":"NONE","dynamicBurgerMenu":"https://owners.hyundaiusa.com/content/dam/hyundai/us/myhyundai/image/2022/tucson-phev/sel/exterior/base/deep-sea/Dashboard-01.png/jcr:content/renditions/cq5dam.thumbnail.105.68.png","remoteStartWakeupDays":"seven","enrollmentDate":"*****","svdDay":"16","trim":"SEL","modelCode":"TUCSON PLUGIN HYBRID","ubiCapabilityInd":"Y","vin":"*****","enrollmentId":"*****","sideMirrorHeatCapable":"YES","ownersuccession":"1","odometer":"9073","nickName":"2022 TUCSON PLUGIN HYBRID","defaultBurgerMenu":"https://owners.hyundaiusa.com/content/dam/hyundai/us/myhyundai/image/2022/tucson-phev/sel/exterior/base/default/Dashboard-01.png/jcr:content/renditions/cq5dam.thumbnail.105.68.png","evStatus":"P","modelYear":"2022","steeringWheelHeatCapable":"YES","defaultDashboard":"https://owners.hyundaiusa.com/content/dam/hyundai/us/myhyundai/image/2022/tucson-phev/sel/exterior/base/default/Dashboard-01.png","vehicleGeneration":"2","starttype":"BUTTON","sapColorCode":"PS8","bluelinkEnabled":true,"odometerUpdateDate":"20221112151011","fatcAvailable":"Y","color":"BLUE","maintSyncCapable":"YES","brandIndicator":"H","deviceStatus":"ENROLLED","setOffPeak":"1","mapProvider":"HERE","generalBurgerMenu":"https://owners.hyundaiusa.com/content/dam/hyundai/us/myhyundai/image/2022/tucson-phev/general/exterior/base/default/Dashboard-01.png/jcr:content/renditions/cq5dam.thumbnail.105.68.png","interiorColor":"NNB","accessoryCode":"D-AUDIO2","nadid":"*****","mit":"7500","regid":"**********","blueLink":"Y","waypointInd":"NO","billingInd":"MONTHLY","seatConfigurations":{"seatConfigs":[{"heatingCapable":"YES","ventCapable":"NO","supportedLevels":"2,6,7,8","seatLocationID":"1"},{"heatingCapable":"YES","ventCapable":"NO","supportedLevels":"2,6,7,8","seatLocationID":"2"}]},"dynamicDashboard":"https://owners.hyundaiusa.com/content/dam/hyundai/us/myhyundai/image/2022/tucson-phev/sel/exterior/base/deep-sea/Dashboard-01.png","imat":"7500","additionalVehicleDetails":{"combinedHeatSettingsEnable":"Y","temperatureRange":"false","tmuSleepMode":"No","enableHCAModule":"Y","hyundaiHome":"N","wifiHotspotCapable":"N","remoteLockConsentForRemoteStart":"Yes","calendarVehicleSyncEnable":"No","tmuSleepInMin":154.18333333333334,"dkEnrolled":"N","icpAvntCapable":"N","icpAACapable":"N","dkType":"","enableRoadSideAssitanceAAAModule":"Y","evAlarmOptionInfo":"No","remoteLockConsentForRemoteStartCapable":"Yes","mapOtaAccepted":"N","icpCPCapable":"N","dkCapable":"N","enableValetActivate":"N","energyConsoleCapable":"No"},"transmissiontype":"AUTO","bluelinkEnrolled":true,"rearWindowHeatCapable":"YES","preferredDealerCode":"HI015","hmaModel":"NX4P","series":"TUCSON PLUGIN HYBRID","enrollmentStatus":"ACTIVE","generalDashboard":"https://owners.hyundaiusa.com/content/dam/hyundai/us/myhyundai/image/2022/tucson-phev/general/exterior/base/default/Dashboard-01.png","userprofilestatus":"NA"},"roleDetails":[{"roleCode":"OWN","roleName":"OWNER"},{"roleCode":"SUB","roleName":"SUBSCRIBER"}],"responseHeaderMap":{}}],"addressDetails":[{"city":"*****","street":"*****","postalCode":"*****","type":"PRIMARY","region":"HI"}],"user":{"lastName":"*****","phonesOptIn":[{"number":"*****","primaryPhoneIndicator":"YES","fccOptIn":"NO","type":"MOBILE"}],"loginId":"*****@gmail.com","prefix":"Mrs","tncFlag":"N","phones":[{"number":"*****","type":"cell","order":1}],"userId":"*****@gmail.com","notificationEmail":"*****@gmail.com","accountId":"*****","firstName":"*****","additionalUserDetails":{"userProfileUpdate":"N","timezoneOffset":-10,"billingAccountNumber":"*****","appRating":"N","timezoneAbbr":"HST","otaAcceptance":"N","telematicsPhoneNumber":"*****"},"idmId":"*****","email":"*****@gmail.com"}} 2022-11-12 17:45:35.461 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Get Vehicle Location {'errorSubCode': 'HT_533', 'systemName': 'HATA', 'functionName': 'findMyCar', 'errorSubMessage': 'HATA findMyCar service failed while performing the operation FindMyCar', 'errorMessage': 'Unable to send your request because a previous request is pending. Please wait and try again later.', 'errorCode': 502, 'serviceName': 'FindMyCar'} 2022-11-12 17:45:35.461 WARNING (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Unable to get vehicle location: {'errorSubCode': 'HT_533', 'systemName': 'HATA', 'functionName': 'findMyCar', 'errorSubMessage': 'HATA findMyCar service failed while performing the operation FindMyCar', 'errorMessage': 'Unable to send your request because a previous request is pending. Please wait and try again later.', 'errorCode': 502, 'serviceName': 'FindMyCar'} 2022-11-12 17:45:35.465 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - last_updated_at - before 20221113011122 2022-11-12 17:45:35.465 DEBUG (SyncWorker_6) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - last_updated_at - after 2022-11-13 01:11:22+00:00 2022-11-12 17:45:35.466 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 1.081 seconds (success: True)

terminusxx commented 1 year ago

So I think I have an idea what's causing the original problem. I got this error message a few hours ago:

[hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Unable to get vehicle location: {'errorSubCode': 'C400_1', 'systemName': 'IDM', 'functionName': 'validatePIN', 'errorSubMessage': 'Missing Fields: blueLinkServicePin or pinToken', 'errorMessage': 'Please check to see that all required fields are populated and try again.', 'errorCode': 400, 'serviceName': 'CheckCustomerUserPin'}

I looked further up and saw this, I removed all the other data because it contained so much sensitive info

hyundai_kia_connect_api - using API headers: 'blueLinkServicePin': None,

blueLinkServicePin is showing a value of None when earlier during the lock command it had the correct pin. Is it possible it's trying to refresh the token with the default pin value? Because in my homeassitant conf file the correct pin is still there.

rerpires commented 1 year ago

Hi,

I'm having the same issue, I do reload HA and it's fine, after a couple of hours the entity becames unavailable and shows no info.

Running 2.0.27

EU, Kia E-Niro

This error originated from a custom integration.

Logger: custom_components.kia_uvo.coordinator Source: custom_components/kia_uvo/coordinator.py:102 Integration: Hyundai / Kia Connect (documentation, issues) First occurred: 06:02:26 (4 occurrences) Last logged: 09:03:38

Unexpected error fetching kia_uvo data: 'vehicleStatusInfo' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/kia_uvo/coordinator.py", line 102, in _async_update_data await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 77, in check_and_force_update_vehicles self.force_refresh_vehicle_state(vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state self.api.force_refresh_vehicle_state(self.token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state state = self._get_forced_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 420, in _get_forced_vehicle_state return response["resMsg"]["vehicleStatusInfo"] KeyError: 'vehicleStatusInfo'

Let me know if you need further information.

fuatakgun commented 1 year ago

this issue is probably related to expired or invalid token, happening both on EU and USA

rerpires commented 1 year ago

I'm confused. which token ?

fuatakgun commented 1 year ago

integration is supposed to take care internal refresh of tokens, in EU, it is valid only for 24 hours, in US, it was way shorter. you can see below, we are refreshing the token. https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/master/hyundai_kia_connect_api/VehicleManager.py#L92

rerpires commented 1 year ago

integration is supposed to take care internal refresh of tokens, in EU, it is valid only for 24 hours, in US, it was way shorter. you can see below, we are refreshing the token. https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/master/hyundai_kia_connect_api/VehicleManager.py#L92

What can I do to solve it ? any idea ?

cdnninja commented 1 year ago

Hi,

I'm having the same issue, I do reload HA and it's fine, after a couple of hours the entity becames unavailable and shows no info.

Running 2.0.27

EU, Kia E-Niro

This error originated from a custom integration.

Logger: custom_components.kia_uvo.coordinator Source: custom_components/kia_uvo/coordinator.py:102 Integration: Hyundai / Kia Connect (documentation, issues) First occurred: 06:02:26 (4 occurrences) Last logged: 09:03:38

Unexpected error fetching kia_uvo data: 'vehicleStatusInfo' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/kia_uvo/coordinator.py", line 102, in _async_update_data await self.hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 77, in check_and_force_update_vehicles self.force_refresh_vehicle_state(vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/VehicleManager.py", line 87, in force_refresh_vehicle_state self.api.force_refresh_vehicle_state(self.token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 185, in force_refresh_vehicle_state state = self._get_forced_vehicle_state(token, vehicle) File "/usr/local/lib/python3.10/site-packages/hyundai_kia_connect_api/KiaUvoApiEU.py", line 420, in _get_forced_vehicle_state return response["resMsg"]["vehicleStatusInfo"] KeyError: 'vehicleStatusInfo'

Let me know if you need further information.

This is a separate issue. I think you are seeing this: https://github.com/fuatakgun/kia_uvo/issues/424 This thread is for USA cars.

cdnninja commented 1 year ago

So I think I have an idea what's causing the original problem. I got this error message a few hours ago:

[hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Unable to get vehicle location: {'errorSubCode': 'C400_1', 'systemName': 'IDM', 'functionName': 'validatePIN', 'errorSubMessage': 'Missing Fields: blueLinkServicePin or pinToken', 'errorMessage': 'Please check to see that all required fields are populated and try again.', 'errorCode': 400, 'serviceName': 'CheckCustomerUserPin'}

I looked further up and saw this, I removed all the other data because it contained so much sensitive info

hyundai_kia_connect_api - using API headers: 'blueLinkServicePin': None,

blueLinkServicePin is showing a value of None when earlier during the lock command it had the correct pin. Is it possible it's trying to refresh the token with the default pin value? Because in my homeassitant conf file the correct pin is still there.

Yes. I think you are correct. Really good to know we are actually sending None for some reason. Now I take one look through the code and haven't seen the mistake yet - but I bet it exists.

cdnninja commented 1 year ago

Found the issue causing pin missing error. This PR will resolve: https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/pull/124. Please try 2.0.29 and let me know if resolved.

terminusxx commented 1 year ago

No more issues with refreshing tokens! Bad news is that lock entity status isnt changing after successful locks or unlocks:

2022-11-14 19:50:50.256 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Action for lock is: VEHICLE_LOCK_ACTION.UNLOCK 2022-11-14 19:50:50.256 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Calling unlock 2022-11-14 19:50:50.875 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Received lock_action response status code: 200 2022-11-14 19:50:50.875 DEBUG (SyncWorker_9) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - Received lock_action response: 2022-11-14 19:50:50.881 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.VehicleManager] time diff - 1746.881655 2022-11-14 19:50:51.292 DEBUG (SyncWorker_2) [hyundai_kia_connect_api.HyundaiBlueLinkAPIUSA] hyundai_kia_connect_api - get_cached_vehicle_status response {'hataTID': 'TGoysCbySf6pBdtQFWta_w', 'vehicleStatus': {'dateTime': '2022-11-15T05:27:24Z', 'acc': False, 'fuelLevel': 75, 'defrostStatus': 'false', 'transCond': True, 'doorLockStatus': 'true',

If I do a force refresh service call to update the data I finally get

'doorLockStatus': 'false',

But the lock entity status never changes. This could be a bug from changing versions and restarting so ill test over the next few days. I assume the api is just giving me old, cached data, so we maybe we should change the state of the lock based on a successful unlock or lock call? Should I make a new issue for this instead of having it here?

cdnninja commented 1 year ago

Yes let's make a new issue. Items like that get a bit harder to deal with since we are somewhat at the mercy of the api. I personally am not comfortable displaying locked without it actually coming from the api. Just in case it failed.

cdnninja commented 1 year ago

I opened this as it is related: https://github.com/fuatakgun/kia_uvo/issues/440

One thing I noticed in canada and it has been this way since 1.X is that if unlock the car from the integration it never reports back. I think it is because the car seems to only temporarily unlock. It will lock again after waiting automatically.

If I lock the car from the integration it reports correctly shortly after.

terminusxx commented 1 year ago

You're right I found this in a Blue Link manual, how annoying.

Please note: After Blue Link unlocks the doors, they will remain unlocked for only 30 seconds. This auto relock is designed to enhance vehicle security by relocking the doors if the doors are not opened within 30 seconds.

cdnninja commented 1 year ago

In theory we could do this in HA where if unlock is sent it shows unlocked and reverts in 30 seconds. However I don't know if all regions and models do this so not something I want to try do for a minor issue. I am thinking we close this issue if you are good! Feel free to open new issues for anything else you find! Thanks for the help on this!