From f4079de180d0bf9f37bfb312418d2cd8a7c7a12c Mon Sep 17 00:00:00 2001 From: Tom Whittock Date: Sat, 26 Oct 2019 20:26:07 +0100 Subject: [PATCH] Use API-defined switch names instead of channel indices --- custom_components/meross_cloud/switch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/custom_components/meross_cloud/switch.py b/custom_components/meross_cloud/switch.py index e6d14e6c53..e6ffa6abf1 100644 --- a/custom_components/meross_cloud/switch.py +++ b/custom_components/meross_cloud/switch.py @@ -14,9 +14,12 @@ def __init__(self, device: GenericPlug, channel: int): self._device = device self._channel_id = channel self._id = calculate_switch_id(self._device.uuid, channel) - if len(self._device.get_channels())>1: - self._device_name = "%s (channel: %d)" % (self._device.name, channel) + if channel > 0: + # This is a sub-channel within the multi-way adapter + channelData = self._device.get_channels()[channel] + self._device_name = channelData['devName'] else: + # This is the root device self._device_name = self._device.name device.register_event_callback(self.handler)