Skip to content

Commit

Permalink
Additional fixes for multiroom
Browse files Browse the repository at this point in the history
  • Loading branch information
silamon committed Nov 11, 2024
1 parent 3cf75ba commit ce401d1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/linkplay/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -370,21 +380,27 @@ 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:
"""Adds a follower to the multiroom group."""
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."""
Expand Down

0 comments on commit ce401d1

Please sign in to comment.