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

Error communicating with API: invalid literal for int() with base 16: '20.0' #899

Open instantdreams opened 3 months ago

instantdreams commented 3 months ago

Region and Brand of car Canada Hyundai

Version of the integration 2.25.0

Describe the bug After entering integration configuration details the following message appears:

Needs attention
Hyundai Canada [account-email]
No devices or entities
Failed setup, will retry: Config Not Ready: Error communicating with API: invalid literal for int() with base 16: '20.0'

No integration details can be seen.

Debug logs if an error occurred Debug logs were enabled and the configuration was refreshed.

2024-06-26 14:38:54.016 DEBUG (SyncWorker_17) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Sign In Response {"responseHeader":{"responseCode":0,"responseDesc":"Success"},"result":{"accessToken":"[redacted]","scope":["profile"],"tokenType":"bearer","expireIn":86400,"refreshToken":"[redacted]","signature":""}}
2024-06-26 14:38:54.017 DEBUG (SyncWorker_17) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Access Token Value [redacted]
2024-06-26 14:38:54.017 DEBUG (SyncWorker_17) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Refresh Token Value [redacted]
2024-06-26 14:38:54.148 DEBUG (SyncWorker_17) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Get Vehicles Response {"responseHeader":{"responseCode":0,"responseDesc":"Success"},"result":{"vehicles":[{"vehicleId":"FLYPb9j600ZKxRp1lEGB+Q==","nickName":"KONA EV","modelCode":"KE2SEFEMEP20","modelName":"KONA EV","modelYear":"2024","fuelKindCode":"E","trim":"Preferred -","engine":"","exteriorColor":"RRR","dtcCount":0,"subscriptionStatus":"A","subscriptionEndDate":"20270531","mileageForNextService":11999.2,"daysForNextService":"20250626","overviewMessage":"","defaultVehicle":true,"enrollmentStatus":"4","genType":"G3","valetParkingModeOn":1,"mainBatteryType":0,"chrgPortDoorOption":0,"v2loption":0,"v2lSetSocOption":1,"preConditioningOption":2,"vin":"[redacted]"}]}}
2024-06-26 14:38:54.302 DEBUG (SyncWorker_56) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20240626143101', 'airCtrlOn': True, 'engine': True, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '20.0', 'unit': 0}, 'defrost': False, 'lowFuelLight': False, 'acc': True, 'evStatus': {'batteryCharge': False, 'batteryStatus': 74, 'batteryPlugin': 0, 'dischargingLimit': 20, 'remainTime2': {'etc1': {'value': 68, 'unit': 1}, 'etc2': {'value': 500, 'unit': 1}, 'etc3': {'value': 115, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'evModeRange': {'value': 314.0, 'unit': 1}, 'totalAvailableRange': {'value': 314.0, 'unit': 1}}, 'type': 2}], 'reservChargeInfos': {'reservChargeInfo': {'reservChargeInfoDetail': {'reservInfo': {'day': [5, 1, 6, 0, 4, 2, 3], 'time': {'time': '3170', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': 'OFF', 'unit': 0, 'hvacTempType': 0}, 'airCtrl': 2, 'heating1': 0}}}, 'reserveChargeInfo2': {'reservChargeInfoDetail': {'reservInfo': {'day': [5, 1, 6, 0, 4, 2, 3], 'time': {'time': '3170', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': 'OFF', 'unit': 0, 'hvacTempType': 0}, 'airCtrl': 2}}}, 'offpeakPowerInfo': {'offPeakPowerFlag': 0, 'offPeakPowerTime1': {'starttime': {'time': '3170', 'timeSection': 0}, 'endtime': {'time': '3170', 'timeSection': 0}}, 'offPeakPowerTime2': {'starttime': {'time': '3170', 'timeSection': 0}, 'endtime': {'time': '3170', 'timeSection': 0}}}, 'reservFlag': 0, 'ect': {'start': {'day': 9, 'time': {'time': '3163', 'timeSection': 0}}, 'end': {'day': 7, 'time': {'time': '3163', 'timeSection': 0}}}, 'targetSOClist': [{'plugType': 0, 'targetSOClevel': 100}, {'plugType': 1, 'targetSOClevel': 100}]}, 'batteryPreconditiong': False, 'chargePortDoorOpenStatus': 0, 'wirelessCharging': False, 'batterySoh': 100, 'sequenceDetails': 0, 'sequenceSubcode': 0}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'tirePressureLamp': {'tirePressureLampAll': 1, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 95, 'batState': 0, 'sjbDeliveryMode': 1, 'batSignalReferenceValue': {'batWarning': 65}, 'powerAutoCutMode': 2}, 'remoteIgnition': True, 'seatHeaterVentInfo': {'drvSeatHeatState': 2, 'astSeatHeatState': 2, 'rlSeatHeatState': 2, 'rrSeatHeatState': 2}, 'lampWireStatus': {'headLamp': {'headLampStatus': False, 'leftLowLamp': False, 'rightLowLamp': False, 'leftHighLamp': False, 'rightHighLamp': False, 'leftBifuncLamp': False, 'rightBifuncLamp': False}, 'stopLamp': {'stopLampStatus': False, 'leftLamp': False, 'rightLamp': False}, 'turnSignalLamp': {'turnSignalLampStatus': False, 'leftFrontLamp': False, 'rightFrontLamp': False, 'leftRearLamp': False, 'rightRearLamp': False}}, 'smartKeyBatteryWarning': False, 'washerFluidStatus': False, 'breakOilStatus': False, 'engineRuntime': {}}}}
2024-06-26 14:38:54.302 DEBUG (SyncWorker_56) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Old Vehicle Last Updated: None
2024-06-26 14:38:54.302 DEBUG (SyncWorker_56) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Current Vehicle Last Updated: 2024-06-26 14:31:01+00:00
2024-06-26 14:38:54.445 DEBUG (SyncWorker_59) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20240626143101', 'airCtrlOn': True, 'engine': True, 'doorLock': True, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '20.0', 'unit': 0}, 'defrost': False, 'lowFuelLight': False, 'acc': True, 'evStatus': {'batteryCharge': False, 'batteryStatus': 74, 'batteryPlugin': 0, 'dischargingLimit': 20, 'remainTime2': {'etc1': {'value': 68, 'unit': 1}, 'etc2': {'value': 500, 'unit': 1}, 'etc3': {'value': 115, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'evModeRange': {'value': 314.0, 'unit': 1}, 'totalAvailableRange': {'value': 314.0, 'unit': 1}}, 'type': 2}], 'reservChargeInfos': {'reservChargeInfo': {'reservChargeInfoDetail': {'reservInfo': {'day': [5, 1, 6, 0, 4, 2, 3], 'time': {'time': '3170', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': 'OFF', 'unit': 0, 'hvacTempType': 0}, 'airCtrl': 2, 'heating1': 0}}}, 'reserveChargeInfo2': {'reservChargeInfoDetail': {'reservInfo': {'day': [5, 1, 6, 0, 4, 2, 3], 'time': {'time': '3170', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': 'OFF', 'unit': 0, 'hvacTempType': 0}, 'airCtrl': 2}}}, 'offpeakPowerInfo': {'offPeakPowerFlag': 0, 'offPeakPowerTime1': {'starttime': {'time': '3170', 'timeSection': 0}, 'endtime': {'time': '3170', 'timeSection': 0}}, 'offPeakPowerTime2': {'starttime': {'time': '3170', 'timeSection': 0}, 'endtime': {'time': '3170', 'timeSection': 0}}}, 'reservFlag': 0, 'ect': {'start': {'day': 9, 'time': {'time': '3163', 'timeSection': 0}}, 'end': {'day': 7, 'time': {'time': '3163', 'timeSection': 0}}}, 'targetSOClist': [{'plugType': 0, 'targetSOClevel': 100}, {'plugType': 1, 'targetSOClevel': 100}]}, 'batteryPreconditiong': False, 'chargePortDoorOpenStatus': 0, 'wirelessCharging': False, 'batterySoh': 100, 'sequenceDetails': 0, 'sequenceSubcode': 0}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'tirePressureLamp': {'tirePressureLampAll': 1, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 95, 'batState': 0, 'sjbDeliveryMode': 1, 'batSignalReferenceValue': {'batWarning': 65}, 'powerAutoCutMode': 2}, 'remoteIgnition': True, 'seatHeaterVentInfo': {'drvSeatHeatState': 2, 'astSeatHeatState': 2, 'rlSeatHeatState': 2, 'rrSeatHeatState': 2}, 'lampWireStatus': {'headLamp': {'headLampStatus': False, 'leftLowLamp': False, 'rightLowLamp': False, 'leftHighLamp': False, 'rightHighLamp': False, 'leftBifuncLamp': False, 'rightBifuncLamp': False}, 'stopLamp': {'stopLampStatus': False, 'leftLamp': False, 'rightLamp': False}, 'turnSignalLamp': {'turnSignalLampStatus': False, 'leftFrontLamp': False, 'rightFrontLamp': False, 'leftRearLamp': False, 'rightRearLamp': False}}, 'smartKeyBatteryWarning': False, 'washerFluidStatus': False, 'breakOilStatus': False, 'engineRuntime': {}}}}
2024-06-26 14:38:54.446 DEBUG (SyncWorker_59) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Old Vehicle Last Updated: 2024-06-26 14:31:01+00:00
2024-06-26 14:38:54.446 DEBUG (SyncWorker_59) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - Current Vehicle Last Updated: 2024-06-26 14:31:01+00:00
2024-06-26 14:38:54.447 DEBUG (MainThread) [custom_components.kia_uvo.coordinator] Finished fetching kia_uvo data in 0.949 seconds (success: False)

Access token is correctly generated. Vehicle details are retrieved.

To Reproduce key airTemp has value 20.0 and unit 0, which is the only matching value in the debug log.

Expected behavior Exception not to be raised by temperature value.

cdnninja commented 3 months ago

What year and model? Looks like they finally are not using the crazy temp approach of the past. This section of code will need to detect if the car is providing a real temp vs hex and not touch it if a real temp:

https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/fdc08fc99595224234046b227b56cff0e7fbb5f6/hyundai_kia_connect_api/KiaUvoApiCA.py#L250-L263

instantdreams commented 3 months ago

This is a 2024 Kona Preferred (SE) in Canada.

Checking HA this morning, the car is connected and information can be displayed, but the error message is still occurring:

homeassistant  | 2024-06-27 08:46:10.114 ERROR (MainThread) [custom_components.kia_uvo.coordinator] Error fetching kia_uvo data: Error communicating with API: invalid literal for int() with base 16: '19.5'

The payload has 19.5 as the airTemp:

homeassistant  | 2024-06-27 08:46:10.111 DEBUG (SyncWorker_51) [hyundai_kia_connect_api.KiaUvoApiCA] hyundai_kia_connect_api - get_cached_vehicle_status response {'responseHeader': {'responseCode': 0, 'responseDesc': 'Success'}, 'result': {'status': {'lastStatusDate': '20240627143621', 'airCtrlOn': True, 'engine': True, 'doorLock': False, 'doorOpen': {'frontLeft': 0, 'frontRight': 0, 'backLeft': 0, 'backRight': 0}, 'trunkOpen': False, 'airTempUnit': 'C', 'airTemp': {'value': '19.5', 'unit': 0}, 'defrost': False, 'lowFuelLight': False, 'acc': True, 'evStatus': {'batteryCharge': False, 'batteryStatus': 76, 'batteryPlugin': 0, 'dischargingLimit': 20, 'remainTime2': {'etc1': {'value': 62, 'unit': 1}, 'etc2': {'value': 450, 'unit': 1}, 'etc3': {'value': 105, 'unit': 1}, 'atc': {'value': 0, 'unit': 1}}, 'drvDistance': [{'rangeByFuel': {'evModeRange': {'value': 317.0, 'unit': 1}, 'totalAvailableRange': {'value': 317.0, 'unit': 1}}, 'type': 2}], 'reservChargeInfos': {'reservChargeInfo': {'reservChargeInfoDetail': {'reservInfo': {'day': [5, 1, 6, 0, 4, 2, 3], 'time': {'time': '3170', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': 'OFF', 'unit': 0, 'hvacTempType': 0}, 'airCtrl': 2, 'heating1': 0}}}, 'reserveChargeInfo2': {'reservChargeInfoDetail': {'reservInfo': {'day': [5, 1, 6, 0, 4, 2, 3], 'time': {'time': '3170', 'timeSection': 0}}, 'reservChargeSet': False, 'reservFatcSet': {'defrost': False, 'airTemp': {'value': 'OFF', 'unit': 0, 'hvacTempType': 0}, 'airCtrl': 2}}}, 'offpeakPowerInfo': {'offPeakPowerFlag': 0, 'offPeakPowerTime1': {'starttime': {'time': '3170', 'timeSection': 0}, 'endtime': {'time': '3170', 'timeSection': 0}}, 'offPeakPowerTime2': {'starttime': {'time': '3170', 'timeSection': 0}, 'endtime': {'time': '3170', 'timeSection': 0}}}, 'reservFlag': 0, 'ect': {'start': {'day': 9, 'time': {'time': '3163', 'timeSection': 0}}, 'end': {'day': 7, 'time': {'time': '3163', 'timeSection': 0}}}, 'targetSOClist': [{'plugType': 0, 'targetSOClevel': 100}, {'plugType': 1, 'targetSOClevel': 100}]}, 'batteryPreconditiong': False, 'chargePortDoorOpenStatus': 0, 'wirelessCharging': False, 'batterySoh': 100, 'sequenceDetails': 0, 'sequenceSubcode': 0}, 'hoodOpen': False, 'transCond': True, 'steerWheelHeat': 0, 'sideBackWindowHeat': 0, 'tirePressureLamp': {'tirePressureLampAll': 1, 'tirePressureLampFL': 0, 'tirePressureLampFR': 0, 'tirePressureLampRL': 0, 'tirePressureLampRR': 0}, 'battery': {'batSoc': 96, 'batState': 0, 'sjbDeliveryMode': 1, 'batSignalReferenceValue': {'batWarning': 65}, 'powerAutoCutMode': 2}, 'remoteIgnition': True, 'seatHeaterVentInfo': {'drvSeatHeatState': 2, 'astSeatHeatState': 2, 'rlSeatHeatState': 2, 'rrSeatHeatState': 2}, 'lampWireStatus': {'headLamp': {'headLampStatus': False, 'leftLowLamp': False, 'rightLowLamp': False, 'leftHighLamp': False, 'rightHighLamp': False, 'leftBifuncLamp': False, 'rightBifuncLamp': False}, 'stopLamp': {'stopLampStatus': False, 'leftLamp': False, 'rightLamp': False}, 'turnSignalLamp': {'turnSignalLampStatus': False, 'leftFrontLamp': False, 'rightFrontLamp': False, 'leftRearLamp': False, 'rightRearLamp': False}}, 'smartKeyBatteryWarning': False, 'washerFluidStatus': False, 'breakOilStatus': False, 'engineRuntime': {}}}}
instantdreams commented 3 months ago

Checking further, there are more detailed error messages:

homeassistant  | 2024-06-27 08:47:14.801 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.kona_ev_set_temperature for domain sensor with platform kia_uvo
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 658, in state
homeassistant  |     numerical_value = int(value)
homeassistant  |                       ^^^^^^^^^^
homeassistant  | ValueError: invalid literal for int() with base 10: 'OFF'
homeassistant  |
homeassistant  | During handling of the above exception, another exception occurred:
homeassistant  |
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 661, in state
homeassistant  |     numerical_value = float(value)
homeassistant  |                       ^^^^^^^^^^^^
homeassistant  | ValueError: could not convert string to float: 'OFF'
homeassistant  |
homeassistant  | The above exception was the direct cause of the following exception:
homeassistant  |
homeassistant  | Traceback (most recent call last):
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 600, in _async_add_entities
homeassistant  |     await coro
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity
homeassistant  |     await entity.add_to_platform_finish()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish
homeassistant  |     self.async_write_ha_state()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
homeassistant  |     self._async_write_ha_state()
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
homeassistant  |     state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
homeassistant  |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
homeassistant  |     state = self._stringify_state(available)
homeassistant  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
homeassistant  |     if (state := self.state) is None:
homeassistant  |                  ^^^^^^^^^^
homeassistant  |   File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 665, in state
homeassistant  |     raise ValueError(
homeassistant  | ValueError: Sensor sensor.kona_ev_set_temperature has device class 'temperature', state class 'None' unit '°C' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'OFF' (<class 'str'>)

Hope that helps!