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
455 stars 89 forks source link

Canada - Unable to update location #906

Open hurricane7719 opened 4 months ago

hurricane7719 commented 4 months ago

Region and Brand of car - Canada, Genesis GV60

Version of the integration - 2.25.2

Describe the bug Location is never provided. Always lists as "Unknown". Debug logs result in error that engine has not been started in recent days or vehicle has poor coverage. But location can be retrieved via the app and other data gets updated

Debug logs if an error occurred 2024-07-05 14:20:31.706 DEBUG (SyncWorker_16) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Service status data {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'maintenanceInfo': {'msopServiceOdometer': 102.4, 'msopServiceOdometerUnit': 1, 'mtspServiceDate': '20240329', 'imatServiceOdometer': 12102.0, 'imatServiceOdometerUnit': 1, 'mtitServiceDate': '20250329', 'currentOdometer': 6428.0, 'currentOdometerUnit': 1, 'serviceOdometerDuration': 12000.0, 'serviceDaysDuration': 365, 'serviceMonthsThreshold': 12}}} 2024-07-05 14:20:31.886 DEBUG (SyncWorker_16) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received Pin validation response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'pAuth': 'gHOdcPzPdgMPEmEVcthpUGoNzggyOCTa'}} 2024-07-05 14:22:32.132 DEBUG (SyncWorker_16) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Vehicle Location {'error': {'errorCode': '6504', 'errorDesc': 'We cannot process your request. Please check, as it appears your engine has not been started in recent days or your vehicle is in a poor network coverage area.'}, 'responseHeader': {'responseCode': 1, 'responseDesc': 'Failure'}} 2024-07-05 14:22:32.132 WARNING (SyncWorker_16) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get vehicle location failed 2024-07-05 14:22:32.307 DEBUG (SyncWorker_16) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Received get_charge_limits: {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': [{'plugType': 0, 'level': 80, 'dte': {'rangeByFuel': {'gasModeRange': {}, 'evModeRange': {'value': 345.0, 'unit': 1}, 'totalAvailableRange': {'value': 345.0, 'unit': 1}}, 'type': 1}}, {'plugType': 1, 'level': 80, 'dte': {'rangeByFuel': {'gasModeRange': {}, 'evModeRange': {'value': 345.0, 'unit': 1}, 'totalAvailableRange': {'value': 345.0, 'unit': 1}}, 'type': 1}}]} 2024-07-05 14:22:32.310 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 121.361 seconds (success: True) 2024-07-05 14:52:31.950 DEBUG (SyncWorker_3) [hyundai_kia_connect_api.VehicleManager] hyundai_kia_connect_api - Time differential in seconds: 2294.950294

To Reproduce

Expected behavior

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Additionally, the logic of using the vehicle odometer to determine is the location should be updated is somewhat flawed. The vehicle appears to only infrequently respond with an updated odometer value. Perhaps only after engine shutdown.

cdnninja commented 4 months ago

Someone will need to sniff the traffic to see what changed for the api or genesis.

I no longer own a car so can't do this.

As for the odometer flawed I don't see another option. We can't pull location on each poll as it will kill the battery and max out api calls.

Engine on off may be missed on polling interval. It also isn't updated on cached any different than odometer.

I'm open to changes though if you can test a better way. Unfortunately no perfect world.

hurricane7719 commented 4 months ago

Fumbled through this thanks to the instructions on the Wiki. Seems like the request URL is different that the current code in KiaUvoApiCA.py.

Not sure if this applies across all brands or is only specific to Genesis

I'd try my way through updating the code, but don't have much python or GitHub experience. I'm worried I'd break more than I'd fix

Query POST https://genesisconnect.ca/tods/api/evc/fme HTTP/2 host: genesisconnect.ca language: 0 offset: -4 from: SPA brand: G vehicleid: nWgiRNWQiYYk0hki8p65Mg== accesstoken: pauth: content-type: application/json content-length: 0 accept-encoding: gzip user-agent: okhttp/3.14.9

Response

HTTP/1.1 200 Server: nginx Date: Mon, 08 Jul 2024 14:54:50 GMT Content-Type: application/json;charset=UTF-8 X-OneAgent-JS-Injection: true Access-Control-Allow-Origin: * Access-Control-Allow-Methods: POST, GET Access-Control-Max-Age: 3600 Access-Control-Allow-Headers: x-requested-with transactionId: 2361093743 language: 0 offset: -8 transactionDate: Mon, 08 Jul 2024 14:54:50 GMT Access-Control-Expose-Headers: transactionId, transactionDate, offset, language Server-Timing: dtSInfo;desc="0", dtRpid;desc="-664472492" Set-Cookie: dtCookie=v_4_srv_6_sn_DE73EC3BA37E782B096AFC44508F682F_perc_100000_ol_0_mul_1_app-3A8d314cac062f2b84_0; Path=/; Domain=.genesisconnect.ca X-XSS-Protection: 1; mode=block Content-Length: 413

{"responseHeader":{"responseCode":0,"responseDesc":"Success"},"result":{"gpsDetail":{"coord":{"lat":45.155266,"lon":-75.430116,"alt":0.0,"type":0},"head":202,"speed":{"value":0,"unit":0},"accuracy":{"hdop":119,"pdop":225},"time":"20240708145449"},"drvDistance":{"rangeByFuel":{"gasModeRange":{"value":0.0,"unit":1},"evModeRange":{"value":368.0,"unit":1},"totalAvailableRange":{"value":368.0,"unit":1}},"type":2}}}