]> git.giorgioravera.it Git - mercedes_me_api.git/commitdiff
Add unique IDs
authorDaniel Rheinbay <danielrheinbay@gmail.com>
Sun, 6 Dec 2020 13:21:19 +0000 (14:21 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Thu, 17 Dec 2020 10:13:31 +0000 (11:13 +0100)
Add unique IDs for sensors. This allows users to rename the sensors and add icons all from within Home Assistant GUI.

custom_components/mercedesmeapi/resources.py

index 8a7b62967c907a73c535f4e4ded9f69191f5142f..234991d24e50737eb227b23d671d20aaf4bb7c7e 100644 (file)
@@ -63,6 +63,11 @@ class MercedesMeResource (Entity):
         self._lastupdate = datetime.fromtimestamp(self._timestamp/1000)
         self._valid = True
 
+    @property
+    def unique_id(self):
+        """Return the unique id of the sensor."""
+        return f"{self._vin}-{self._name}"
+
     @property
     def name(self):
         """Return the name of the sensor."""