Giter Site home page Giter Site logo

dahlb / ha_kia_hyundai Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 5.0 696 KB

A Home Assistant HACS integration that supports Kia Connect(Uvo). The integration supports the USA.

License: MIT License

Python 99.66% Shell 0.34%
car homeassistant homeassistant-integration kia python3 uvo

ha_kia_hyundai's People

Contributors

actions-user avatar badguy99 avatar bvlaicu avatar cdnninja avatar dahlb avatar dependabot[bot] avatar fuatakgun avatar jaywryan avatar mancavemedia avatar tarheelgrad1998 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ha_kia_hyundai's Issues

KeyError: 'pin'

Region and Brand of car
US / Kia Niro

Describe the bug
After entering credentials you get "unknown error".

Debug logs if an error occurred

...skipping...
2021-12-28 12:45:57 DEBUG (PysherScheduler) [websocket] send: b'\x81\xa4\xe0\x87\xcb\xf7\x9b\xa5\xae\x81\x85\xe9\xbf\xd5\xda\xa7\xe9\x87\x95\xf4\xa3\x92\x92\xbd\xbb\x9e\x8e\xe0\xe9\xdb\xc0\xa5\xaf\x96\x94\xe6\xe9\xcd\xc0\xa5\xe9\x8a'
2021-12-28 12:45:57 INFO (PysherEventLoop) [pysher.connection] Connection: Message - {"event":"pusher:pong","data":"{}"}
2021-12-28 12:45:57 INFO (PysherEventLoop) [pysher.connection] Connection: pong from pusher
2021-12-28 12:46:57 DEBUG (PysherEventLoop) [websocket] send: b'\x8a\x80\x1dE\x98!'
2021-12-28 12:47:23 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.guest_room is taking over 10 seconds
2021-12-28 12:47:57 INFO (PysherScheduler) [pysher.connection] Connection: ping to pusher
2021-12-28 12:47:57 DEBUG (PysherScheduler) [websocket] send: b'\x81\xa4\xd8S\x13\xd3\xa3qv\xa5\xbd=g\xf1\xe2s1\xa3\xad {\xb6\xaaic\xba\xb641\xff\xf8qw\xb2\xac21\xe9\xf8q1\xae'
2021-12-28 12:47:57 INFO (PysherEventLoop) [pysher.connection] Connection: Message - {"event":"pusher:pong","data":"{}"}
2021-12-28 12:47:57 INFO (PysherEventLoop) [pysher.connection] Connection: pong from pusher
2021-12-28 12:48:57 DEBUG (PysherEventLoop) [websocket] send: b'\x8a\x80\x02\xe5VU'
2021-12-28 12:49:08 DEBUG (MainThread) [custom_components.ha_kia_hyundai.api_cloud_util] US KIA in use
2021-12-28 12:49:18 DEBUG (MainThread) [custom_components.ha_kia_hyundai.api_cloud_util] US KIA in use
2021-12-28 12:49:18 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/ha_kia_hyundai/config_flow.py", line 136, in async_step_auth
if user_input[CONF_PIN] is not None:
KeyError: 'pin'

To Reproduce
Steps to reproduce the behavior:

  1. Enter initial configuration screen
  2. Select "US" and "Kia". Press Enter.
  3. Enter credentials
  4. See error

Expected behavior
The credentials should be accepted and I should be prompted to select my vehicle.

Additional context
Commenting out lines 136 and 137 avoids the issue. My guess is that PIN is only needed for Canada so for US the dictionary was not set up.

Mileage incorrect from API response

Region and Brand of car
US / Kia Niro

Describe the bug
The following sensors have incorrect data:
"Niro Odometer" shows 0.0 mi
"Niro Last Services" shows 125,000 mi

Debug logs if an error occurred
2021-12-30 09:55:11 DEBUG (MainThread) [kia_hyundai_api.us_kia] response text:{"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleSummary":[{"vin":"KNDCC3LC7L5428408","vehicleIdentifier":"428408","modelName":"NIRO","modelYear":"2020","nickName":"Niro","generation":2,"extColorCode":"C3U","trim":"TOURING","imagePath":{"imageName":"2020-niro-touring-c3u.png","imagePath":"/content/dam/kia/us/owners/image/vehicle-app/2020/niro/touring/","imageType":"1","imageSize":{"length":"100","width":"100","uom":0}},"enrollmentStatus":0,"fatcAvailable":0,"telematicsUnit":1,"fuelType":3,"colorName":"DEEP CERULEAN","activationType":2,"mileage":"0","dealerCode":"PA004","mobileStore":[{"osType":0,"downloadURL":"https://itunes.apple.com/us/app/kia-access-with-uvo-link/id1280548773?mt=8","image":{"imageName":"iosImage.png","imagePath":"/content/dam/kia/us/owners/image/common/app/","imageType":"2","imageSize":{"length":"100","width":"100","uom":0}}},{"osType":1,"downloadURL":"https://play.google.com/store/apps/details?id=com.myuvo.link","image":{"imageName":"androidImage.png","imagePath":"/content/dam/kia/us/owners/image/common/app/","imageType":"2","imageSize":{"length":"100","width":"100","uom":0}}}],"supportedApp":{"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}}},"licensePlate":"","psi":"","supportAdditionalDriver":0,"customerType":1,"projectCode":"DEHEV","headUnitDesc":"DAV2","provStatus":"4","enrollmentSuppressionType":0,"vehicleKey":"0b49316b-c6d3-4d1a-aa54-494c89850124"}]}}
2021-12-30 09:55:11 DEBUG (MainThread) [custom_components.ha_kia_hyundai] first update start
2021-12-30 09:55:11 DEBUG (MainThread) [kia_hyundai_api.us_kia] sending https://api.owners.kia.com/apigw/v1/cmm/gvi request with {'vehicleConfigReq': {'airTempRange': '0', 'maintenance': '1', 'seatHeatCoolOption': '1', 'vehicle': '1', 'vehicleFeature': '1'}, 'vehicleInfoReq': {'drivingActivty': '0', 'dtc': '0', 'enrollment': '0', 'functionalCards': '0', 'location': '1', 'vehicleStatus': '1', 'weather': '0'}, 'vinKey': ['0b49316b-c6d3-4d1a-aa54-494c89850124']}
2021-12-30 09:55:11 DEBUG (MainThread) [kia_hyundai_api.us_kia] response headers:<CIMultiDictProxy('Server': 'KMA', 'Date': 'Thu, 30 Dec 2021 14:55:11 GMT', 'Content-Length': '4678', 'Content-Type': 'application/json', 'Xid': 'd051a429-654e-4463-843d-5bdc1d126698')>
2021-12-30 09:55:11 DEBUG (MainThread) [kia_hyundai_api.us_kia] response text:{"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleInfoList":[{"vinKey":"0b49316b-c6d3-4d1a-aa54-494c89850124","vehicleConfig":{"vehicleDetail":{"vehicle":{"vin":"KNDCC3LC7L5428408","trim":{"modelYear":"2020","salesModelCode":"G4262","optionGroupCode":"010","modelName":"NIRO","factoryCode":"G5","projectCode":"DEHEV","trimName":"TOURING","driveType":"0","transmissionType":"1","ivrCategory":"5","btSeriesCode":"G"},"telematics":1,"mileage":"0","mileageSyncDate":"20211229212654","exteriorColor":"DEEP CERULEAN","exteriorColorCode":"C3U","fuelType":3,"invDealerCode":"PA004","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":"2020-niro-touring-c3u.png","imagePath":"/content/dam/kia/us/owners/image/vehicle-app/2020/niro/touring/","imageType":"1","imageSize":{"length":"100","width":"100","uom":0}}],"device":{"launchType":"0","swVersion":"DEPE_HEV.USA.D2V.002.001.191207","telematics":{"generation":"3","platform":"1","tmsCenter":"1","billing":true},"versionNum":"GASOLINE","headUnitType":"2","hdRadio":"X40HAF","ampType":"NA","modem":{"meid":"352756079211901","mdn":"6574342729","iccid":"89148000005952739845"},"headUnitName":"daudio1","bluetoothRef":"19","headUnitDesc":"DAV2"}},"maintenance":{"nextServiceMile":5803.83,"maintenanceSchedule":[7500,15000,22500,30000,37500,45000,52500,60000,67500,75000,82500,90000,97500,105000,112500]},"vehicleFeature":{"remoteFeature":{"lock":"1","unlock":"1","start":"3","stop":"1","scheduleCount":"2","inVehicleSchedule":"1","heatedSteeringWheel":"1","heatedSideMirror":"1","heatedRearWindow":"1","heatedSeat":"0","ventSeat":"0","alarm":"1","hornlight":"1","panic":"1","doorSecurity":"1","engineIdleTime":"1","separateHeatedAccessories":"0","windowSafety":"0"},"chargeFeature":{"batteryChargeType":"0","chargeEndPct":"0","immediateCharge":"0","cancelCharge":"0","evRange":"0","scheduleCount":"0","inVehicleSchedule":"0","offPeakType":"0","scheduleType":"0","chargeLevel":"0","scheduleConfig":"0","fatcWithCharge":"0"},"alertFeature":{"geofenceType":{"geofence":"1","entryCount":"5","exitCount":"1","inVehicleConfig":"0","minRadius":"1","maxRadius":"10","minHeight":"1","maxHeight":"10","minWidth":"1","maxWidth":"10","uom":"0"},"curfewType":{"curfew":"1","curfewCount":"21","inVehicleConfig":"0"},"speedType":{"speed":"1","speedCount":"21","inVehicleConfig":"0"},"valetType":{"valet":"1","valetParkingMode":"0","defaultRadius":"1","defaultRadiusUnit":"3","defaultInterval":"5","defaultIntervalUnit":"3","inVehicleConfig":"0"}},"vrmFeature":{"autoDTC":"1","scheduledDTC":"1","backgroundDTC":"1","manualDTC":"1","healthReport":"0","drivingScore":"1","gasRange":"1","evRange":"0","trip":"1"},"locationFeature":{"gpsStreaming":"0","location":"1","poi":"1","poiCount":"25","push2Vehicle":"1","wayPoint":"1","mapType":"1","surroundView":"0","svr":"1"},"userSettingFeature":{"usmType":"0","calendar":"0","valetParkingMode":"0","wifiHotSpot":"0","otaSupport":"0","digitalKeyOption":"0"}},"heatVentSeat":{},"billingPeriod":{"freeTrial":{"value":12,"unit":0},"freeTrialExtension":{"value":12,"unit":1},"servicePeriod":{"value":60,"unit":1}}},"lastVehicleInfo":{"vehicleNickName":"Niro","preferredDealer":"PA004","licensePlate":"","psi":"","customerType":1,"vehicleStatusRpt":{"statusType":"2","reportDate":{"utc":"20211230145511","offset":-8},"vehicleStatus":{"climate":{"airCtrl":false,"defrost":false,"airTemp":{"value":"75","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,"distanceToEmpty":{"value":410,"unit":3},"tirePressure":{"all":0,"frontLeft":0,"frontRight":0,"rearLeft":0,"rearRight":0},"dateTime":{"utc":"20211230145511","offset":-8},"syncDate":{"utc":"20211230122654","offset":-8},"batteryStatus":{"stateOfCharge":100,"sensorStatus":0,"deliveryMode":0},"sleepMode":true,"lampWireStatus":{"headLamp":{},"stopLamp":{},"turnSignalLamp":{}},"windowStatus":{},"engineOilStatus":false,"vehicleMovementHis":true,"engineRuntime":{"value":12,"unit":1},"valetParkingMode":0}},"location":{"coord":{"lat":40.008689,"lon":-75.243305,"alt":64.9,"type":0,"altdo":0},"head":177,"speed":{"value":0,"unit":1},"accuracy":{"hdop":0,"pdop":1},"syncDate":{"utc":"20211230122654","offset":-8}},"financed":true,"financeRegistered":false,"linkStatus":0}}]}}
2021-12-30 09:55:13 WARNING (MainThread) [custom_components.ha_kia_hyundai.vehicle] Location name lookup failed:Service timed out
2021-12-30 09:55:13 DEBUG (MainThread) [custom_components.ha_kia_hyundai.vehicle] Finished fetching Vehicle 428408 data in 2.076 seconds (success: True)
2021-12-30 09:55:13 DEBUG (MainThread) [custom_components.ha_kia_hyundai] first update finished

Additional context
I included the complete log for the first fetch of vehicle data after restarting HA. This should provide all the data you need to populate the sensors.

Unable to Lock/Unlock Car

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

Describe the bug
When I clock the lock/unlock toggle switch in Home Assistant I get the following error:
Failed to call service lock/lock. Lock.async_lock() got an unexpected keyword argument 'entity_id'

Debug logs if an error occurred

Outlined here: https://github.com/dahlb/ha_kia_hyundai/blob/master/README.m

Nothing reflected in the logs

To Reproduce
Steps to reproduce the behavior:
Click on the Lock toggle switch in HA and the pop up appears

Expected behavior
Car to lock and unlock

Screenshots
Screenshot 2023-02-10 at 9 41 49 AM

Additional context
Not 100% sure this is a ha_kia_hyundai issue or home assistant issue.. but I believe it started after the 2023.2.0 release..

Integration Error Post-Configuration

Region and Brand of car
US / Kia Niro

Describe the bug
After entering all the configuration details no data appears in the dashboard. When you view the Integrations screen you see "Retrying setup..." with error details. See below for traceback.

Debug logs if an error occurred

2021-12-29 07:40:08 DEBUG (MainThread) [custom_components.ha_kia_hyundai] first update start
2021-12-29 07:40:08 DEBUG (MainThread) [kia_hyundai_api.us_kia] sending https://api.owners.kia.com/apigw/v1/cmm/gvi request with {'vehicleConfigReq': {'airTempRange': '0', 'maintenance': '1', 'seatHeatCoolOption': '1', 'vehicle': '1', 'vehicleFeature': '1'}, 'vehicleInfoReq': {'drivingActivty': '0', 'dtc': '0', 'enrollment': '0', 'functionalCards': '0', 'location': '1', 'vehicleStatus': '1', 'weather': '0'}, 'vinKey': ['9a0042e8-8b89-4c6f-b293-460c15738b67']}
2021-12-29 07:40:08 DEBUG (MainThread) [kia_hyundai_api.us_kia] response headers:<CIMultiDictProxy('Server': 'KMA', 'Date': 'Wed, 29 Dec 2021 12:40:08 GMT', 'Content-Length': '4680', 'Content-Type': 'application/json', 'Xid': '6d46987c-44b5-43e8-b51b-b0830580a753')>
2021-12-29 07:40:08 DEBUG (MainThread) [kia_hyundai_api.us_kia] response text:{"status":{"statusCode":0,"errorType":0,"errorCode":0,"errorMessage":"Success with response body"},"payload":{"vehicleInfoList":[{"vinKey":"9a0042e8-8b89-4c6f-b293-460c15738b67","vehicleConfig":{"vehicleDetail":{"vehicle":{"vin":"KNDCC3LC7L5428408","trim":{"modelYear":"2020","salesModelCode":"G4262","optionGroupCode":"010","modelName":"NIRO","factoryCode":"G5","projectCode":"DEHEV","trimName":"TOURING","driveType":"0","transmissionType":"1","ivrCategory":"5","btSeriesCode":"G"},"telematics":1,"mileage":"0","mileageSyncDate":"20211228211444","exteriorColor":"DEEP CERULEAN","exteriorColorCode":"C3U","fuelType":3,"invDealerCode":"PA004","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":"2020-niro-touring-c3u.png","imagePath":"/content/dam/kia/us/owners/image/vehicle-app/2020/niro/touring/","imageType":"1","imageSize":{"length":"100","width":"100","uom":0}}],"device":{"launchType":"0","swVersion":"DEPE_HEV.USA.D2V.002.001.191207","telematics":{"generation":"3","platform":"1","tmsCenter":"1","billing":true},"versionNum":"GASOLINE","headUnitType":"2","hdRadio":"X40HAF","ampType":"NA","modem":{"meid":"352756079211901","mdn":"6574342729","iccid":"89148000005952739845"},"headUnitName":"daudio1","bluetoothRef":"19","headUnitDesc":"DAV2"}},"maintenance":{"nextServiceMile":5823.7197,"maintenanceSchedule":[7500,15000,22500,30000,37500,45000,52500,60000,67500,75000,82500,90000,97500,105000,112500]},"vehicleFeature":{"remoteFeature":{"lock":"1","unlock":"1","start":"3","stop":"1","scheduleCount":"2","inVehicleSchedule":"1","heatedSteeringWheel":"1","heatedSideMirror":"1","heatedRearWindow":"1","heatedSeat":"0","ventSeat":"0","alarm":"1","hornlight":"1","panic":"1","doorSecurity":"1","engineIdleTime":"1","separateHeatedAccessories":"0","windowSafety":"0"},"chargeFeature":{"batteryChargeType":"0","chargeEndPct":"0","immediateCharge":"0","cancelCharge":"0","evRange":"0","scheduleCount":"0","inVehicleSchedule":"0","offPeakType":"0","scheduleType":"0","chargeLevel":"0","scheduleConfig":"0","fatcWithCharge":"0"},"alertFeature":{"geofenceType":{"geofence":"1","entryCount":"5","exitCount":"1","inVehicleConfig":"0","minRadius":"1","maxRadius":"10","minHeight":"1","maxHeight":"10","minWidth":"1","maxWidth":"10","uom":"0"},"curfewType":{"curfew":"1","curfewCount":"21","inVehicleConfig":"0"},"speedType":{"speed":"1","speedCount":"21","inVehicleConfig":"0"},"valetType":{"valet":"1","valetParkingMode":"0","defaultRadius":"1","defaultRadiusUnit":"3","defaultInterval":"5","defaultIntervalUnit":"3","inVehicleConfig":"0"}},"vrmFeature":{"autoDTC":"1","scheduledDTC":"1","backgroundDTC":"1","manualDTC":"1","healthReport":"0","drivingScore":"1","gasRange":"1","evRange":"0","trip":"1"},"locationFeature":{"gpsStreaming":"0","location":"1","poi":"1","poiCount":"25","push2Vehicle":"1","wayPoint":"1","mapType":"1","surroundView":"0","svr":"1"},"userSettingFeature":{"usmType":"0","calendar":"0","valetParkingMode":"0","wifiHotSpot":"0","otaSupport":"0","digitalKeyOption":"0"}},"heatVentSeat":{},"billingPeriod":{"freeTrial":{"value":12,"unit":0},"freeTrialExtension":{"value":12,"unit":1},"servicePeriod":{"value":60,"unit":1}}},"lastVehicleInfo":{"vehicleNickName":"Niro","preferredDealer":"PA004","licensePlate":"","psi":"","customerType":1,"vehicleStatusRpt":{"statusType":"2","reportDate":{"utc":"20211229124008","offset":-8},"vehicleStatus":{"climate":{"airCtrl":false,"defrost":false,"airTemp":{"value":"75","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,"distanceToEmpty":{"value":438,"unit":3},"tirePressure":{"all":0,"frontLeft":0,"frontRight":0,"rearLeft":0,"rearRight":0},"dateTime":{"utc":"20211229124008","offset":-8},"syncDate":{"utc":"20211229121444","offset":-8},"batteryStatus":{"stateOfCharge":100,"sensorStatus":0,"deliveryMode":0},"sleepMode":true,"lampWireStatus":{"headLamp":{},"stopLamp":{},"turnSignalLamp":{}},"windowStatus":{},"engineOilStatus":false,"vehicleMovementHis":false,"engineRuntime":{"value":8,"unit":1},"valetParkingMode":0}},"location":{"coord":{"lat":40.008693,"lon":-75.243275,"alt":61.2,"type":0,"altdo":0},"head":179,"speed":{"value":0,"unit":1},"accuracy":{"hdop":0,"pdop":1},"syncDate":{"utc":"20211229121444","offset":-8}},"financed":true,"financeRegistered":false,"linkStatus":0}}]}}
2021-12-29 07:40:08 ERROR (MainThread) [custom_components.ha_kia_hyundai.vehicle] Unexpected error fetching Vehicle 428408 data: '<=' not supported between instances of 'NoneType' and 'int'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
return await self.update_method()
File "/config/custom_components/ha_kia_hyundai/vehicle.py", line 112, in async_update_data
await self.api_cloud.update(vehicle=self)
File "/config/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 30, in request_with_active_session_wrapper
return await func(*args, **kwargs)
File "/config/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 232, in update
if ev_max_dc_charge_level <= 100:
TypeError: '<=' not supported between instances of 'NoneType' and 'int'
2021-12-29 07:40:08 DEBUG (MainThread) [custom_components.ha_kia_hyundai.vehicle] Finished fetching Vehicle 428408 data in 0.267 seconds (success: False)

To Reproduce
Steps to reproduce the behavior:
Simply configure the integration as per standard. It found my car but appears to get a parsing error when processing the results.

Expected behavior
No error showing on the integration screen. Data showing in dashboard.

Screenshots
image

Add Sensor for "Distance to Empty"

Is your feature request related to a problem? Please describe.
"Distance to Empty" is available in from the API and would be a useful addition to the sensor list.

Include the logs of the end point from Data in HA if this is a sensor

				"distanceToEmpty": {
					"value": 397,
					"unit": 3
				},

Custom Component fails to load starting yesterday - SSL Error

Please check Services, Known Bug / Issues and Troubleshooting over here first: https://github.com/dahlb/ha_kia_hyundai/blob/master/README.md
Region and Brand of car
US - Kia Soul EV 2018

Describe the bug
fails to load all entities

Debug logs if an error occurred
error during setup: Cannot connect to host api.owners.kia.com:443 ssl:<ssl.SSLContext object at 0xa9da5a90> [[SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:1123)], waiting 1 minute and trying again.

FULL LOG:
2022-09-21 07:42:37.818 DEBUG (MainThread) [custom_components.ha_kia_hyundai.api_cloud_util] US KIA in use
2022-09-21 07:42:37.843 DEBUG (MainThread) [kia_hyundai_api.us_kia] sending https://api.owners.kia.com/apigw/v1/prof/authUser request with {'deviceKey': '', 'deviceType': 2, 'userCredential': {'userId': '', 'password': ''}}
2022-09-21 07:42:39.993 WARNING (MainThread) [custom_components.ha_kia_hyundai] error during setup: Cannot connect to host api.owners.kia.com:443 ssl:<ssl.SSLContext object at 0xa9da5a90> [[SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:1123)], waiting 1 minute and trying again.
2022-09-21 07:42:50.155 DEBUG (MainThread) [kia_hyundai_api.us_kia] sending https://api.owners.kia.com/apigw/v1/prof/authUser request with {'deviceKey': '', 'deviceType': 2, 'userCredential': {'userId': '', 'password': ''}}
2022-09-21 07:43:17.815 DEBUG (MainThread) [custom_components.ha_kia_hyundai.config_flow] user input in option flow : {'scan_interval': 60, 'force_scan_interval': 240, 'no_force_scan_hour_start': 19, 'no_force_scan_hour_finish': 5}

Outlined here: https://github.com/dahlb/ha_kia_hyundai/blob/master/README.m

To Reproduce
Steps to reproduce the behavior:

  1. (Re)Start home assistant
  2. See error

Expected behavior
Entities load and data happens...

Deprecated HA warning in 2022.11.2 for is_metric

USA, Kia, EV6, Wind AWD

After updating to 2022.11.2 (from 2022.10.x) received a deprecated warning as below:

`Logger: homeassistant.helpers.frame
Source: helpers/frame.py:77
First occurred: 5:51:48 PM (1 occurrences)
Last logged: 5:51:48 PM

Detected integration that accesses the is_metric property of the unit system. This is deprecated and will stop working in Home Assistant 2023.1. Please adjust to use instance check instead.. Please report issue to the custom integration author for ha_kia_hyundai using this method at custom_components/ha_kia_hyundai/init.py, line 161: if hass.config.units.is_metric:`

Sensor List Should be Limited to Supported Features

The sensor list includes sensors for features that are not available in my car. For example, I do not have a heated steering wheel. I believe that the API response indicates whether the car has a specific feature. The sensor list should be limited to those sensors that are relevant to the specific car.

Missing vehicle ID, Hyundai Ioniq EV 2021, Canada

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

Describe the bug
A clear and concise description of what the bug is.

Debug logs if an error occurred
This error originated from a custom integration.

Logger: custom_components.ha_kia_hyundai.vehicle
Source: custom_components/ha_kia_hyundai/api_cloud_ca.py:317
Integration: Kia/Hyundai (documentation, issues)
First occurred: 3:38:25 PM (2 occurrences)
Last logged: 3:38:38 PM

Unexpected error fetching Vehicle XkfhdHMVuCM2Ir4ss1Ju3Q== data: _post_request_with_logging_and_errors_raised() missing 1 required positional argument: 'vehicle_id'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
return await self.update_method()
File "/config/custom_components/ha_kia_hyundai/vehicle.py", line 117, in async_update_data
await self.api_cloud.update(vehicle=self)
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 33, in request_with_active_session_wrapper
return await func(*args, **kwargs)
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 317, in update
pin_token = await self.api.get_pin_token(
File "/usr/local/lib/python3.9/site-packages/kia_hyundai_api/ca.py", line 184, in get_pin_token
response = await self._post_request_with_logging_and_errors_raised(
File "/usr/local/lib/python3.9/site-packages/kia_hyundai_api/ca.py", line 33, in request_with_logging_wrapper
response = await func(*args, **kwargs)
TypeError: _post_request_with_logging_and_errors_raised() missing 1 required positional argument: 'vehicle_id'

Outlined here: https://github.com/dahlb/ha_kia_hyundai/blob/master/README.m

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

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

Additional context
Add any other context about the problem here.

Error comparing int and datetime

Logger: homeassistant.components.script.car_climate_waiting
Source: custom_components/kia_uvo/vehicle.py:148
Integration: Script (documentation, issues)
First occurred: 10:08:13 AM (2 occurrences)
Last logged: 10:08:13 AM

car: climate waiting: Repeat at step 1: Error executing script. Unexpected error for call_service at pos 2: '>' not supported between instances of 'datetime.timedelta' and 'int'
car: climate waiting: Error executing script. Unexpected error for repeat at pos 1: '>' not supported between instances of 'datetime.timedelta' and 'int'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 371, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 571, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/config/custom_components/kia_uvo/init.py", line 78, in async_handle_request_sync
await hass.async_create_task(hass_vehicle.request_sync())
File "/config/custom_components/kia_uvo/vehicle.py", line 186, in request_sync
await self.api_cloud.request_sync(vehicle=self)
File "/config/custom_components/kia_uvo/api_cloud_us_kia.py", line 33, in request_with_active_session_wrapper
return await func(*args, **kwargs)
File "/config/custom_components/kia_uvo/api_cloud_us_kia.py", line 279, in request_sync
await vehicle.update()
File "/config/custom_components/kia_uvo/vehicle.py", line 148, in update
if age_of_last_sync > force_scan_interval:
TypeError: '>' not supported between instances of 'datetime.timedelta' and 'int'

won't connect

error during setup: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://www.mybluelink.ca/tods/api/lgn')

2022-10-15 11:07:07.891 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Sonata (SONATA HEV) for ha_kia_hyundai
File "/config/custom_components/ha_kia_hyundai/init.py", line 242, in async_setup_entry
File "/config/custom_components/ha_kia_hyundai/api_cloud.py", line 49, in get_vehicle
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 33, in request_with_active_session_wrapper
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 62, in get_vehicles
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 51, in _get_access_token
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 56, in login
File "/config/custom_components/ha_kia_hyundai/init.py", line 250, in async_setup_entry
File "/config/custom_components/ha_kia_hyundai/api_cloud.py", line 49, in get_vehicle
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 33, in request_with_active_session_wrapper
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 62, in get_vehicles
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 51, in _get_access_token
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 56, in login

UNLOCK Request Fails

Region and Brand of car
US / Kia Niro

Describe the bug
The UNLOCK requests displays a "failed to call service..." message. I am posting the issue because the traceback shows that something unexpected happened, as opposed to this being a feature that is not yet implemented,

Debug logs if an error occurred

2021-12-29 19:34:31 DEBUG (MainThread) [kia_hyundai_api.us_kia] sending https://api.owners.kia.com/apigw/v1/rems/door/unlock request
2021-12-29 19:34:32 DEBUG (MainThread) [kia_hyundai_api.us_kia] response headers:<CIMultiDictProxy('Server': 'KMA', 'Date': 'Thu, 30 Dec 2021 00:34:32 GMT', 'Content-Length': '99', 'Content-Type': 'application/json', 'Xid': '2243dae3-80ca-4b28-8916-fe2d7bd699fe')>
2021-12-29 19:34:32 DEBUG (MainThread) [kia_hyundai_api.us_kia] response text:{"status":{"statusCode":1,"errorType":1,"errorCode":1072,"errorMessage":"Vehicle is not enrolled"}}
2021-12-29 19:34:32 DEBUG (MainThread) [kia_hyundai_api.us_kia] error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1072,"errorMessage":"Vehicle is not enrolled"}}
2021-12-29 19:34:32 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1659636776] api error:Vehicle is not enrolled
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 209, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 663, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 896, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 700, in _handle_entity_call
await result
File "/config/custom_components/ha_kia_hyundai/lock.py", line 51, in async_unlock
await self.hass.async_create_task(
File "/config/custom_components/ha_kia_hyundai/vehicle.py", line 201, in lock_action
await self.api_cloud.lock(vehicle=self, action=action)
File "/config/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 30, in request_with_active_session_wrapper
return await func(*args, **kwargs)
File "/config/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 279, in lock
xid = await self.api.unlock(session_id, vehicle.key)
File "/usr/local/lib/python3.9/site-packages/kia_hyundai_api/us_kia.py", line 216, in unlock
response = await self._get_request_with_logging_and_errors_raised(
File "/usr/local/lib/python3.9/site-packages/kia_hyundai_api/us_kia.py", line 47, in request_with_logging_wrapper
raise ClientError(f"api error:{response_json['status']['errorMessage']}")
aiohttp.client_exceptions.ClientError: api error:Vehicle is not enrolled

Additional context
My car is enrolled in UVO Connect, at least for now, and lock/unlock works correctly from my Phone App.

Multiple Car support

Is your feature request related to a problem? Please describe.
Be able to support two or more cars

Describe the solution you'd like
Add this integration more then once in HA

Describe alternatives you've considered

  1. Having one installation handle multiple cars
  2. Allowing multiple installations within HA

I think the solution is as simple as prefixing the internal storage like:
async def async_setup_entry(hass, entry, async_add_entities):
"""Config entry example."""
# assuming API object stored here by init.py
api = hass.data[DOMAIN][entry.entry_id]
reference: https://developers.home-assistant.io/docs/integration_fetching_data/

Integration Error - Could not convert string to float: '01H'

Region and Brand of car
US / Hyundai Sante Fe

Describe the bug
After entering all the configuration details no data appears in the dashboard. When you view the Integrations screen you see "Retrying setup..." with error details. See below for traceback.

I am using v1.4.0, updated today.

Debug logs if an error occurred

This error originated from a custom integration.

Logger: custom_components.ha_kia_hyundai.vehicle
Source: custom_components/ha_kia_hyundai/util.py:61
Integration: Kia/Hyundai (documentation, issues)
First occurred: 1:36:27 PM (3 occurrences)
Last logged: 1:36:47 PM

Unexpected error fetching Vehicle KM8SNXXXXXX data: could not convert string to float: '01H'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/ha_kia_hyundai/vehicle.py", line 112, in async_update_data
    await self.api_cloud.update(vehicle=self)
  File "/config/custom_components/ha_kia_hyundai/api_cloud_us_hyundai.py", line 297, in update
    vehicle.climate_temperature_value = safely_get_json_value(
  File "/config/custom_components/ha_kia_hyundai/util.py", line 61, in safely_get_json_value
    value = callable_to_cast(value)
ValueError: could not convert string to float: '01H'

To Reproduce
Setup integration. Error shows that vehicle is found but couldn't setup.

Expected behavior
Integration setup and device/entities installed.

Screenshots*
image

update versions

manifest.json and setup.py versions should match release tags

issue to connect

when I try to connect the integration, with kia ou Hyundai canada (I have both car) I have this error

image

HA reports range in miles/km unpredictably

USA Hyundai Ioniq 5

Describe the bug
Home Assistant sometimes reports range in miles, other times in kilometres.

Expected behavior
Report range in miles only

Screenshots
image

Picking which car to track

Is your feature request related to a problem? Please describe.
I don't always want to use the first car from the api.

Describe the solution you'd like
Add a second step to the config flow, step one is auth (region if applicable), step is selecting vehicle from list

SSL: Wrong signature type error on login

Region and Brand of car
Kia/USA

Describe the bug
Login fails during start up or trying to re-add the integration. Logs show an error: SSL: WRONG_SIGNATURE_TYPE

Debug logs if an error occurred

2022-07-12 17:39:35 DEBUG (MainThread) [custom_components.ha_kia_hyundai.api_cloud_util] US KIA in use
2022-07-12 17:39:35 DEBUG (MainThread) [kia_hyundai_api.us_kia] sending https://api.owners.kia.com/apigw/v1/prof/authUser request with {'deviceKey': '', 'deviceType': 2, 'userCredential': {'userId': '***', 'password': '***'}}
2022-07-12 17:39:35 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
    await waiter
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 975, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:997)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 277, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/ha_kia_hyundai/config_flow.py", line 141, in async_step_auth
    await api_cloud.login()
  File "/config/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 82, in login
    self._session_id: str = await self.api.login(self.username, self.password)
  File "/usr/local/lib/python3.10/site-packages/kia_hyundai_api/us_kia.py", line 135, in login
    await self._post_request_with_logging_and_errors_raised(
  File "/usr/local/lib/python3.10/site-packages/kia_hyundai_api/us_kia.py", line 29, in request_with_logging_wrapper
    response = await func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/kia_hyundai_api/us_kia.py", line 117, in _post_request_with_logging_and_errors_raised
    return await self.api_session.post(url=url, json=json_body, headers=headers)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 990, in _wrap_create_connection
    raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host api.owners.kia.com:443 ssl:default [[SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:997)]

To Reproduce
Steps to reproduce the behavior:

  1. Click add integration, select Kia/Hyundai
  2. Chose region US; brand: Kia
  3. Enter username and password.
  4. UI shows unknown error; logs show SSL:WRONG_SIGNATURE_TYPE

Expected behavior
Successful login. This integration was working for me before. I didn't happen to notice if it stopped working after a particular HA upgrade, but I don't think there's been a new release of this integration since it was working for me.

commands, unlock may not be working

Not sure if this is problem with my setup or integration. Unlock fails. To tell the truth I don't think I've ever tried so don't if it ever worked. the integration does connect and retrieve the current car status, location, etc.

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/ha_kia_hyundai/api_cloud_ca.py:370
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:05:14 PM (2 occurrences)
Last logged: 7:23:06 PM

[2440435864] Ca.unlock() got an unexpected keyword argument 'saccess_token'
[2422746776] Ca.unlock() got an unexpected keyword argument 'saccess_token'

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 202, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 207, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
await result
File "/config/custom_components/ha_kia_hyundai/lock.py", line 51, in async_unlock
await self.hass.async_create_task(
File "/config/custom_components/ha_kia_hyundai/vehicle.py", line 206, in lock_action
await self.api_cloud.lock(vehicle=self, action=action)
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 33, in request_with_active_session_wrapper
return await func(*args, **kwargs)
File "/config/custom_components/ha_kia_hyundai/api_cloud_ca.py", line 370, in lock
xid = await self.api.unlock(
TypeError: Ca.unlock() got an unexpected keyword argument 'saccess_token'

invalid vehicle for session error

Logger: kia_uvo_api.kia_us
Source: /usr/local/lib/python3.9/site-packages/kia_uvo_api/kia_us.py:45
First occurred: 6:11:03 PM (123 occurrences)
Last logged: 8:13:02 PM

error: unknown error response {"status":{"statusCode":1,"errorType":1,"errorCode":1005,"errorMessage":"Invalid vehicle for current session"}}

Running into 'dh key too small' for Hyundai

Discussed in #57

Originally posted by jpantuso July 19, 2022
Bringing this up here before I resort to poking into the integration internals myself.

In the UI I get "Unknown error occurred" on a login attempt during initial configuration of the integration.

It looks like it is not actually an error with the integration though, the 'dh key too small' in aiohttp I can find multiple discussions around and potential fixes. This is happening on a fresh install of HAOS (aka Alpine 3.16) on a NUC, so it seems like it would be a problem others will hit since this seems to be dependent upon the hyndai back end having weak SSL if I'm understanding things correctly.

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/ha_kia_hyundai/api_cloud_us_hyundai.py:66
Integration: Kia/Hyundai (documentation, issues)
First occurred: 10:08:06 AM (1 occurrences)
Last logged: 10:08:06 AM

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
transport, protocol = await self._create_connection_transport(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
await waiter
File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "/usr/local/lib/python3.10/ssl.py", line 975, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:997)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
result = await method(view, request, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 277, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/ha_kia_hyundai/config_flow.py", line 141, in async_step_auth
await api_cloud.login()
File "/config/custom_components/ha_kia_hyundai/api_cloud_us_hyundai.py", line 66, in login
self._access_token, _, _ = await self.api.login(
File "/usr/local/lib/python3.10/site-packages/kia_hyundai_api/us_hyundai.py", line 166, in login
await self._post_request_with_logging_and_errors_raised(
File "/usr/local/lib/python3.10/site-packages/kia_hyundai_api/us_hyundai.py", line 31, in request_with_logging_wrapper
response = await func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kia_hyundai_api/us_hyundai.py", line 134, in _post_request_with_logging_and_errors_raised
return await self.api_session.post(url=url, json=json_body, headers=headers)
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 990, in _wrap_create_connection
raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host api.telematics.hyundaiusa.com:443 ssl:default [[SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:997)]
<<

Update error

This error originated from a custom integration.

Logger: custom_components.kia_uvo
Source: custom_components/kia_uvo/init.py:169
Integration: Kia Uvo (documentation, issues)
First occurred: 6:01:53 AM (34 occurrences)
Last logged: 8:40:53 AM

Exception in interval update : interval sync request failed, waiting for REQUEST_TO_SYNC_COOLDOWN:0:15:00; age_of_last_request_to_sync:0:00:18.462303
Exception in interval update : interval sync request failed, waiting for REQUEST_TO_SYNC_COOLDOWN:0:15:00; age_of_last_request_to_sync:0:01:18.463230
Exception in interval update : interval sync request failed, waiting for REQUEST_TO_SYNC_COOLDOWN:0:15:00; age_of_last_request_to_sync:0:02:18.464516
Exception in interval update : interval sync request failed, waiting for REQUEST_TO_SYNC_COOLDOWN:0:15:00; age_of_last_request_to_sync:0:00:45.670928
Exception in interval update : '>' not supported between instances of 'datetime.timedelta' and 'int'

Update config flow for CA

  1. Adding Region and Brand to config flow as step before current first step
  2. if region is CA add PIN input to current first step

progress towards #25

Add start/stop charge and set charge limits for Hyundai USA

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Per the readme, starting/stopping the charge and setting the charge limit is not available in the USA for Hyundai. I'd like this added.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Being able to start/stop the charge and setting the charge limit.

Include the logs of the end point from Data in HA if this is a sensor

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Not sure if this is some kind of API limitation or what. If it is I totally understand. Just would like to be able to control this in HASS for my Ioniq 5.

Unable to get SyncDate

Please check Services, Known Bug / Issues and Troubleshooting over here first: https://github.com/dahlb/ha_kia_hyundai/blob/master/README.md
Region and Brand of car
US, KIA Soul EV

Describe the bug
Loading the custom component in HA fails causing the component to not load. Looks like KIA may have changed the output of the returned json data and it no longer includes syncDate, possibly others. Just a guess.. will try to load the data in the api project. Error started today.

Debug logs if an error occurred
2023-02-15 16:32:58.717 ERROR (MainThread) [custom_components.ha_kia_hyundai.vehicle] Unexpected error fetching Vehicle 0***** data: 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
self.data = await self._async_update_data()
File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
return await self.update_method()
File "/home/homeassistant/.homeassistant/custom_components/ha_kia_hyundai/vehicle.py", line 116, in async_update_data
await self.api_cloud.update(vehicle=self)
File "/home/homeassistant/.homeassistant/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 32, in request_with_active_session_wrapper
return await func(args, kwargs)
File "/home/homeassistant/.homeassistant/custom_components/ha_kia_hyundai/api_cloud_us_kia.py", line 120, in update
last_updated_str=vehicle_status["syncDate"]["utc"],
TypeError: 'NoneType' object is not subscriptable
2023-02-15 16:32:58.722 DEBUG (MainThread) [custom_components.ha_kia_hyundai.vehicle] Finished fetching Vehicle 0
** data in 0.326 seconds (success: False)

To Reproduce
Steps to reproduce the behavior:

  1. Restart HA
  2. See error

Expected behavior
custom component to load without issue

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

Additional context
Add any other context about the problem here.

Running HA 2023.2.2 and ha_kia_hyundai v1.7.3

Improvement: debug sensors

The API returns all sorts of interesting data such as whether the car is financed, the car's color, etc. Might be nice to have that data included as a device attribute, assuming HA allows for free-form device attributes.

Integration is using deprecated `DEVICE_CLASS_*` constants

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

n/a

Describe the bug

This custom integration uses deprecated DEVICE_CLASS_* constants in its codebase.

The DEVICE_CLASS_* constants have been deprecated and replaced in Home Assistant Core 2021.12 (over a year ago). I would highly suggest updating/migrating this integration to the new enums.

For example, for the device classes supported by the sensor platform, there is now a SensorDeviceClass enum. So if a sensor previously used the DEVICE_CLASS_ENERGY constant, it should now use SensorDeviceClass.ENERGY. Other platforms (like binary_sensor, and number) provide similar enumerations for their supported device classes.

The migration thus only consists of replacing constants with an enumeration member and is, therefore, very low impact and should be fairly straightforward.

If I can help resolve any questions regarding this change or migration, feel free to ask or respond to this issue. I'm happy to help!

Kindest regards,

../Frenck

Debug logs if an error occurred

n/a

To Reproduce

n/a

Expected behavior

n/a

Screenshots

n/a

Additional context

n/a

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.