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(AU): drive info error caused by indent, include phev #665

Merged
merged 2 commits into from
Oct 31, 2024
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
21 changes: 14 additions & 7 deletions hyundai_kia_connect_api/KiaUvoApiAU.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> No
},
)

if vehicle.engine_type == ENGINE_TYPES.EV:
if (
vehicle.engine_type == ENGINE_TYPES.EV
or vehicle.engine_type == ENGINE_TYPES.PHEV
):
try:
state = self._get_driving_info(token, vehicle)
except Exception as e:
Expand All @@ -255,8 +258,8 @@ def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> No
""",
exc_info=e,
)
else:
self._update_vehicle_drive_info(vehicle, state)
else:
self._update_vehicle_drive_info(vehicle, state)

def force_refresh_vehicle_state(self, token: Token, vehicle: Vehicle) -> None:
status = self._get_forced_vehicle_state(token, vehicle)
Expand All @@ -270,15 +273,19 @@ def force_refresh_vehicle_state(self, token: Token, vehicle: Vehicle) -> None:
)
# Only call for driving info on cars we know have a chance of supporting it.
# Could be expanded if other types do support it.
if vehicle.engine_type == ENGINE_TYPES.EV:
if (
vehicle.engine_type == ENGINE_TYPES.EV
or vehicle.engine_type == ENGINE_TYPES.PHEV
):
try:
state = self._get_driving_info(token, vehicle)
except Exception as e:
# we don't know if all car types provide this information.
# we also don't know what the API returns if the info is unavailable.
# so, catch any exception and move on.
# we don't know if all car types (ex: ICE cars) provide this
# information. We also don't know what the API returns if
# the info is unavailable. So, catch any exception and move on.
_LOGGER.exception(
"""Failed to parse driving info. Possible reasons:
- incompatible vehicle (ICE)
- new API format
- API outage
""",
Expand Down