Fix shared wakelock across Tesla Fleet vehicles (#181658)

This commit is contained in:
Brett Adams
2026-09-11 12:48:32 +02:00
committed by GitHub
parent e2418c5973
commit 3151ca888f
2 changed files with 22 additions and 2 deletions
@@ -1,7 +1,7 @@
"""The Tesla Fleet integration models."""
import asyncio
from dataclasses import dataclass
from dataclasses import dataclass, field
from tesla_fleet_api.const import Scope
from tesla_fleet_api.tesla import EnergySite, VehicleFleet
@@ -34,7 +34,7 @@ class TeslaFleetVehicleData:
vin: str
device: DeviceInfo
signing: bool
wakelock = asyncio.Lock()
wakelock: asyncio.Lock = field(default_factory=asyncio.Lock)
@dataclass
@@ -0,0 +1,20 @@
"""Test the Tesla Fleet models."""
from unittest.mock import Mock
from homeassistant.components.tesla_fleet.models import TeslaFleetVehicleData
def test_wakelock_is_per_instance() -> None:
"""Each vehicle must get its own wakelock, not a lock shared across the account."""
kwargs = {
"api": Mock(),
"coordinator": Mock(),
"vin": "VIN",
"device": Mock(),
"signing": False,
}
a = TeslaFleetVehicleData(**kwargs)
b = TeslaFleetVehicleData(**kwargs)
assert a.wakelock is not b.wakelock