diff --git a/homeassistant/components/rfxtrx/__init__.py b/homeassistant/components/rfxtrx/__init__.py index fb57359829c..6c631cad029 100644 --- a/homeassistant/components/rfxtrx/__init__.py +++ b/homeassistant/components/rfxtrx/__init__.py @@ -378,6 +378,7 @@ class RfxtrxDevice(Entity): self._state = datas[ATTR_STATE] self._should_fire_event = datas[ATTR_FIRE_EVENT] self._brightness = 0 + self._unique_id = f"{slugify(self._event.device.type_string.lower())}_{slugify(self._event.device.id_string.lower())}" self.added_to_hass = False async def async_added_to_hass(self): @@ -409,6 +410,11 @@ class RfxtrxDevice(Entity): """Return true if unable to access real state of entity.""" return True + @property + def unique_id(self): + """Return unique identifier of remote device.""" + return self._unique_id + def turn_off(self, **kwargs): """Turn the device off.""" self._send_command("turn_off") diff --git a/homeassistant/components/rfxtrx/binary_sensor.py b/homeassistant/components/rfxtrx/binary_sensor.py index 5e610128ea6..6426f824320 100644 --- a/homeassistant/components/rfxtrx/binary_sensor.py +++ b/homeassistant/components/rfxtrx/binary_sensor.py @@ -197,6 +197,7 @@ 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( @@ -255,6 +256,11 @@ class RfxtrxBinarySensor(BinarySensorEntity): """Return true if the sensor state is True.""" return self._state + @property + def unique_id(self): + """Return unique identifier of remote device.""" + return self._unique_id + def apply_cmd(self, cmd): """Apply a command for updating the state.""" if cmd == self.cmd_on: diff --git a/homeassistant/components/rfxtrx/sensor.py b/homeassistant/components/rfxtrx/sensor.py index 759268140fc..1b053156fd8 100644 --- a/homeassistant/components/rfxtrx/sensor.py +++ b/homeassistant/components/rfxtrx/sensor.py @@ -127,6 +127,7 @@ 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(self.event.device.type_string.lower())}_{slugify(self.event.device.id_string.lower())}_{slugify(self.data_type)}" def __str__(self): """Return the name of the sensor.""" @@ -155,3 +156,8 @@ class RfxtrxSensor(Entity): def unit_of_measurement(self): """Return the unit this state is expressed in.""" return self._unit_of_measurement + + @property + def unique_id(self): + """Return unique identifier of remote device.""" + return self._unique_id