Skip to content

Commit

Permalink
Fix overkiz entity name (#79229)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyroDev authored and balloob committed Oct 3, 2022
1 parent 590d47a commit d41d09a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion homeassistant/components/overkiz/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ def __init__(
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."""
Expand All @@ -46,7 +55,7 @@ def generate_device_info(self) -> DeviceInfo:
# 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)},
Expand Down Expand Up @@ -103,6 +112,10 @@ def __init__(
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
Expand Down

0 comments on commit d41d09a

Please sign in to comment.