Migrate UPB to new entity naming style (#75096)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
pull/74449/head^2
Glenn Waters 2022-07-14 15:56:36 -04:00 committed by GitHub
parent 09f37fc522
commit 72906bf154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -75,11 +75,6 @@ class UpbEntity(Entity):
element_type = "link" if element.addr.is_link else "device"
self._unique_id = f"{unique_id}_{element_type}_{element.addr}"
@property
def name(self):
"""Name of the element."""
return self._element.name
@property
def unique_id(self):
"""Return unique id of the element."""

View File

@ -49,6 +49,8 @@ async def async_setup_entry(
class UpbLight(UpbAttachedEntity, LightEntity):
"""Representation of an UPB Light."""
_attr_has_entity_name = True
def __init__(self, element, unique_id, upb):
"""Initialize an UpbLight."""
super().__init__(element, unique_id, upb)

View File

@ -49,6 +49,11 @@ async def async_setup_entry(
class UpbLink(UpbEntity, Scene):
"""Representation of an UPB Link."""
def __init__(self, element, unique_id, upb):
"""Initialize the base of all UPB devices."""
super().__init__(element, unique_id, upb)
self._attr_name = element.name
async def async_activate(self, **kwargs: Any) -> None:
"""Activate the task."""
self._element.activate()