diff --git a/custom_components/tesla_custom/base.py b/custom_components/tesla_custom/base.py index b6b2b727..a4dae265 100644 --- a/custom_components/tesla_custom/base.py +++ b/custom_components/tesla_custom/base.py @@ -27,6 +27,7 @@ def __init__( self._enabled_by_default: bool = True self.hass = hass self.type = None + self._memorized_unique_id = None def refresh(self) -> None: """Refresh the device data. @@ -106,7 +107,9 @@ def vehicle_name(self) -> str: @property def unique_id(self) -> str: """Return unique id for car entity.""" - return slugify(f"{self._car.vin} {self.type}") + if not self._memorized_unique_id: + self._memorized_unique_id = slugify(f"{self._car.vin} {self.type}") + return self._memorized_unique_id @property def device_info(self) -> DeviceInfo: @@ -145,7 +148,11 @@ def __init__( @property def unique_id(self) -> str: """Return unique id for energy site device.""" - return slugify(f"{self._energysite.energysite_id} {self.type}") + if not self._memorized_unique_id: + self._memorized_unique_id = slugify( + f"{self._energysite.energysite_id} {self.type}" + ) + return self._memorized_unique_id @property def sw_version(self) -> bool: