Use new HMIP labels for HomematicIP Cloud multi devices (#32925)

* Use new labels for HomematicIP Cloud multi devices

* Update homeassistant/components/homematicip_cloud/device.py

Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com>

* Update name composition

Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
This commit is contained in:
SukramJandspringstan authored and GitHub committed 2020-03-29 21:38:59 +02:00
1 parent d45c386149
commit 1cd0e764b6
6 files changed
+51 -25

No files matched your search

@@ -166,12 +166,19 @@ class HomematicipGenericDevice(Entity):
def name(self) -> str:
"""Return the name of the generic device."""
name = self._device.label
if self._home.name is not None and self._home.name != "":
if name and self._home.name:
name = f"{self._home.name} {name}"
if self.post is not None and self.post != "":
if name and self.post:
name = f"{name} {self.post}"
return name
def _get_label_by_channel(self, channel: int) -> str:
"""Return the name of the channel."""
name = self._device.functionalChannels[channel].label
if name and self._home.name:
name = f"{self._home.name} {name}"
return name
@property
def should_poll(self) -> bool:
"""No polling needed."""
@@ -71,6 +71,14 @@ class HomematicipLight(HomematicipGenericDevice, Light):
"""Initialize the light device."""
super().__init__(hap, device)
@property
def name(self) -> str:
"""Return the name of the multi switch channel."""
label = self._get_label_by_channel(1)
if label:
return label
return super().name
@property
def is_on(self) -> bool:
"""Return true if device is on."""
@@ -193,6 +201,9 @@ class HomematicipNotificationLight(HomematicipGenericDevice, Light):
@property
def name(self) -> str:
"""Return the name of the generic device."""
label = self._get_label_by_channel(self.channel)
if label:
return label
return f"{super().name} Notification"
@property
@@ -153,6 +153,14 @@ class HomematicipMultiSwitch(HomematicipGenericDevice, SwitchDevice):
self.channel = channel
super().__init__(hap, device, f"Channel{channel}")
@property
def name(self) -> str:
"""Return the name of the multi switch channel."""
label = self._get_label_by_channel(self.channel)
if label:
return label
return super().name
@property
def unique_id(self) -> str:
"""Return a unique ID."""