Skip to content

Commit

Permalink
fix(AU): drive info error caused by indent, include phev (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdnninja authored Oct 31, 2024
1 parent bc735d9 commit ecef763
Showing 1 changed file with 14 additions and 7 deletions.
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

0 comments on commit ecef763

Please sign in to comment.