From ce401d1adcb1729e81275e0c429e8b88011cd6d7 Mon Sep 17 00:00:00 2001 From: Simon Lamon <32477463+silamon@users.noreply.github.com> Date: Mon, 11 Nov 2024 10:38:11 +0000 Subject: [PATCH] Additional fixes for multiroom --- src/linkplay/bridge.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/linkplay/bridge.py b/src/linkplay/bridge.py index 307b45e..c0cc98a 100644 --- a/src/linkplay/bridge.py +++ b/src/linkplay/bridge.py @@ -73,7 +73,17 @@ def playmode_support(self) -> list[PlayingMode]: def eth(self) -> str | None: """Returns the ethernet address.""" eth2 = self.properties.get(DeviceAttribute.ETH2) - return eth2 if eth2 else self.properties.get(DeviceAttribute.APCLI0) + eth0 = self.properties.get(DeviceAttribute.ETH0) + for eth in [eth2, eth0]: + if eth == "0.0.0.0": + eth = None + return ( + eth2 + if eth2 + else eth0 + if eth0 + else self.properties.get(DeviceAttribute.APCLI0) + ) async def timesync(self) -> None: """Sync the time.""" @@ -370,6 +380,8 @@ async def update_status(self, bridges: list[LinkPlayBridge]) -> None: async def ungroup(self) -> None: """Ungroups the multiroom group.""" await self.leader.request(LinkPlayCommand.MULTIROOM_UNGROUP) + for follewer in self.followers: + follewer.multiroom = None self.followers = [] async def add_follower(self, follower: LinkPlayBridge) -> None: @@ -377,14 +389,18 @@ async def add_follower(self, follower: LinkPlayBridge) -> None: await follower.request( LinkPlayCommand.MULTIROOM_JOIN.format(self.leader.device.eth) ) # type: ignore[str-format] - self.followers.append(follower) + if follower not in self.followers: + follower.multiroom = self + self.followers.append(follower) async def remove_follower(self, follower: LinkPlayBridge) -> None: """Removes a follower from the multiroom group.""" await self.leader.request( LinkPlayCommand.MULTIROOM_KICK.format(follower.device.eth) ) # type: ignore[str-format] - self.followers.remove(follower) + if follower in self.followers: + follower.multiroom = None + self.followers.remove(follower) async def set_volume(self, value: int) -> None: """Sets the volume for the multiroom group."""