From b43908fe8d11e319ce032708be326ec804aae5ce Mon Sep 17 00:00:00 2001 From: Tuen Lee Date: Sun, 19 Nov 2023 00:34:52 +0100 Subject: [PATCH] change entity_id with polestar_unique_id --- custom_components/polestar_api/sensor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/polestar_api/sensor.py b/custom_components/polestar_api/sensor.py index 31b293d..f480901 100644 --- a/custom_components/polestar_api/sensor.py +++ b/custom_components/polestar_api/sensor.py @@ -179,10 +179,11 @@ def __init__(self, """Initialize the sensor.""" super().__init__(device) self._device = device - # get the first 8 character of the id - unique_id = device.vin[:8] + # get the last 4 character of the id + unique_id = device.vin[-4:] + self.entity_id = f"{POLESTAR_API_DOMAIN}.'polestar_'.{unique_id}_{description.key}" self._attr_name = f"{description.name}" - self._attr_unique_id = f"{unique_id}-{description.key}" + self._attr_unique_id = f"polestar_{unique_id}-{description.key}" self.value = None self.description = description