Skip to content

Commit c784bd7

Browse files
committed
fixed the bootstrap
boostrap the metadata first so it can proper name all the sensors.
1 parent bc40acd commit c784bd7

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

custom_components/cardata/bootstrap.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)