Switch what is used for unique identifier (#37581)

* Switch what is used for device identifier

type_string can be changed if new device types are added based
on same driver.

* No need to slugify unique id
This commit is contained in:
Joakim Plate authored and GitHub committed 2020-07-07 21:50:19 +02:00
1 parent d0632ab636
commit d0983b69df
3 files changed
+6 -3

No files matched your search

+3 -1
View File
@@ -119,7 +119,9 @@ class RfxtrxSensor(Entity):
self.should_fire_event = should_fire_event
self.data_type = data_type
self._unit_of_measurement = DATA_TYPES.get(data_type, "")
self._unique_id = f"{slugify(device.type_string.lower())}_{slugify(device.id_string.lower())}_{slugify(data_type)}"
self._unique_id = (
f"{device.packettype:x}_{device.subtype:x}_{device.id_string}_{data_type}"
)
async def async_added_to_hass(self):
"""Restore RFXtrx switch device state (ON/OFF)."""