Skip to content

Commit

Permalink
Add find_bridge and remove_bridge to controller (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
silamon authored Dec 22, 2024
1 parent 258546e commit a662914
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/linkplay/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ async def discover_bridges(self) -> None:
]
self.bridges.extend(new_bridges)

async def find_bridge(self, bridge_uuid: str) -> LinkPlayBridge | None:
"""Find a LinkPlay device by its bridge uuid."""

for bridge in self.bridges:
if bridge.device.uuid == bridge_uuid:
return bridge

return None

async def add_bridge(self, bridge_to_add: LinkPlayBridge) -> None:
"""Add given LinkPlay device if not already added."""

Expand All @@ -39,6 +48,14 @@ async def add_bridge(self, bridge_to_add: LinkPlayBridge) -> None:
if bridge_to_add.device.uuid not in current_bridges:
self.bridges.append(bridge_to_add)

async def remove_bridge(self, bridge_to_remove: LinkPlayBridge) -> None:
"""Remove given LinkPlay device if not already deleted."""

# Remove bridge
current_bridges = [bridge.device.uuid for bridge in self.bridges]
if bridge_to_remove.device.uuid in current_bridges:
self.bridges.remove(bridge_to_remove)

async def discover_multirooms(self) -> None:
"""Attempts to discover multirooms on the local network."""

Expand Down

0 comments on commit a662914

Please sign in to comment.