mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Attempt to set unique id of rfxtrx device (#37159)
This commit is contained in:
parent
10f296ba17
commit
201dab93ff
@ -378,6 +378,7 @@ class RfxtrxDevice(Entity):
|
|||||||
self._state = datas[ATTR_STATE]
|
self._state = datas[ATTR_STATE]
|
||||||
self._should_fire_event = datas[ATTR_FIRE_EVENT]
|
self._should_fire_event = datas[ATTR_FIRE_EVENT]
|
||||||
self._brightness = 0
|
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
|
self.added_to_hass = False
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
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 if unable to access real state of entity."""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return unique identifier of remote device."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
self._send_command("turn_off")
|
self._send_command("turn_off")
|
||||||
|
@ -197,6 +197,7 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
|||||||
self._data_bits = data_bits
|
self._data_bits = data_bits
|
||||||
self._cmd_on = cmd_on
|
self._cmd_on = cmd_on
|
||||||
self._cmd_off = cmd_off
|
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:
|
if data_bits is not None:
|
||||||
self._masked_id = get_pt2262_deviceid(
|
self._masked_id = get_pt2262_deviceid(
|
||||||
@ -255,6 +256,11 @@ class RfxtrxBinarySensor(BinarySensorEntity):
|
|||||||
"""Return true if the sensor state is True."""
|
"""Return true if the sensor state is True."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return unique identifier of remote device."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
def apply_cmd(self, cmd):
|
def apply_cmd(self, cmd):
|
||||||
"""Apply a command for updating the state."""
|
"""Apply a command for updating the state."""
|
||||||
if cmd == self.cmd_on:
|
if cmd == self.cmd_on:
|
||||||
|
@ -127,6 +127,7 @@ class RfxtrxSensor(Entity):
|
|||||||
self.should_fire_event = should_fire_event
|
self.should_fire_event = should_fire_event
|
||||||
self.data_type = data_type
|
self.data_type = data_type
|
||||||
self._unit_of_measurement = DATA_TYPES.get(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):
|
def __str__(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
@ -155,3 +156,8 @@ class RfxtrxSensor(Entity):
|
|||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit this state is expressed in."""
|
"""Return the unit this state is expressed in."""
|
||||||
return self._unit_of_measurement
|
return self._unit_of_measurement
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return unique identifier of remote device."""
|
||||||
|
return self._unique_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user