pybeoplay 2.8.3__tar.gz → 2.9.2__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.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybeoplay
3
- Version: 2.8.3
3
+ Version: 2.9.2
4
4
  Summary: BeoPlay API for Python
5
5
  Home-page: https://github.com/giachello/pybeoplay
6
- Download-URL: https://github.com/giachello/pybeoplay/tarball/2.8.3
6
+ Download-URL: https://github.com/giachello/pybeoplay/tarball/2.9.2
7
7
  Author: Giovanni Iachello
8
8
  Author-email: giovanni.iachello@gmail.com
9
9
  License: MIT
@@ -12,6 +12,7 @@ https://widdowquinn.github.io/coding/update-pypi-package/
12
12
  import asyncio
13
13
  import json
14
14
  import logging
15
+ import time
15
16
  from typing import Optional
16
17
  import requests
17
18
  import aiohttp
@@ -87,7 +88,7 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
87
88
  def host(self):
88
89
  """Return the device host."""
89
90
  return self._host
90
-
91
+
91
92
  @property
92
93
  def name(self):
93
94
  """Return the device name."""
@@ -132,12 +133,17 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
132
133
  def digits(self):
133
134
  """Get the list of available digits"""
134
135
  return BEOPLAY_DIGITS
135
-
136
+
137
+ @property
138
+ def oneway_commands(self):
139
+ """Get the list of available one-way commands"""
140
+ return BEOPLAY_ONEWAY_COMMANDS
141
+
136
142
  @property
137
143
  def soundMode(self):
138
144
  """Get the current sound modes"""
139
145
  return self._soundMode
140
-
146
+
141
147
  @property
142
148
  def soundModes(self):
143
149
  """Get the list of available sound modes"""
@@ -152,12 +158,12 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
152
158
  def standPosition(self):
153
159
  """Get the current stand position"""
154
160
  return self._standPosition
155
-
161
+
156
162
  @property
157
163
  def standPositions(self):
158
164
  """Get the list of available stand positions"""
159
165
  return self._standPositions
160
-
166
+
161
167
  ###############################################################
162
168
  # ASYNC BASED NETWORK CALLS
163
169
  ###############################################################
@@ -308,7 +314,7 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
308
314
  self.on = False
309
315
  return self.on
310
316
  return False
311
-
317
+
312
318
  async def async_get_sound_mode(self):
313
319
  """Returns the current sound mode, or None if not retrieved."""
314
320
  self._soundMode = None
@@ -328,7 +334,7 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
328
334
  self._soundMode = element["friendlyName"]
329
335
  return self._soundModes
330
336
  return
331
-
337
+
332
338
  async def async_get_stand_position(self):
333
339
  """Returns the stand position, or None if not retrieved."""
334
340
  self._standPosition = None
@@ -421,6 +427,7 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
421
427
  self.on = True
422
428
 
423
429
  async def async_set_source(self, source):
430
+ """Set the active source."""
424
431
  i = 0
425
432
  while i < len(self.sources):
426
433
  if self.sources[i] == source:
@@ -433,33 +440,29 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
433
440
  i += 1
434
441
 
435
442
  async def async_set_sound_mode(self, soundMode):
436
- # get sound modes if not already done
443
+ """Get sound modes if not already done"""
437
444
  if not self._soundModes:
438
445
  await self.async_get_sound_modes()
439
-
440
446
  if soundMode not in self._soundModes:
441
447
  raise ValueError("Sound mode not available")
442
-
443
448
  soundModeId = self._soundModes[soundMode]
444
-
445
449
  await self.async_postReq("PUT", BEOPLAY_URL_SET_SOUND_MODE, {"active": soundModeId})
446
-
447
450
 
448
451
  async def async_set_stand_position(self, standPosition):
452
+ """Set the active stand position."""
449
453
  if not self._standPositions:
450
454
  await self.async_get_stand_positions()
451
-
452
455
  if standPosition not in self._standPositions:
453
456
  raise ValueError("Stand position not available")
454
-
455
457
  standPositionID = self._standPositions.get(standPosition, None)
456
-
457
458
  await self.async_postReq("PUT", BEOPLAY_URL_STAND_ACTIVE, {"active": standPositionID})
458
459
 
459
460
  async def async_join_experience(self):
461
+ """Join the current experience."""
460
462
  await self.async_postReq("POST", BEOPLAY_URL_JOIN_EXPERIENCE, {})
461
463
 
462
464
  async def async_leave_experience(self):
465
+ """Leave the current experience."""
463
466
  await self.async_postReq("DELETE", BEOPLAY_URL_LEAVE_EXPERIENCE, {})
464
467
 
465
468
  async def async_play_queue_item(self, instantplay: bool, queueItem: dict):
@@ -508,32 +511,48 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
508
511
  """
509
512
  Send a remote command to the device. Command needs to be one of:
510
513
 
511
- Cursor/Select, Cursor/Up, Cursor/Down, Cursor/Left, Cursor/Right, Cursor/Exit, Cursor/Back, Cursor/PageUp, Cursor/PageDown, Cursor/Clear,
512
- Stream/Play, Stream/Stop, Stream/Pause, Stream/Wind, Stream/Rewind, Stream/Forward, Stream/Backward,
514
+ Cursor/Select, Cursor/Up, Cursor/Down, Cursor/Left, Cursor/Right, Cursor/Exit,
515
+ Cursor/Back, Cursor/PageUp, Cursor/PageDown, Cursor/Clear,
516
+ Stream/Play, Stream/Stop, Stream/Pause, Stream/Wind, Stream/Rewind, Stream/Forward,
517
+ Stream/Backward,
513
518
  List/StepUp, List/StepDown, List/PreviousElement, List/Shuffle, List/Repeat,
514
- Menu/Root, Menu/Option, Menu/Setup, Menu/Contents, Menu/Favorites, Menu/ElectronicProgramGuide, Menu/VideoOnDemand, Menu/Text, Menu/HbbTV,Menu/HomeControl,
515
- Device/Information, Device/Eject, Device/TogglePower, Device/Languages, Device/Subtitles, Device/OneWayJoin, Device/Mots,
516
- Record/Record,
519
+ Menu/Root, Menu/Option, Menu/Setup, Menu/Contents, Menu/Favorites,
520
+ Menu/ElectronicProgramGuide, Menu/VideoOnDemand, Menu/Text, Menu/HbbTV,Menu/HomeControl,
521
+ Device/Information, Device/Eject, Device/TogglePower, Device/Languages, Device/Subtitles,
522
+ Device/OneWayJoin, Device/Mots, Record/Record,
517
523
  Generic/Blue, Generic/Red, Generic/Green, Generic/Yellow.
518
524
 
519
- toBeReleased: true if this is a button press that is held. Needs to be completed by calling async_remote_release.
525
+ toBeReleased: true if this is a button press that is held. Needs to be completed by
526
+ calling async_remote_release.
520
527
 
521
528
  """
522
- if (command not in BEOPLAY_REMOTE_COMMANDS):
529
+ if command not in BEOPLAY_REMOTE_COMMANDS:
523
530
  return
524
531
  await self.async_postReq("POST", BEOPLAY_REMOTE_PREFIX + command, {"toBeReleased": toBeReleased})
525
532
 
526
533
  async def async_remote_release(self, command : str):
527
- if (command not in BEOPLAY_REMOTE_COMMANDS):
534
+ """Release a previously held remote command."""
535
+ if command not in BEOPLAY_REMOTE_COMMANDS:
528
536
  return
529
537
  await self.async_postReq("POST", BEOPLAY_REMOTE_PREFIX + command + BEOPLAY_URL_RELEASE, {})
530
538
 
539
+ async def async_oneway_command(self, command: str):
540
+ """Send a one-way command to the device. See the oneway_commands property for valid
541
+ values."""
542
+ if command not in BEOPLAY_ONEWAY_COMMANDS:
543
+ return
544
+ await self.async_postReq(
545
+ "POST",
546
+ BEOPLAY_ONEWAY,
547
+ {BEOPLAY_ONEWAY_KEY: command, BEOPLAY_ONEWAY_TIMESTAMP_KEY: int(time.time())},
548
+ )
549
+
531
550
  async def async_digits(self, digit : str):
532
551
  """
533
552
  Send a digit keypress to the device. Digits are 0-9
534
553
 
535
554
  """
536
- if (digit not in BEOPLAY_DIGITS):
555
+ if digit not in BEOPLAY_DIGITS:
537
556
  return
538
557
  await self.async_postReq("POST", BEOPLAY_DIGITS_URL, {BEOPLAY_DIGITS_KEY: int(digit)})
539
558
 
@@ -774,6 +793,16 @@ class BeoPlay: # pylint: disable=too-many-instance-attributes,too-many-public-m
774
793
  def leaveExperience(self):
775
794
  self._postReq("DELETE", BEOPLAY_URL_LEAVE_EXPERIENCE, {})
776
795
 
796
+ def oneway_command(self, command: str):
797
+ """Send a one-way command to the device. See the oneway_commands property for valid values."""
798
+ if command not in BEOPLAY_ONEWAY_COMMANDS:
799
+ return
800
+ self._postReq(
801
+ "POST",
802
+ BEOPLAY_ONEWAY,
803
+ {BEOPLAY_ONEWAY_KEY: command, BEOPLAY_ONEWAY_TIMESTAMP_KEY: int(time.time())},
804
+ )
805
+
777
806
  def playQueueItem(self, instantplay: bool, queueItem: dict):
778
807
  if instantplay:
779
808
  self._postReq(
@@ -1,50 +1,69 @@
1
- #
2
- # BeoPlay JSON interface for Bang & Olufsen Speakers, TVs and other NL devices
3
- # Reference: https://documenter.getpostman.com/view/1053298/T1LTe4Lt#intro
4
- # Reference: https://raw.githubusercontent.com/PolyPv/BeoRemote/master/BeoRemote.txt
5
- # Lifted a lot of code from marton borzak's ha-beoplay
6
- #
7
- #
8
-
9
- # Connection constants
10
- BASE_URL = 'http://{0}:8080/{1}'
11
- TIMEOUT = 5.0
12
- CONNFAILCOUNT = 5
13
-
14
- # BeoPlay constants
15
- BEOPLAY_URL_NOTIFICATIONS = 'BeoNotify/Notifications'
16
-
17
- BEOPLAY_URL_SET_VOLUME = 'BeoZone/Zone/Sound/Volume/Speaker/Level'
18
- BEOPLAY_URL_MUTE = 'BeoZone/Zone/Sound/Volume/Speaker/Muted'
19
- BEOPLAY_URL_PLAY = 'BeoZone/Zone/Stream/Play'
20
- BEOPLAY_URL_RELEASE = '/Release'
21
- BEOPLAY_URL_PAUSE = 'BeoZone/Zone/Stream/Pause'
22
- BEOPLAY_URL_STOP = 'BeoZone/Zone/Stream/Stop'
23
- BEOPLAY_URL_FORWARD = 'BeoZone/Zone/Stream/Forward'
24
- BEOPLAY_URL_BACKWARD = 'BeoZone/Zone/Stream/Backward'
25
- BEOPLAY_URL_STEPUP = 'BeoZone/Zone/List/StepUp'
26
- BEOPLAY_URL_STEPDOWN = 'BeoZone/Zone/List/StepDown'
27
- BEOPLAY_URL_SHUFFLE = 'BeoZone/Zone/List/Shuffle'
28
- BEOPLAY_URL_REPEAT = 'BeoZone/Zone/List/Repeat'
29
- BEOPLAY_URL_STANDBY = 'BeoDevice/powerManagement/standby'
30
-
31
- BEOPLAY_URL_GET_SOURCES = 'BeoZone/Zone/Sources'
32
- BEOPLAY_URL_ACTIVE_SOURCES = 'BeoZone/Zone/ActiveSources'
33
-
34
- BEOPLAY_URL_STAND_ACTIVE = 'BeoZone/Zone/Stand/Active'
35
- BEOPLAY_URL_STAND = 'BeoZone/Zone/Stand'
36
- BEOPLAY_URL_GET_SOUND_MODE = 'BeoZone/Zone/Sound/Mode'
37
- BEOPLAY_URL_SET_SOUND_MODE = 'BeoZone/Zone/Sound/Mode/Active'
38
-
39
- BEOPLAY_URL_JOIN_EXPERIENCE = 'BeoZone/Zone/Device/OneWayJoin'
40
- BEOPLAY_URL_LEAVE_EXPERIENCE = 'BeoZone/Zone/ActiveSources/primaryExperience'
41
- BEOPLAY_URL_PLAYQUEUE = 'BeoZone/Zone/PlayQueue'
42
- BEOPLAY_URL_PLAYQUEUE_INSTANT = '?instantplay'
43
-
44
-
45
- BEOPLAY_REMOTE_COMMANDS = ['Cursor/Select', 'Cursor/Up', 'Cursor/Down', 'Cursor/Left', 'Cursor/Right', 'Cursor/Exit', 'Cursor/Back', 'Cursor/PageUp', 'Cursor/PageDown', 'Cursor/Clear', 'Stream/Play', 'Stream/Stop', 'Stream/Pause', 'Stream/Wind', 'Stream/Rewind', 'Stream/Forward', 'Stream/Backward', 'List/StepUp', 'List/StepDown', 'List/PreviousElement', 'List/Shuffle', 'List/Repeat', 'Menu/Root', 'Menu/Option', 'Menu/Setup', 'Menu/Contents', 'Menu/Favorites', 'Menu/ElectronicProgramGuide', 'Menu/VideoOnDemand', 'Menu/Text', 'Menu/HbbTV,Menu/HomeControl', 'Device/Information', 'Device/Eject', 'Device/TogglePower', 'Device/Languages', 'Device/Subtitles', 'Device/OneWayJoin', 'Device/Mots', 'Record/Record', 'Generic/Blue', 'Generic/Red', 'Generic/Green', 'Generic/Yellow']
46
- BEOPLAY_REMOTE_PREFIX = 'BeoZone/Zone/'
47
-
48
- BEOPLAY_DIGITS = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
49
- BEOPLAY_DIGITS_URL = 'BeoZone/Zone/Digits'
50
- BEOPLAY_DIGITS_KEY = 'digits'
1
+ #
2
+ # BeoPlay JSON interface for Bang & Olufsen Speakers, TVs and other NL devices
3
+ # Reference: https://documenter.getpostman.com/view/1053298/T1LTe4Lt#intro
4
+ # Reference: https://raw.githubusercontent.com/PolyPv/BeoRemote/master/BeoRemote.txt
5
+ # Lifted a lot of code from marton borzak's ha-beoplay
6
+ #
7
+ #
8
+
9
+ # Connection constants
10
+ BASE_URL = 'http://{0}:8080/{1}'
11
+ TIMEOUT = 5.0
12
+ CONNFAILCOUNT = 5
13
+
14
+ # BeoPlay constants
15
+ BEOPLAY_URL_NOTIFICATIONS = 'BeoNotify/Notifications'
16
+
17
+ BEOPLAY_URL_SET_VOLUME = 'BeoZone/Zone/Sound/Volume/Speaker/Level'
18
+ BEOPLAY_URL_MUTE = 'BeoZone/Zone/Sound/Volume/Speaker/Muted'
19
+ BEOPLAY_URL_PLAY = 'BeoZone/Zone/Stream/Play'
20
+ BEOPLAY_URL_RELEASE = '/Release'
21
+ BEOPLAY_URL_PAUSE = 'BeoZone/Zone/Stream/Pause'
22
+ BEOPLAY_URL_STOP = 'BeoZone/Zone/Stream/Stop'
23
+ BEOPLAY_URL_FORWARD = 'BeoZone/Zone/Stream/Forward'
24
+ BEOPLAY_URL_BACKWARD = 'BeoZone/Zone/Stream/Backward'
25
+ BEOPLAY_URL_STEPUP = 'BeoZone/Zone/List/StepUp'
26
+ BEOPLAY_URL_STEPDOWN = 'BeoZone/Zone/List/StepDown'
27
+ BEOPLAY_URL_SHUFFLE = 'BeoZone/Zone/List/Shuffle'
28
+ BEOPLAY_URL_REPEAT = 'BeoZone/Zone/List/Repeat'
29
+ BEOPLAY_URL_STANDBY = 'BeoDevice/powerManagement/standby'
30
+
31
+ BEOPLAY_URL_GET_SOURCES = 'BeoZone/Zone/Sources'
32
+ BEOPLAY_URL_ACTIVE_SOURCES = 'BeoZone/Zone/ActiveSources'
33
+
34
+ BEOPLAY_URL_STAND_ACTIVE = 'BeoZone/Zone/Stand/Active'
35
+ BEOPLAY_URL_STAND = 'BeoZone/Zone/Stand'
36
+ BEOPLAY_URL_GET_SOUND_MODE = 'BeoZone/Zone/Sound/Mode'
37
+ BEOPLAY_URL_SET_SOUND_MODE = 'BeoZone/Zone/Sound/Mode/Active'
38
+
39
+ BEOPLAY_URL_JOIN_EXPERIENCE = 'BeoZone/Zone/Device/OneWayJoin'
40
+ BEOPLAY_URL_LEAVE_EXPERIENCE = 'BeoZone/Zone/ActiveSources/primaryExperience'
41
+ BEOPLAY_URL_PLAYQUEUE = 'BeoZone/Zone/PlayQueue'
42
+ BEOPLAY_URL_PLAYQUEUE_INSTANT = '?instantplay'
43
+
44
+
45
+ BEOPLAY_REMOTE_COMMANDS = ['Cursor/Select', 'Cursor/Up', 'Cursor/Down', 'Cursor/Left',
46
+ 'Cursor/Right', 'Cursor/Exit', 'Cursor/Back', 'Cursor/PageUp',
47
+ 'Cursor/PageDown', 'Cursor/Clear', 'Stream/Play', 'Stream/Stop',
48
+ 'Stream/Pause', 'Stream/Wind', 'Stream/Rewind',
49
+ 'Stream/Forward', 'Stream/Backward', 'List/StepUp', 'List/StepDown',
50
+ 'List/PreviousElement', 'List/Shuffle', 'List/Repeat', 'Menu/Root',
51
+ 'Menu/Option', 'Menu/Setup', 'Menu/Contents', 'Menu/Favorites',
52
+ 'Menu/ElectronicProgramGuide', 'Menu/VideoOnDemand', 'Menu/Text',
53
+ 'Menu/HbbTV,Menu/HomeControl', 'Device/Information',
54
+ 'Device/Eject', 'Device/TogglePower', 'Device/Languages',
55
+ 'Device/Subtitles', 'Device/OneWayJoin', 'Device/Mots',
56
+ 'Record/Record', 'Generic/Blue', 'Generic/Red',
57
+ 'Generic/Green', 'Generic/Yellow']
58
+ BEOPLAY_REMOTE_PREFIX = 'BeoZone/Zone/'
59
+
60
+ BEOPLAY_DIGITS = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
61
+ BEOPLAY_DIGITS_URL = 'BeoZone/Zone/Digits'
62
+ BEOPLAY_DIGITS_KEY = 'digits'
63
+
64
+ BEOPLAY_ONEWAY = 'BeoOneWay/Input'
65
+ BEOPLAY_ONEWAY_KEY = 'command'
66
+ BEOPLAY_ONEWAY_TIMESTAMP_KEY = 'timestamp'
67
+ BEOPLAY_ONEWAY_COMMANDS = ['CURSOR_UP', 'CURSOR_LEFT', 'CURSOR_RIGHT', 'CURSOR_DOWN', 'BACK',
68
+ 'MENU', 'SELECT', 'STEP_UP', 'STEP_DOWN', 'VOLUME_UP', 'VOLUME_DOWN',
69
+ 'REWIND', 'PLAY', 'WIND', 'STANDBY', 'RELEASE', 'PMUTE']
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybeoplay
3
- Version: 2.8.3
3
+ Version: 2.9.2
4
4
  Summary: BeoPlay API for Python
5
5
  Home-page: https://github.com/giachello/pybeoplay
6
- Download-URL: https://github.com/giachello/pybeoplay/tarball/2.8.3
6
+ Download-URL: https://github.com/giachello/pybeoplay/tarball/2.9.2
7
7
  Author: Giovanni Iachello
8
8
  Author-email: giovanni.iachello@gmail.com
9
9
  License: MIT
@@ -7,7 +7,7 @@ def readme():
7
7
 
8
8
  PACKAGE_NAME = 'pybeoplay'
9
9
  HERE = os.path.abspath(os.path.dirname(__file__))
10
- VERSION = '2.8.3'
10
+ VERSION = '2.9.2'
11
11
 
12
12
  PACKAGES = find_packages(exclude=['tests', 'tests.*', 'dist', 'ccu', 'build'])
13
13
 
File without changes
File without changes
File without changes