From 0f108e7b096bf2023be30a76db7ecf7334eb0e97 Mon Sep 17 00:00:00 2001 From: WillemD61 <96531991+WillemD61@users.noreply.github.com> Date: Thu, 5 Oct 2023 09:49:52 +0200 Subject: [PATCH 1/2] correction to get total power consumed from driving info total power consumed is obtained from drivingInfo, not drivingInfoDetail --- hyundai_kia_connect_api/KiaUvoApiEU.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hyundai_kia_connect_api/KiaUvoApiEU.py b/hyundai_kia_connect_api/KiaUvoApiEU.py index b5b018bc..b6fce10a 100644 --- a/hyundai_kia_connect_api/KiaUvoApiEU.py +++ b/hyundai_kia_connect_api/KiaUvoApiEU.py @@ -1031,8 +1031,8 @@ def _get_driving_info(self, token: Token, vehicle: Vehicle) -> dict: response30d = response30d.json() _LOGGER.debug(f"{DOMAIN} - get_driving_info response30d {response30d}") _check_response_for_errors(response30d) - if get_child_value(responseAlltime, "resMsg.drivingInfoDetail.0"): - drivingInfo = responseAlltime["resMsg"]["drivingInfoDetail"][0] + if get_child_value(responseAlltime, "resMsg.drivingInfo.0"): + drivingInfo = responseAlltime["resMsg"]["drivingInfo"][0] drivingInfo["dailyStats"] = [] for day in response30d["resMsg"]["drivingInfoDetail"]: From 4606b050df9dcff7c9d757177a571eb070359d99 Mon Sep 17 00:00:00 2001 From: WillemD61 <96531991+WillemD61@users.noreply.github.com> Date: Sat, 7 Oct 2023 20:02:09 +0200 Subject: [PATCH 2/2] adjustment for total odo get total odometer value from responseAlltime.drivingInfo and added extra check before calculating daily stats from response30d.drivingInfoDetail --- hyundai_kia_connect_api/KiaUvoApiEU.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hyundai_kia_connect_api/KiaUvoApiEU.py b/hyundai_kia_connect_api/KiaUvoApiEU.py index b6fce10a..b1e34bd0 100644 --- a/hyundai_kia_connect_api/KiaUvoApiEU.py +++ b/hyundai_kia_connect_api/KiaUvoApiEU.py @@ -1035,18 +1035,19 @@ def _get_driving_info(self, token: Token, vehicle: Vehicle) -> dict: drivingInfo = responseAlltime["resMsg"]["drivingInfo"][0] drivingInfo["dailyStats"] = [] - for day in response30d["resMsg"]["drivingInfoDetail"]: - processedDay = DailyDrivingStats( - date=dt.datetime.strptime(day["drivingDate"], "%Y%m%d"), - total_consumed=day["totalPwrCsp"], - engine_consumption=day["motorPwrCsp"], - climate_consumption=day["climatePwrCsp"], - onboard_electronics_consumption=day["eDPwrCsp"], - battery_care_consumption=day["batteryMgPwrCsp"], - regenerated_energy=day["regenPwr"], - distance=day["calculativeOdo"], - ) - drivingInfo["dailyStats"].append(processedDay) + if get_child_value(response30d, "resMsg.drivingInfoDetail.0"): + for day in response30d["resMsg"]["drivingInfoDetail"]: + processedDay = DailyDrivingStats( + date=dt.datetime.strptime(day["drivingDate"], "%Y%m%d"), + total_consumed=day["totalPwrCsp"], + engine_consumption=day["motorPwrCsp"], + climate_consumption=day["climatePwrCsp"], + onboard_electronics_consumption=day["eDPwrCsp"], + battery_care_consumption=day["batteryMgPwrCsp"], + regenerated_energy=day["regenPwr"], + distance=day["calculativeOdo"], + ) + drivingInfo["dailyStats"].append(processedDay) for drivingInfoItem in response30d["resMsg"]["drivingInfo"]: if drivingInfoItem["drivingPeriod"] == 0: