Skip to content

Commit

Permalink
fix: step over calculativeodo if not found or zero, to avoid exceptio…
Browse files Browse the repository at this point in the history
…ns. (#523)

For vechicles lacking CalculativeOdo in the eu, this change means that
it will silently continue and not throw as is in the current version.
Fixes the exception mentioned in
Hyundai-Kia-Connect/kia_uvo#842.
Note, if this key is actually suposed to be present for all vechicles
(including phev which seems to be the issue here), then this will just
hush the exception and obv not fix the main issue.

---------

Co-authored-by: magnuselden <magnu@DESKTOP-ACV2GPT>
Co-authored-by: cdnninja <[email protected]>
  • Loading branch information
3 people authored Mar 20, 2024
1 parent 2e79b73 commit 4752bc8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hyundai_kia_connect_api/KiaUvoApiEU.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,15 @@ def _get_driving_info(self, token: Token, vehicle: Vehicle) -> dict:
for drivingInfoItem in response30d["resMsg"]["drivingInfo"]:
if (
drivingInfoItem["drivingPeriod"] == 0
and drivingInfoItem["calculativeOdo"] > 0
and next(
(
v
for k, v in drivingInfoItem.items()
if k.lower() == "calculativeodo"
),
0,
)
> 0
):
drivingInfo["consumption30d"] = round(
drivingInfoItem["totalPwrCsp"]
Expand Down

0 comments on commit 4752bc8

Please sign in to comment.