Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 9, 2025
1 parent d1ef964 commit 1991ef0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions hyundai_kia_connect_api/KiaUvoApiAU.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,32 @@ def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> No
{
"status": response["resMsg"],
"vehicleLocation": location,
},
},
)

if vehicle.odometer == None:
# Some cars (e.g. 2024 Niro EV) report as not supporting ccs2 but
# only report the odometer value in the ccs2 status response.
# So if the odo is None we will try to request the ccs2 status.
try:
url = self.SPA_API_URL + "vehicles/" + vehicle.id + "/ccs2/carstatus/latest"
url = (
self.SPA_API_URL
+ "vehicles/"
+ vehicle.id
+ "/ccs2/carstatus/latest"
)
ccs2Response = requests.get(
url,
headers=self._get_authenticated_headers(
token, vehicle.ccu_ccs2_protocol_support
),
).json()

_LOGGER.debug(f"{DOMAIN} - get_cached_vehicle_status ccs2 response: {ccs2Response}")

_LOGGER.debug(
f"{DOMAIN} - get_cached_vehicle_status ccs2 response: {ccs2Response}"
)
_check_response_for_errors(ccs2Response)

state = ccs2Response["resMsg"]["state"]["Vehicle"]
odo = get_child_value(state, "Drivetrain.Odometer")
if odo != None:
Expand All @@ -272,7 +279,6 @@ def update_vehicle_with_cached_state(self, token: Token, vehicle: Vehicle) -> No
""",
exc_info=e,
)


if (
vehicle.engine_type == ENGINE_TYPES.EV
Expand Down

0 comments on commit 1991ef0

Please sign in to comment.