@@ -75,6 +75,15 @@ async def async_run_bootstrap(hass: HomeAssistant, entry: ConfigEntry) -> None:
7575 name = coordinator .names .get (vin , vin ),
7676 )
7777
78+ # IMPORTANT: Fetch metadata FIRST, before seeding telematic data
79+ # This ensures coordinator.names is populated when sensors are created
80+ from .metadata import async_fetch_and_store_basic_data
81+
82+ await async_fetch_and_store_basic_data (
83+ hass , entry , headers , vins , quota , runtime .session
84+ )
85+
86+ # NOW seed telematic data (sensors will be created with names available)
7887 created_entities = False
7988 container_id = entry .data .get ("hv_container_id" )
8089 if container_id :
@@ -88,18 +97,13 @@ async def async_run_bootstrap(hass: HomeAssistant, entry: ConfigEntry) -> None:
8897 )
8998
9099 if created_entities :
91- from .metadata import async_fetch_and_store_basic_data
92-
93- await async_fetch_and_store_basic_data (
94- hass , entry , headers , vins , quota , runtime .session
95- )
96100 from .telematics import async_update_last_telematic_poll
97101 import time
98102
99103 async_update_last_telematic_poll (hass , entry , time .time ())
100104 else :
101105 _LOGGER .debug (
102- "Bootstrap did not seed new descriptors for entry %s; basic data fetch skipped " ,
106+ "Bootstrap did not seed new descriptors for entry %s" ,
103107 entry .entry_id ,
104108 )
105109
@@ -268,4 +272,4 @@ def _build_headers(access_token: str) -> dict[str, str]:
268272 "Authorization" : f"Bearer { access_token } " ,
269273 "x-version" : API_VERSION ,
270274 "Accept" : "application/json" ,
271- }
275+ }
0 commit comments