python-linkplay 0.0.10__tar.gz → 0.0.12__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 (23) hide show
  1. {python_linkplay-0.0.10/src/python_linkplay.egg-info → python_linkplay-0.0.12}/PKG-INFO +1 -1
  2. python_linkplay-0.0.12/src/linkplay/__version__.py +1 -0
  3. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/bridge.py +31 -9
  4. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/consts.py +19 -0
  5. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/endpoint.py +12 -1
  6. {python_linkplay-0.0.10 → python_linkplay-0.0.12/src/python_linkplay.egg-info}/PKG-INFO +1 -1
  7. python_linkplay-0.0.10/src/linkplay/__version__.py +0 -1
  8. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/LICENSE +0 -0
  9. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/README.md +0 -0
  10. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/pyproject.toml +0 -0
  11. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/setup.cfg +0 -0
  12. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/setup.py +0 -0
  13. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/__init__.py +0 -0
  14. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/__main__.py +0 -0
  15. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/controller.py +0 -0
  16. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/discovery.py +0 -0
  17. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/exceptions.py +0 -0
  18. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/linkplay/utils.py +0 -0
  19. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/python_linkplay.egg-info/SOURCES.txt +0 -0
  20. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/python_linkplay.egg-info/dependency_links.txt +0 -0
  21. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/python_linkplay.egg-info/not-zip-safe +0 -0
  22. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/python_linkplay.egg-info/requires.txt +0 -0
  23. {python_linkplay-0.0.10 → python_linkplay-0.0.12}/src/python_linkplay.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python_linkplay
3
- Version: 0.0.10
3
+ Version: 0.0.12
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.0.12'
@@ -26,12 +26,15 @@ class LinkPlayDevice:
26
26
  """Represents a LinkPlay device."""
27
27
 
28
28
  bridge: LinkPlayBridge
29
- properties: dict[DeviceAttribute, str] = dict.fromkeys(
30
- DeviceAttribute.__members__.values(), ""
31
- )
29
+ properties: dict[DeviceAttribute, str]
32
30
 
33
31
  def __init__(self, bridge: LinkPlayBridge):
34
32
  self.bridge = bridge
33
+ self.properties = dict.fromkeys(DeviceAttribute.__members__.values(), "")
34
+
35
+ def to_dict(self):
36
+ """Return the state of the LinkPlayDevice."""
37
+ return {"properties": self.properties}
35
38
 
36
39
  async def update_status(self) -> None:
37
40
  """Update the device status."""
@@ -74,12 +77,15 @@ class LinkPlayPlayer:
74
77
  """Represents a LinkPlay player."""
75
78
 
76
79
  bridge: LinkPlayBridge
77
- properties: dict[PlayerAttribute, str] = dict.fromkeys(
78
- PlayerAttribute.__members__.values(), ""
79
- )
80
+ properties: dict[PlayerAttribute, str]
80
81
 
81
82
  def __init__(self, bridge: LinkPlayBridge):
82
83
  self.bridge = bridge
84
+ self.properties = dict.fromkeys(PlayerAttribute.__members__.values(), "")
85
+
86
+ def to_dict(self):
87
+ """Return the state of the LinkPlayPlayer."""
88
+ return {"properties": self.properties}
83
89
 
84
90
  async def update_status(self) -> None:
85
91
  """Update the player status."""
@@ -124,6 +130,11 @@ class LinkPlayPlayer:
124
130
  await self.bridge.request(LinkPlayCommand.PAUSE)
125
131
  self.properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.PAUSED
126
132
 
133
+ async def stop(self) -> None:
134
+ """Stop the current playing track and remove the selected source."""
135
+ await self.bridge.request(LinkPlayCommand.STOP)
136
+ self.properties[PlayerAttribute.PLAYING_STATUS] = PlayingStatus.STOPPED
137
+
127
138
  async def toggle(self) -> None:
128
139
  """Start playing if the player is currently not playing. Stops playing if it is."""
129
140
  await self.bridge.request(LinkPlayCommand.TOGGLE)
@@ -224,9 +235,12 @@ class LinkPlayPlayer:
224
235
  @property
225
236
  def play_mode(self) -> PlayingMode:
226
237
  """Returns the current playing mode of the player."""
227
- return PlayingMode(
228
- self.properties.get(PlayerAttribute.PLAYBACK_MODE, PlayingMode.IDLE)
229
- )
238
+ try:
239
+ return PlayingMode(
240
+ self.properties.get(PlayerAttribute.PLAYBACK_MODE, PlayingMode.IDLE)
241
+ )
242
+ except ValueError:
243
+ return PlayingMode(PlayingMode.IDLE)
230
244
 
231
245
  @property
232
246
  def loop_mode(self) -> LoopMode:
@@ -256,6 +270,14 @@ class LinkPlayBridge:
256
270
 
257
271
  return self.device.name
258
272
 
273
+ def to_dict(self):
274
+ """Return the state of the LinkPlayBridge."""
275
+ return {
276
+ "endpoint": self.endpoint.to_dict(),
277
+ "device": self.device.to_dict(),
278
+ "player": self.player.to_dict(),
279
+ }
280
+
259
281
  async def json_request(self, command: str) -> dict[str, str]:
260
282
  """Performs a GET request on the given command and returns the result as a JSON object."""
261
283
  return await self.endpoint.json_request(command)
@@ -79,6 +79,7 @@ class LinkPlayCommand(StrEnum):
79
79
  VOLUME = "setPlayerCmd:vol:{}"
80
80
  PLAYLIST = "setPlayerCmd:playlist:uri:{}"
81
81
  PAUSE = "setPlayerCmd:pause"
82
+ STOP = "setPlayerCmd:stop"
82
83
  TOGGLE = "setPlayerCmd:onepause"
83
84
  EQUALIZER_MODE = "setPlayerCmd:equalizer:{}"
84
85
  LOOP_MODE = "setPlayerCmd:loopmode:{}"
@@ -304,6 +305,12 @@ class PlayerAttribute(StrEnum):
304
305
  VOLUME = "vol"
305
306
  MUTED = "mute"
306
307
 
308
+ def __str__(self):
309
+ return self.value
310
+
311
+ def __repr__(self):
312
+ return self.value
313
+
307
314
 
308
315
  class DeviceAttribute(StrEnum):
309
316
  """Defines the device attributes."""
@@ -412,6 +419,12 @@ class DeviceAttribute(StrEnum):
412
419
  POWER_MODE = "power_mode"
413
420
  SECURITY_CAPABILITIES = "security_capabilities"
414
421
 
422
+ def __str__(self):
423
+ return self.value
424
+
425
+ def __repr__(self):
426
+ return self.value
427
+
415
428
 
416
429
  class MultiroomAttribute(StrEnum):
417
430
  """Defines the player attributes."""
@@ -420,3 +433,9 @@ class MultiroomAttribute(StrEnum):
420
433
  FOLLOWER_LIST = "slave_list"
421
434
  UUID = "uuid"
422
435
  IP = "ip"
436
+
437
+ def __str__(self):
438
+ return self.value
439
+
440
+ def __repr__(self):
441
+ return self.value
@@ -3,7 +3,6 @@ from abc import ABC, abstractmethod
3
3
 
4
4
  from aiohttp import ClientSession
5
5
 
6
- from linkplay.consts import TCPPORT
7
6
  from linkplay.utils import (
8
7
  call_tcpuart,
9
8
  call_tcpuart_json,
@@ -23,6 +22,10 @@ class LinkPlayEndpoint(ABC):
23
22
  async def json_request(self, command: str) -> dict[str, str]:
24
23
  """Performs a request on the given command and returns the result as a JSON object."""
25
24
 
25
+ @abstractmethod
26
+ def to_dict(self) -> dict[str, str]:
27
+ """Return the state of the LinkPlayEndpoint"""
28
+
26
29
 
27
30
  class LinkPlayApiEndpoint(LinkPlayEndpoint):
28
31
  """Represents a LinkPlay HTTP API endpoint."""
@@ -35,6 +38,10 @@ class LinkPlayApiEndpoint(LinkPlayEndpoint):
35
38
  self._endpoint: str = f"{protocol}://{endpoint}"
36
39
  self._session: ClientSession = session
37
40
 
41
+ def to_dict(self):
42
+ """Return the state of the LinkPlayEndpoint"""
43
+ return {"endpoint": self._endpoint}
44
+
38
45
  async def request(self, command: str) -> None:
39
46
  """Performs a GET request on the given command and verifies the result."""
40
47
  await session_call_api_ok(self._endpoint, self._session, command)
@@ -55,6 +62,10 @@ class LinkPlayTcpUartEndpoint(LinkPlayEndpoint):
55
62
  ):
56
63
  self._connection = connection
57
64
 
65
+ def to_dict(self):
66
+ """Return the state of the LinkPlayEndpoint"""
67
+ return {}
68
+
58
69
  async def request(self, command: str) -> None:
59
70
  reader, writer = self._connection
60
71
  await call_tcpuart(reader, writer, command)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python_linkplay
3
- Version: 0.0.10
3
+ Version: 0.0.12
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.0.10'