python-linkplay 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {python_linkplay-0.2.2/src/python_linkplay.egg-info → python_linkplay-0.2.3}/PKG-INFO +1 -1
  2. python_linkplay-0.2.3/src/linkplay/__version__.py +1 -0
  3. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/bridge.py +23 -1
  4. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/controller.py +13 -0
  5. {python_linkplay-0.2.2 → python_linkplay-0.2.3/src/python_linkplay.egg-info}/PKG-INFO +1 -1
  6. python_linkplay-0.2.2/src/linkplay/__version__.py +0 -1
  7. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/LICENSE +0 -0
  8. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/README.md +0 -0
  9. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/pyproject.toml +0 -0
  10. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/setup.cfg +0 -0
  11. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/setup.py +0 -0
  12. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/__init__.py +0 -0
  13. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/__main__.py +0 -0
  14. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/consts.py +0 -0
  15. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/discovery.py +0 -0
  16. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/endpoint.py +0 -0
  17. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/exceptions.py +0 -0
  18. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/manufacturers.py +0 -0
  19. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/linkplay/utils.py +0 -0
  20. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/python_linkplay.egg-info/SOURCES.txt +0 -0
  21. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/python_linkplay.egg-info/dependency_links.txt +0 -0
  22. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/python_linkplay.egg-info/not-zip-safe +0 -0
  23. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/python_linkplay.egg-info/requires.txt +0 -0
  24. {python_linkplay-0.2.2 → python_linkplay-0.2.3}/src/python_linkplay.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_linkplay
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A Python Library for Seamless LinkPlay Device Control
5
5
  Author: Velleman Group nv
6
6
  License: MIT
@@ -0,0 +1 @@
1
+ __version__ = '0.2.3'
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import time
4
- from typing import Any
4
+ from typing import Any, Callable
5
5
 
6
6
  from linkplay.consts import (
7
7
  INPUT_MODE_MAP,
@@ -36,6 +36,8 @@ class LinkPlayDevice:
36
36
  bridge: LinkPlayBridge
37
37
  properties: dict[DeviceAttribute, str]
38
38
 
39
+ controller: Callable[[], None] | None = None
40
+
39
41
  def __init__(self, bridge: LinkPlayBridge):
40
42
  self.bridge = bridge
41
43
  self.properties = dict.fromkeys(DeviceAttribute.__members__.values(), "")
@@ -44,6 +46,10 @@ class LinkPlayDevice:
44
46
  """Return the state of the LinkPlayDevice."""
45
47
  return {"properties": self.properties}
46
48
 
49
+ def set_callback(self, controller: Callable[[], None]) -> None:
50
+ """Sets a callback function to notify events."""
51
+ self.controller = controller
52
+
47
53
  async def update_status(self) -> None:
48
54
  """Update the device status."""
49
55
  self.properties = await self.bridge.json_request(LinkPlayCommand.DEVICE_STATUS) # type: ignore[assignment]
@@ -123,6 +129,8 @@ class LinkPlayPlayer:
123
129
  properties: dict[PlayerAttribute, str]
124
130
  custom_properties: dict[PlayerAttribute, str]
125
131
 
132
+ previous_playing_mode: PlayingMode | None = None
133
+
126
134
  def __init__(self, bridge: LinkPlayBridge):
127
135
  self.bridge = bridge
128
136
  self.properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
@@ -140,6 +148,20 @@ class LinkPlayPlayer:
140
148
 
141
149
  self.properties = fixup_player_properties(properties)
142
150
 
151
+ # handle multiroom changes
152
+ if self.bridge.device.controller is not None and (
153
+ (
154
+ self.previous_playing_mode != PlayingMode.FOLLOWER
155
+ and self.play_mode == PlayingMode.FOLLOWER
156
+ )
157
+ or (
158
+ self.previous_playing_mode == PlayingMode.FOLLOWER
159
+ and self.play_mode != PlayingMode.FOLLOWER
160
+ )
161
+ ):
162
+ self.bridge.device.controller()
163
+ self.previous_playing_mode = self.play_mode
164
+
143
165
  async def next(self) -> None:
144
166
  """Play the next song in the playlist."""
145
167
  await self.bridge.request(LinkPlayCommand.NEXT)
@@ -18,6 +18,16 @@ class LinkPlayController:
18
18
  self.bridges = []
19
19
  self.multirooms = []
20
20
 
21
+ def get_bridge_callback(self):
22
+ """Returns an async callback function for LinkPlayBridge."""
23
+
24
+ async def callback() -> None:
25
+ """Async callback function to handle events from a LinkPlayBridge."""
26
+ LOGGER.debug("Controller event received")
27
+ await self.discover_multirooms()
28
+
29
+ return callback
30
+
21
31
  async def discover_bridges(self) -> None:
22
32
  """Attempts to discover LinkPlay devices on the local network."""
23
33
 
@@ -46,6 +56,7 @@ class LinkPlayController:
46
56
  # Add bridge
47
57
  current_bridges = [bridge.device.uuid for bridge in self.bridges]
48
58
  if bridge_to_add.device.uuid not in current_bridges:
59
+ bridge_to_add.device.set_callback(self.get_bridge_callback())
49
60
  self.bridges.append(bridge_to_add)
50
61
 
51
62
  async def remove_bridge(self, bridge_to_remove: LinkPlayBridge) -> None:
@@ -80,6 +91,8 @@ class LinkPlayController:
80
91
  multiroom.leader.multiroom = None
81
92
  removed_multirooms.append(multiroom)
82
93
  except LinkPlayInvalidDataException as exc:
94
+ multiroom.leader.multiroom = None
95
+ removed_multirooms.append(multiroom)
83
96
  LOGGER.exception(exc)
84
97
 
85
98
  # Create new multirooms from new bridges
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_linkplay
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A Python Library for Seamless LinkPlay Device Control
5
5
  Author: Velleman Group nv
6
6
  License: MIT
@@ -1 +0,0 @@
1
- __version__ = '0.2.2'
File without changes