mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
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:
parent
d0632ab636
commit
d0983b69df
@ -328,7 +328,7 @@ class RfxtrxDevice(Entity):
|
||||
self._event = event
|
||||
self._state = datas[ATTR_STATE]
|
||||
self._should_fire_event = datas[ATTR_FIRE_EVENT]
|
||||
self._unique_id = f"{slugify(self._event.device.type_string.lower())}_{slugify(self._event.device.id_string.lower())}"
|
||||
self._unique_id = f"{event.device.packettype:x}_{event.device.subtype:x}_{event.device.id_string}"
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
@ -162,14 +162,15 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
||||
self._data_bits = data_bits
|
||||
self._cmd_on = cmd_on
|
||||
self._cmd_off = cmd_off
|
||||
self._unique_id = f"{slugify(self.event.device.type_string.lower())}_{slugify(self.event.device.id_string.lower())}"
|
||||
|
||||
if data_bits is not None:
|
||||
self._masked_id = get_pt2262_deviceid(
|
||||
event.device.id_string.lower(), data_bits
|
||||
)
|
||||
self._unique_id = f"{event.device.packettype:x}_{event.device.subtype:x}_{self._masked_id}"
|
||||
else:
|
||||
self._masked_id = None
|
||||
self._unique_id = f"{event.device.packettype:x}_{event.device.subtype:x}_{event.device.id_string}"
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Restore RFXtrx switch device state (ON/OFF)."""
|
||||
|
@ -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)."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user