]> 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)
committerDaniel Rheinbay <danielrheinbay@gmail.com>
Sun, 6 Dec 2020 13:21:19 +0000 (14:21 +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 a6fbece4a6f8d88692c35c877697d6a2dd47c905..6c438729e5cc864bcbe6fb494b4c40b6083c7de7 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."""