Skip to content

Commit aa84498

Browse files
committed
feat: wire vehicle profile fetching into EU login flow
Add _fetch_vehicle_profiles call in VehicleManager.initialize_vehicles() so vehicle profiles are auto-populated on login. Add no-op base method on ApiImpl (needed for test DummyApi). KiaUvoApiEU override fetches /profile endpoint for each vehicle with graceful degradation on failure.
1 parent 2441599 commit aa84498

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

hyundai_kia_connect_api/ApiImpl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class ApiImpl:
140140
def __init__(self) -> None:
141141
"""Initialize."""
142142

143+
def _fetch_vehicle_profiles(self, token: Token, vehicles: list[Vehicle]) -> None:
144+
"""No-op base. Override in region subclasses with profile endpoint."""
145+
143146
def login(
144147
self,
145148
username: str,

hyundai_kia_connect_api/KiaUvoApiEU.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,21 @@ def _map_vehicle_profile(self, profile_data: dict) -> VehicleProfile:
251251
dtc_categories=dtc_category if dtc_category else None,
252252
)
253253

254+
def _fetch_vehicle_profiles(self, token: Token, vehicles: list[Vehicle]) -> None:
255+
for vehicle in vehicles:
256+
try:
257+
url = self.SPA_API_URL + f"vehicles/{vehicle.id}/profile"
258+
headers = self._get_authenticated_headers(token)
259+
response = requests.get(url, headers=headers, timeout=30)
260+
_check_response_for_errors(response.json())
261+
profile_data = response.json().get("resMsg", {}).get("vinInfo", [])
262+
if profile_data:
263+
vehicle.profile = self._map_vehicle_profile(profile_data[0])
264+
except Exception:
265+
_LOGGER.debug(
266+
f"{DOMAIN} - Vehicle profile fetch failed for {vehicle.id}"
267+
)
268+
254269
def login(
255270
self,
256271
username: str,

hyundai_kia_connect_api/VehicleManager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def initialize_vehicles(self):
127127
"Vehicles already initialized, this will re-initialize and cause data loss mapping errors"
128128
)
129129
vehicles = self.api.get_vehicles(self.token)
130+
self.api._fetch_vehicle_profiles(self.token, vehicles)
130131
for vehicle in vehicles:
131132
vehicle.supports_window_control = self.api.supports_window_control
132133
self.vehicles[vehicle.id] = vehicle

0 commit comments

Comments
 (0)