Fix overkiz entity name (#79229)
parent
590d47aad0
commit
d41d09aa7e
|
@ -34,8 +34,17 @@ class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]):
|
|||
self._attr_available = self.device.available
|
||||
self._attr_unique_id = self.device.device_url
|
||||
|
||||
if self.is_sub_device:
|
||||
# In case of sub entity, use the provided label as name
|
||||
self._attr_name = self.device.label
|
||||
|
||||
self._attr_device_info = self.generate_device_info()
|
||||
|
||||
@property
|
||||
def is_sub_device(self) -> bool:
|
||||
"""Return True if device is a sub device."""
|
||||
return "#" in self.device_url and not self.device_url.endswith("#1")
|
||||
|
||||
@property
|
||||
def device(self) -> Device:
|
||||
"""Return Overkiz device linked to this entity."""
|
||||
|
@ -46,7 +55,7 @@ class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]):
|
|||
# Some devices, such as the Smart Thermostat have several devices in one physical device,
|
||||
# with same device url, terminated by '#' and a number.
|
||||
# In this case, we use the base device url as the device identifier.
|
||||
if "#" in self.device_url and not self.device_url.endswith("#1"):
|
||||
if self.is_sub_device:
|
||||
# Only return the url of the base device, to inherit device name and model from parent device.
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.executor.base_device_url)},
|
||||
|
@ -103,6 +112,10 @@ class OverkizDescriptiveEntity(OverkizEntity):
|
|||
self.entity_description = description
|
||||
self._attr_unique_id = f"{super().unique_id}-{self.entity_description.key}"
|
||||
|
||||
if self.is_sub_device:
|
||||
# In case of sub device, use the provided label and append the name of the type of entity
|
||||
self._attr_name = f"{self.device.label} {description.name}"
|
||||
|
||||
|
||||
# Used by state translations for sensor and select entities
|
||||
@unique
|
||||
|
|
Loading…
Reference in New Issue