Add unique_id to Wirelesstag entities. (#95631)

* Add unique_id to Wirelesstag entities.

* Update homeassistant/components/wirelesstag/binary_sensor.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/wirelesstag/sensor.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

* Update homeassistant/components/wirelesstag/switch.py

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
Dave Pearce 2023-06-30 15:04:23 -04:00 committed by GitHub
parent c6210b68bd
commit 982a52b91d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 0 deletions

View File

@ -100,6 +100,7 @@ class WirelessTagBinarySensor(WirelessTagBaseSensor, BinarySensorEntity):
super().__init__(api, tag) super().__init__(api, tag)
self._sensor_type = sensor_type self._sensor_type = sensor_type
self._name = f"{self._tag.name} {self.event.human_readable_name}" self._name = f"{self._tag.name} {self.event.human_readable_name}"
self._attr_unique_id = f"{self.tag_id}_{self._sensor_type}"
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Register callbacks.""" """Register callbacks."""

View File

@ -100,6 +100,7 @@ class WirelessTagSensor(WirelessTagBaseSensor, SensorEntity):
self._sensor_type = description.key self._sensor_type = description.key
self.entity_description = description self.entity_description = description
self._name = self._tag.name self._name = self._tag.name
self._attr_unique_id = f"{self.tag_id}_{self._sensor_type}"
# I want to see entity_id as: # I want to see entity_id as:
# sensor.wirelesstag_bedroom_temperature # sensor.wirelesstag_bedroom_temperature

View File

@ -82,6 +82,7 @@ class WirelessTagSwitch(WirelessTagBaseSensor, SwitchEntity):
super().__init__(api, tag) super().__init__(api, tag)
self.entity_description = description self.entity_description = description
self._name = f"{self._tag.name} {description.name}" self._name = f"{self._tag.name} {description.name}"
self._attr_unique_id = f"{self.tag_id}_{description.key}"
def turn_on(self, **kwargs: Any) -> None: def turn_on(self, **kwargs: Any) -> None:
"""Turn on the switch.""" """Turn on the switch."""