Migrate Crownstone to has entity name (#96566)

This commit is contained in:
Joost Lekkerkerker 2023-07-18 20:39:37 +02:00 committed by GitHub
parent ac06905b1c
commit 6afa49a441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View file

@ -12,6 +12,7 @@ class CrownstoneBaseEntity(Entity):
"""Base entity class for Crownstone devices.""" """Base entity class for Crownstone devices."""
_attr_should_poll = False _attr_should_poll = False
_attr_has_entity_name = True
def __init__(self, device: Crownstone) -> None: def __init__(self, device: Crownstone) -> None:
"""Initialize the device.""" """Initialize the device."""

View file

@ -71,6 +71,7 @@ class CrownstoneEntity(CrownstoneBaseEntity, LightEntity):
""" """
_attr_icon = "mdi:power-socket-de" _attr_icon = "mdi:power-socket-de"
_attr_name = None
def __init__( def __init__(
self, crownstone_data: Crownstone, usb: CrownstoneUart | None = None self, crownstone_data: Crownstone, usb: CrownstoneUart | None = None
@ -79,7 +80,6 @@ class CrownstoneEntity(CrownstoneBaseEntity, LightEntity):
super().__init__(crownstone_data) super().__init__(crownstone_data)
self.usb = usb self.usb = usb
# Entity class attributes # Entity class attributes
self._attr_name = str(self.device.name)
self._attr_unique_id = f"{self.cloud_id}-{CROWNSTONE_SUFFIX}" self._attr_unique_id = f"{self.cloud_id}-{CROWNSTONE_SUFFIX}"
@property @property