Check vehicle metadata (#134381)

This commit is contained in:
Brett Adams 2025-01-01 21:09:15 +10:00 committed by GitHub
parent 031de8da51
commit 513c8487c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -85,6 +85,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslemetryConfigEntry) -
scopes = calls[0]["scopes"]
region = calls[0]["region"]
vehicle_metadata = calls[0]["vehicles"]
products = calls[1]["response"]
device_registry = dr.async_get(hass)
@ -102,7 +103,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslemetryConfigEntry) -
)
for product in products:
if "vin" in product and Scope.VEHICLE_DEVICE_DATA in scopes:
if (
"vin" in product
and vehicle_metadata.get(product["vin"], {}).get("access")
and Scope.VEHICLE_DEVICE_DATA in scopes
):
# Remove the protobuff 'cached_data' that we do not use to save memory
product.pop("cached_data", None)
vin = product["vin"]

View File

@ -46,9 +46,25 @@ METADATA = {
"energy_device_data",
"energy_cmds",
],
"vehicles": {
"LRW3F7EK4NC700000": {
"proxy": False,
"access": True,
"polling": True,
"firmware": "2024.44.25",
}
},
}
METADATA_NOSCOPE = {
"uid": "abc-123",
"region": "NA",
"scopes": ["openid", "offline_access", "vehicle_device_data"],
"vehicles": {
"LRW3F7EK4NC700000": {
"proxy": False,
"access": True,
"polling": True,
"firmware": "2024.44.25",
}
},
}