devialet 1.5.0__tar.gz → 1.5.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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: devialet
3
- Version: 1.5.0
3
+ Version: 1.5.2
4
4
  Summary: Devialet API
5
5
  Home-page: https://github.com/fwestenberg/devialet
6
6
  Download-URL: https://github.com/fwestenberg/devialet/releases/latest
@@ -16,7 +16,7 @@ async def main():
16
16
  session = async with aiohttp.ClientSession() as session:
17
17
  client = DevialetApi('192.168.1.10', session)
18
18
  await client.async_update()
19
- await client.async_set_volume_level(0.2)
19
+ await client.async_set_volume_level(20)
20
20
  await client.async_media_next_track()
21
21
  await client.async_turn_off()
22
22
 
@@ -31,32 +31,37 @@ AV_TRANSPORT = "urn:schemas-upnp-org:service:AVTransport:2"
31
31
  MEDIA_RENDERER = "urn:schemas-upnp-org:device:MediaRenderer:2"
32
32
 
33
33
  class UrlSuffix(Enum):
34
+ # Devices commands
34
35
  GET_GENERAL_INFO = "/ipcontrol/v1/devices/current"
35
- GET_SOURCES = "/ipcontrol/v1/groups/current/sources"
36
- GET_CURRENT_SOURCE = "/ipcontrol/v1/groups/current/sources/current"
36
+
37
+ # Systems commands
37
38
  GET_VOLUME = "/ipcontrol/v1/systems/current/sources/current/soundControl/volume"
38
39
  GET_NIGHT_MODE = "/ipcontrol/v1/systems/current/settings/audio/nightMode"
39
40
  GET_EQUALIZER = "/ipcontrol/v1/systems/current/settings/audio/equalizer"
40
- GET_CURRENT_POSITION = (
41
- "/ipcontrol/v1/groups/current/sources/current/playback/position"
42
- )
43
- SEEK = "/ipcontrol/v1/systems/current/sources/current/playback/position"
44
- PLAY = "/ipcontrol/v1/systems/current/sources/current/playback/play"
45
- PAUSE = "/ipcontrol/v1/systems/current/sources/current/playback/pause"
46
- STOP = "/ipcontrol/v1/systems/current/sources/current/playback/pause"
47
- PREVIOUS_TRACK = "/ipcontrol/v1/systems/current/sources/current/playback/previous"
48
- NEXT_TRACK = "/ipcontrol/v1/systems/current/sources/current/playback/next"
49
41
  TURN_OFF = "/ipcontrol/v1/systems/current/powerOff"
50
42
  VOLUME_UP = "/ipcontrol/v1/systems/current/sources/current/soundControl/volumeUp"
51
43
  VOLUME_DOWN = (
52
44
  "/ipcontrol/v1/systems/current/sources/current/soundControl/volumeDown"
53
45
  )
54
46
  VOLUME_SET = "/ipcontrol/v1/systems/current/sources/current/soundControl/volume"
55
- MUTE = "/ipcontrol/v1/groups/current/sources/current/playback/mute"
56
- UNMUTE = "/ipcontrol/v1/groups/current/sources/current/playback/unmute"
57
47
  EQUALIZER = "/ipcontrol/v1/systems/current/settings/audio/equalizer"
58
48
  NIGHT_MODE = "/ipcontrol/v1/systems/current/settings/audio/nightMode"
59
49
  SELECT_SOURCE = "/ipcontrol/v1/groups/current/sources/%SOURCE_ID%/playback/play"
60
50
 
51
+ # Groups commands
52
+ GET_SOURCES = "/ipcontrol/v1/groups/current/sources"
53
+ GET_CURRENT_SOURCE = "/ipcontrol/v1/groups/current/sources/current"
54
+ GET_CURRENT_POSITION = (
55
+ "/ipcontrol/v1/groups/current/sources/current/playback/position"
56
+ )
57
+ SEEK = "/ipcontrol/v1/groups/current/sources/current/playback/position"
58
+ PLAY = "/ipcontrol/v1/groups/current/sources/current/playback/play"
59
+ PAUSE = "/ipcontrol/v1/groups/current/sources/current/playback/pause"
60
+ STOP = "/ipcontrol/v1/groups/current/sources/current/playback/pause"
61
+ PREVIOUS_TRACK = "/ipcontrol/v1/groups/current/sources/current/playback/previous"
62
+ NEXT_TRACK = "/ipcontrol/v1/groups/current/sources/current/playback/next"
63
+ MUTE = "/ipcontrol/v1/groups/current/sources/current/playback/mute"
64
+ UNMUTE = "/ipcontrol/v1/groups/current/sources/current/playback/unmute"
65
+
61
66
  def __str__(self):
62
67
  return str(self.value)
@@ -18,6 +18,7 @@ from async_upnp_client.utils import CaseInsensitiveDict
18
18
 
19
19
  from .const import AV_TRANSPORT, LOGGER, NORMAL_INPUTS, MEDIA_RENDERER, SPEAKER_POSITIONS, UrlSuffix
20
20
 
21
+ UPNP_SEARCH_INTERVAL = 120
21
22
 
22
23
  class DevialetApi:
23
24
  """Devialet API class."""
@@ -182,6 +183,11 @@ class DevialetApi:
182
183
  except (KeyError, TypeError):
183
184
  return None
184
185
 
186
+ @property
187
+ def dmr_device(self) -> DmrDevice | None:
188
+ """Return DMR device class."""
189
+ return self._dmr_device
190
+
185
191
  @property
186
192
  def source_list(self) -> list | None:
187
193
  """Return the list of available input sources."""
@@ -212,8 +218,8 @@ class DevialetApi:
212
218
  return sorted(self._source_list)
213
219
 
214
220
  @property
215
- def available_options(self) -> any | None:
216
- """Return the list of available options for this source."""
221
+ def available_operations(self) -> any | None:
222
+ """Return the list of available operations for this source."""
217
223
  try:
218
224
  return self._source_state["availableOperations"]
219
225
  except (KeyError, TypeError):
@@ -266,14 +272,6 @@ class DevialetApi:
266
272
  """When was the position of the current playing media valid."""
267
273
  return self._position_updated_at
268
274
 
269
- @property
270
- def supported_features(self) -> any | None:
271
- """Flag media player features that are supported."""
272
- try:
273
- return self._source_state["availableOptions"]
274
- except (KeyError, TypeError):
275
- return None
276
-
277
275
  @property
278
276
  def source(self) -> str | None:
279
277
  """Return the current input source."""
@@ -330,7 +328,8 @@ class DevialetApi:
330
328
  "equalizer": self._equalizer,
331
329
  "source_list": self.source_list,
332
330
  "source": self.source,
333
- "upnp_device_info": self._upnp_device.device_info
331
+ "upnp_device_type": getattr(self._upnp_device.device_info, 'device_type') if self._upnp_device else "Not available",
332
+ "upnp_device_url": getattr(self._upnp_device.device_info, 'url') if self._upnp_device else "Not available",
334
333
  }
335
334
 
336
335
  async def async_volume_up(self) -> None:
@@ -480,18 +479,16 @@ class DevialetApi:
480
479
  except aiohttp.ClientConnectorError as conn_err:
481
480
  LOGGER.debug("Host %s: Connection error %s", self._host, str(conn_err))
482
481
  self._is_available = False
483
- self._upnp_device = None
484
482
  return None
485
483
  except asyncio.TimeoutError:
486
484
  LOGGER.debug("Devialet connection timeout exception. Please check the connection")
487
485
  self._is_available = False
488
- self._upnp_device = None
489
486
  return None
490
487
  except (TypeError, json.JSONDecodeError):
491
- LOGGER.debug("Devialet: JSON error")
488
+ LOGGER.debug("Get request: JSON error")
492
489
  return None
493
490
  except Exception: # pylint: disable=bare-except
494
- LOGGER.debug("Devialet: unknown exception occurred")
491
+ LOGGER.debug("Get request: unknown exception occurred")
495
492
  return None
496
493
 
497
494
  async def _async_post_request(self, suffix:str, json_body:str={}) -> bool | None:
@@ -521,10 +518,10 @@ class DevialetApi:
521
518
  )
522
519
  return False
523
520
  except (TypeError, json.JSONDecodeError):
524
- LOGGER.debug("Devialet: unknown response type")
521
+ LOGGER.debug("Post request: unknown response type")
525
522
  return False
526
523
  except Exception: # pylint: disable=bare-except
527
- LOGGER.debug("Devialet: unknown exception occurred")
524
+ LOGGER.debug("Post request: unknown exception occurred")
528
525
  return False
529
526
 
530
527
  async def _async_on_search_response(self, data: CaseInsensitiveDict) -> None:
@@ -538,10 +535,19 @@ class DevialetApi:
538
535
  self._upnp_device = await factory.async_create_device(location)
539
536
  self._dmr_device = DmrDevice(self._upnp_device, None)
540
537
 
538
+ async def async_search_allowed(self) -> bool:
539
+ """Conditions to check if UPnP search is allowed."""
540
+ if (
541
+ self.is_available
542
+ and not self.upnp_available
543
+ and self.is_system_leader
544
+ and ( not self._last_upnp_search
545
+ or ( datetime.datetime.now() - self._last_upnp_search).total_seconds() >= UPNP_SEARCH_INTERVAL ) ):
546
+ return True
547
+ return False
548
+
541
549
  async def async_discover_upnp_device(self) -> None:
542
550
  """Discover the UPnP device."""
543
- if self._last_upnp_search is not None and (datetime.datetime.now() - self._last_upnp_search).total_seconds() < 60:
544
- return
545
551
  self._last_upnp_search = datetime.datetime.now()
546
552
 
547
553
  await async_search(async_callback=self._async_on_search_response,
@@ -563,9 +569,9 @@ class DevialetApi:
563
569
  result = await set_uri.async_call(InstanceID=0, CurrentURI=media_url, CurrentURIMetaData=meta_data)
564
570
  LOGGER.debug("Action result: %s", str(result))
565
571
  except UpnpActionResponseError as a:
566
- LOGGER.error("Devialet: error playing %s: %s", media_title, a.error_desc)
572
+ LOGGER.error("Error playing %s: %s", media_title, a.error_desc)
567
573
  except UpnpXmlParseError as x:
568
- LOGGER.error("Devialet: error playing %s %s", media_title, x.text)
574
+ LOGGER.error("Error playing %s %s", media_title, x.text)
569
575
 
570
576
  await self.async_upnp_play()
571
577
 
@@ -579,7 +585,7 @@ class DevialetApi:
579
585
  set_uri = service.action("Play")
580
586
 
581
587
  try:
582
- await set_uri.async_call(InstanceID=0, Speed=1)
588
+ await set_uri.async_call(InstanceID=0, Speed="1")
583
589
  return
584
590
  except UpnpActionResponseError:
585
591
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: devialet
3
- Version: 1.5.0
3
+ Version: 1.5.2
4
4
  Summary: Devialet API
5
5
  Home-page: https://github.com/fwestenberg/devialet
6
6
  Download-URL: https://github.com/fwestenberg/devialet/releases/latest
@@ -3,7 +3,7 @@ from distutils.core import setup
3
3
  setup(
4
4
  name='devialet',
5
5
  packages=['devialet'],
6
- version='1.5.0',
6
+ version='1.5.2',
7
7
  license='MIT',
8
8
  description='Devialet API',
9
9
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes