mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Fix overkiz entity name (#79229)
This commit is contained in:
parent
d7be3c8780
commit
0431575199
@ -34,8 +34,17 @@ class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]):
|
|||||||
self._attr_available = self.device.available
|
self._attr_available = self.device.available
|
||||||
self._attr_unique_id = self.device.device_url
|
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()
|
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
|
@property
|
||||||
def device(self) -> Device:
|
def device(self) -> Device:
|
||||||
"""Return Overkiz device linked to this entity."""
|
"""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,
|
# Some devices, such as the Smart Thermostat have several devices in one physical device,
|
||||||
# with same device url, terminated by '#' and a number.
|
# with same device url, terminated by '#' and a number.
|
||||||
# In this case, we use the base device url as the device identifier.
|
# 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.
|
# Only return the url of the base device, to inherit device name and model from parent device.
|
||||||
return {
|
return {
|
||||||
"identifiers": {(DOMAIN, self.executor.base_device_url)},
|
"identifiers": {(DOMAIN, self.executor.base_device_url)},
|
||||||
@ -103,6 +112,10 @@ class OverkizDescriptiveEntity(OverkizEntity):
|
|||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = f"{super().unique_id}-{self.entity_description.key}"
|
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
|
# Used by state translations for sensor and select entities
|
||||||
@unique
|
@unique
|
||||||
|
Loading…
x
Reference in New Issue
Block a user