Skip to content

Commit 27625e8

Browse files
committed
Wansnt added to all cars :(
1 parent 7a0d6bd commit 27625e8

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

custom_components/cardata/number.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,15 @@ async def async_setup_entry(
6161
entities: list[NumberEntity] = []
6262
created_vins: set[str] = set()
6363

64+
# Get all known VINs (both live MQTT data and restored metadata)
65+
all_vins = set(coordinator.data.keys()) | set(coordinator.device_metadata.keys())
66+
67+
# Filter by allowed VINs if initialized
68+
if coordinator._allowed_vins_initialized:
69+
all_vins = all_vins & coordinator._allowed_vins
70+
6471
# Create manual battery capacity input for each known EV/PHEV vehicle
65-
for vin in coordinator.data.keys():
72+
for vin in all_vins:
6673
# Check if this vehicle has HV battery (EV/PHEV)
6774
vehicle_data = coordinator.data.get(vin, {})
6875
if "vehicle.drivetrain.batteryManagement.header" in vehicle_data:
@@ -79,7 +86,7 @@ async def async_setup_entry(
7986
created_vins.add(vin)
8087
_LOGGER.debug("Created manual battery capacity input for %s (%s)", vehicle_name, redact_vin(vin))
8188

82-
# Restore previously created entities from entity registry (even if VIN not currently online)
89+
# Restore previously created entities from entity registry (for VINs not yet in coordinator data)
8390
entity_registry = async_get(hass)
8491
for entity_entry in async_entries_for_config_entry(entity_registry, entry.entry_id):
8592
if entity_entry.domain != "number":

0 commit comments

Comments
 (0)