Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(EU): correction to get total power consumed from driving info #419

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions hyundai_kia_connect_api/KiaUvoApiEU.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,22 +1031,23 @@ 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"]:
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:
Expand Down