Skip to content

Commit

Permalink
Merge pull request #22 from twhittock/switch-channel-names
Browse files Browse the repository at this point in the history
Use API-defined switch names instead of channel indices
  • Loading branch information
albertogeniola authored Nov 11, 2019
2 parents 05bf512 + bc8a9d9 commit fa1976f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/meross_cloud/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,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)
Expand Down

0 comments on commit fa1976f

Please sign in to comment.