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

Fails to set up. Check logs error #208

Closed pageb018 closed 2 years ago

pageb018 commented 2 years ago

Please check Services, Known Bug / Issues and Troubleshooting over here first: https://github.com/fuatakgun/kia_uvo/blob/master/README.md Region and Brand of car

Describe the bug When adding the integration to home assistant, I see the "Failed to set up, Check the logs" error. No entities are added.

Debug logs if an error occurred

Please see the log messages that seems to be causing the failure.

Error setting up entry brian@pagefamily.org for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/kia_uvo/__init__.py", line 217, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/__init__.py", line 206, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

kia_uvo - Exception in update : 'stateOfCharge' - 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 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoAPIUSA.py", line 264, in get_cached_vehicle_status "batSoc": vehicle_status["batteryStatus"]["stateOfCharge"], KeyError: 'stateOfCharge'

To Reproduce Steps to reproduce the behavior:

  1. add via HACS
  2. Add as intergration
  3. Choose USA and Kia as country and options.
  4. Add username and pw
  5. Submit

Screen Shot 2021-12-17 at 9 12 23 AM

Screen Shot 2021-12-17 at 9 23 27 AM

Screen Shot 2021-12-17 at 9 48 46 AM

Expected behavior The integration should be added and entities should be created.

fuatakgun commented 2 years ago

We need debug logs, only error log is not enough to understand this

pageb018 commented 2 years ago

@fuatakgun Ok. Give me a moment.

pageb018 commented 2 years ago

2021-12-17 10:15:39 DEBUG (MainThread) [custom_components.kia_uvo] kia_uvo - async_setup_entry started - <homeassistant.config_entries.ConfigEntry object at 0x7fe0cf86af60> 2021-12-17 10:15:39 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Received token into Vehicle Object {'valid_until': '2021-12-17 10:53:54.718402', 'access_token': '6dca957f-223e-4fbe-bffe-0f2105cc7133', 'refresh_token': None, 'device_id': 'KNDPRCA64M7847948', 'vehicle_name': 'Kia', 'vehicle_id': '847948', 'vehicle_regid': '***', 'vehicle_model': 'SPORTAGE', 'vehicle_registration_date': 'missing', 'stamp': 'NoStamp'} 2021-12-17 10:15:39 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Refresh token started 2021-12-17 10:53:54.718402 2021-12-17 10:15:39.290384 False 2021-12-17 10:15:39 DEBUG (SyncWorker_7) [custom_components.kia_uvo.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/cmm/gvi request with {'vehicleConfigReq': {'airTempRange': '0', 'maintenance': '0', 'seatHeatCoolOption': '0', 'vehicle': '1', 'vehicleFeature': '0'}, 'vehicleInfoReq': {'drivingActivty': '0', 'dtc': '1', 'enrollment': '1', 'functionalCards': '0', 'location': '1', 'vehicleStatus': '1', 'weather': '0'}, 'vinKey': ['9d623024-04b0-4c39-8230-5bfaa94ece47']} 2021-12-17 10:15:40 DEBUG (SyncWorker_7) [custom_components.kia_uvo.KiaUvoAPIUSA] got response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleInfoList":[{"vinKey":"*****","vehicleConfig":{"vehicleDetail":{"vehicle":{"vin":"KNDPRCA64M7847948","trim":{"modelYear":"2021","salesModelCode":"45482","optionGroupCode":"010","modelName":"SPORTAGE","factoryCode":"D9","projectCode":"QL","trimName":"SX-P","driveType":"2","transmissionType":"1","ivrCategory":"5","btSeriesCode":"4"},"telematics":1,"mileage":"11665.9","mileageSyncDate":"20211216143655","exteriorColor":"STEEL GRAY","exteriorColorCode":"KLG","fuelType":1,"invDealerCode":"NJ074","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":"2021-sportage-sx-p-klg.png","imagePath":"/content/dam/kia/us/owners/image/vehicle-app/2021/sportage/sx-p/","imageType":"1","imageSize":{"length":"100","width":"100","uom":0}}],"device":{"launchType":"0","swVersion":"QL21.USA.SOP.V115.200325.STD_H","telematics":{"generation":"3","platform":"1","tmsCenter":"1","billing":true},"versionNum":"GASOLINE","headUnitType":"0","hdRadio":"X40HA","ampType":"NA","modem":{"meid":"354522081645629","mdn":"6574268216","iccid":"89148000005704994995"},"headUnitName":"avn5em","bluetoothRef":"10","headUnitDesc":"AVN5.0"}},"billingPeriod":{"freeTrial":{"value":12,"unit":0},"freeTrialExtension":{"value":12,"unit":1},"servicePeriod":{"value":60,"unit":1}}},"lastVehicleInfo":{"vehicleNickName":"Kia","preferredDealer":"NJ074","customerType":0,"enrollment":{"provStatus":"4","enrollmentStatus":"1","enrollmentType":"0","registrationDate":"20200829","expirationDate":"20210829","expirationMileage":"100000","freeServiceDate":{"startDate":"20200829","endDate":"20210829"}},"activeDTC":{"dtcActiveCount":"0"},"vehicleStatusRpt":{"statusType":"2","reportDate":{"utc":"20211217151540","offset":-8},"vehicleStatus":{"climate":{"airCtrl":false,"defrost":false,"airTemp":{"value":"LOW","unit":1},"heatingAccessory":{"steeringWheel":0,"sideMirror":0,"rearWindow":0}},"engine":false,"doorLock":true,"doorStatus":{"frontLeft":0,"frontRight":0,"backLeft":0,"backRight":0,"trunk":0,"hood":0},"lowFuelLight":false,"ign3":false,"transCond":true,"dateTime":{"utc":"20211217151540","offset":-8},"syncDate":{"utc":"20211217053655","offset":-8},"batteryStatus":{},"sleepMode":true,"lampWireStatus":{"headLamp":{},"stopLamp":{},"turnSignalLamp":{}},"windowStatus":{},"vehicleMovementHis":true,"engineRuntime":{"value":1509,"unit":3},"valetParkingMode":0}},"location":{"coord":{"lat":40.62193333,"lon":-74.4951805556,"alt":113,"type":0,"altdo":0},"head":22,"speed":{"value":0,"unit":1},"accuracy":{"hdop":7,"pdop":13},"syncDate":{"utc":"20211217053655","offset":-8}},"financed":true,"financeRegistered":true,"linkStatus":0}}]}} 2021-12-17 10:15:41 ERROR (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Exception in update : 'stateOfCharge' - 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 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoAPIUSA.py", line 264, in get_cached_vehicle_status "batSoc": vehicle_status["batteryStatus"]["stateOfCharge"], KeyError: 'stateOfCharge' 2021-12-17 10:15:41 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry brian@pagefamily.org for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/kia_uvo/__init__.py", line 217, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/__init__.py", line 206, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

fuatakgun commented 2 years ago

Please remove possible sensitive data from logs (if there is any)

I see that your kia uvo enrollment is expired, is that correct? Date: 20210829

pageb018 commented 2 years ago

It has been renewed and works correctly within the app. I will edit my previous post to remove data.

pageb018 commented 2 years ago

Does this component require the a higher level UVO service? I currently use "Plus" but there is a higher tier that includes Alexa and Google integration.

cdnninja commented 2 years ago

It looks like it is failing on a EV based value. Doesn't look like you have a EV. Could you test the code in #209?

pageb018 commented 2 years ago

Manually editing still fails, but the errors have changed.

2021-12-17 15:24:39 DEBUG (MainThread) [custom_components.kia_uvo] kia_uvo - async_setup_entry started - <homeassistant.config_entries.ConfigEntry object at 0x7fb08a0ecf60> 2021-12-17 15:24:39 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Received token into Vehicle Object {'valid_until': '2021-12-17 16:22:43.253498', 'access_token': '29888314-c6f5-4d3f-ba73-5b6835e00534', 'refresh_token': None, 'device_id': 'KNDPRCA64M7847948', 'vehicle_name': 'Kia', 'vehicle_id': '847948', 'vehicle_regid': 'xxxxxxxxxxx', 'vehicle_model': 'SPORTAGE', 'vehicle_registration_date': 'missing', 'stamp': 'NoStamp'} 2021-12-17 15:24:39 DEBUG (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Refresh token started 2021-12-17 16:22:43.253498 2021-12-17 15:24:39.186416 False 2021-12-17 15:24:39 DEBUG (SyncWorker_1) [custom_components.kia_uvo.KiaUvoAPIUSA] sending https://api.owners.kia.com/apigw/v1/cmm/gvi request with {'vehicleConfigReq': {'airTempRange': '0', 'maintenance': '0', 'seatHeatCoolOption': '0', 'vehicle': '1', 'vehicleFeature': '0'}, 'vehicleInfoReq': {'drivingActivty': '0', 'dtc': '1', 'enrollment': '1', 'functionalCards': '0', 'location': '1', 'vehicleStatus': '1', 'weather': '0'}, 'vinKey': ['2911b8f8-1a8b-43ea-afe6-0db5c41b49bc']}

2021-12-17 15:24:40 DEBUG (SyncWorker_1) [custom_components.kia_uvo.KiaUvoAPIUSA] got response {"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleInfoList":[{"vinKey":"2911b8f8-1a8b-43ea-afe6-0db5c41b49bc","vehicleConfig":{"vehicleDetail":{"vehicle":{"vin":"xxxxxxxx","trim":{"modelYear":"2021","salesModelCode":"45482","optionGroupCode":"010","modelName":"SPORTAGE","factoryCode":"D9","projectCode":"QL","trimName":"SX-P","driveType":"2","transmissionType":"1","ivrCategory":"5","btSeriesCode":"4"},"telematics":1,"mileage":"11665.9","mileageSyncDate":"20211216143655","exteriorColor":"STEEL GRAY","exteriorColorCode":"KLG","fuelType":1,"invDealerCode":"NJ074","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":"2021-sportage-sx-p-klg.png","imagePath":"/content/dam/kia/us/owners/image/vehicle-app/2021/sportage/sx-p/","imageType":"1","imageSize":{"length":"100","width":"100","uom":0}}],"device":{"launchType":"0","swVersion":"QL21.USA.SOP.V115.200325.STD_H","telematics":{"generation":"3","platform":"1","tmsCenter":"1","billing":true},"versionNum":"GASOLINE","headUnitType":"0","hdRadio":"X40HA","ampType":"NA","modem":{"meid":"354522081645629","mdn":"6574268216","iccid":"89148000005704994995"},"headUnitName":"avn5em","bluetoothRef":"10","headUnitDesc":"AVN5.0"}},"billingPeriod":{"freeTrial":{"value":12,"unit":0},"freeTrialExtension":{"value":12,"unit":1},"servicePeriod":{"value":60,"unit":1}}},"lastVehicleInfo":{"vehicleNickName":"Kia","preferredDealer":"NJ074","customerType":0,"enrollment":{"provStatus":"4","enrollmentStatus":"1","enrollmentType":"0","registrationDate":"20200829","expirationDate":"20210829","expirationMileage":"100000","freeServiceDate":{"startDate":"20200829","endDate":"20210829"}},"activeDTC":{"dtcActiveCount":"0"},"vehicleStatusRpt":{"statusType":"2","reportDate":{"utc":"20211217202440","offset":-8},"vehicleStatus":{"climate":{"airCtrl":false,"defrost":false,"airTemp":{"value":"LOW","unit":1},"heatingAccessory":{"steeringWheel":0,"sideMirror":0,"rearWindow":0}},"engine":false,"doorLock":true,"doorStatus":{"frontLeft":0,"frontRight":0,"backLeft":0,"backRight":0,"trunk":0,"hood":0},"lowFuelLight":false,"ign3":false,"transCond":true,"dateTime":{"utc":"20211217202440","offset":-8},"syncDate":{"utc":"20211217053655","offset":-8},"batteryStatus":{},"sleepMode":true,"lampWireStatus":{"headLamp":{},"stopLamp":{},"turnSignalLamp":{}},"windowStatus":{},"vehicleMovementHis":true,"engineRuntime":{"value":1509,"unit":3},"valetParkingMode":0}},"location":{"coord":{"lat":40.62193333,"lon":-74.4951805556,"alt":113,"type":0,"altdo":0},"head":22,"speed":{"value":0,"unit":1},"accuracy":{"hdop":7,"pdop":13},"syncDate":{"utc":"20211217053655","offset":-8}},"financed":true,"financeRegistered":true,"linkStatus":0}}]}} 2021-12-17 15:24:43 ERROR (MainThread) [custom_components.kia_uvo.Vehicle] kia_uvo - Exception in update : 'tirePressure' - 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 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/kia_uvo/KiaUvoAPIUSA.py", line 278, in get_cached_vehicle_status "tirePressureLampAll": vehicle_status["tirePressure"]["all"] KeyError: 'tirePressure' 2021-12-17 15:24:43 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry brian@pagefamily.org for kia_uvo Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/kia_uvo/__init__.py", line 217, in async_setup_entry await update(dt_util.utcnow()) File "/config/custom_components/kia_uvo/__init__.py", line 206, in update datetime.now(local_timezone) - vehicle.last_updated TypeError: can't subtract offset-naive and offset-aware datetimes

cdnninja commented 2 years ago

This file here fixes the next one as well. https://github.com/fuatakgun/kia_uvo/blob/master/custom_components/kia_uvo/KiaUvoAPIUSA.py

pageb018 commented 2 years ago

Perfect. I am up and running!

Appreciate the work and thanks for fixing so fast! Happy holidays and happy new year.

cdnninja commented 2 years ago

Glad to hear! Fixed will be in the next release which is this weekend.