Skip to content

Commit

Permalink
sonos: update to SoCo 0.30.4 (refer to SoCo changelog for a full list…
Browse files Browse the repository at this point in the history
… of robustness fixes)
  • Loading branch information
aschwith committed May 5, 2024
1 parent 646e22a commit 9310578
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 80 deletions.
2 changes: 1 addition & 1 deletion sonos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,7 @@ class Sonos(SmartPlugin):
"""
Main class of the Plugin. Does all plugin specific stuff
"""
PLUGIN_VERSION = "1.8.5"
PLUGIN_VERSION = "1.8.6"

def __init__(self, sh):
"""Initializes the plugin."""
Expand Down
2 changes: 1 addition & 1 deletion sonos/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugin:
documentation: https://github.com/smarthomeNG/plugins/blob/master/sonos/README.md
support: https://knx-user-forum.de/forum/supportforen/smarthome-py/25151-sonos-anbindung

version: 1.8.5 # Plugin version
version: 1.8.6 # Plugin version
sh_minversion: 1.5.1 # minimum shNG version to use this plugin
py_minversion: 3.8 # minimum Python version to use for this plugin
multi_instance: False # plugin supports multi instance
Expand Down
2 changes: 1 addition & 1 deletion sonos/soco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
__author__ = "The SoCo-Team <python-soco@googlegroups.com>"
# Please increment the version number and add the suffix "-dev" after
# a release, to make it possible to identify in-development code
__version__ = "0.30.2"
__version__ = "0.30.4"
__website__ = "https://github.com/SoCo/SoCo"
__license__ = "MIT License"

Expand Down
5 changes: 2 additions & 3 deletions sonos/soco/alarms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains classes relating to Sonos Alarms."""

import logging
import re
from datetime import datetime, timedelta
Expand Down Expand Up @@ -120,8 +121,7 @@ def last_alarm_list_version(self, alarm_list_version):

def __iter__(self):
"""Return an interator for all alarms."""
for alarm in list(self.alarms.values()):
yield alarm
yield from list(self.alarms.values())

def __len__(self):
"""Return the number of alarms."""
Expand Down Expand Up @@ -225,7 +225,6 @@ def get_next_alarm_datetime(


class Alarm:

"""A class representing a Sonos Alarm.
Alarms may be created or updated and saved to, or removed from the Sonos
Expand Down
4 changes: 0 additions & 4 deletions sonos/soco/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class _BaseCache:

"""An abstract base class for the cache."""

# pylint: disable=no-self-use, unused-argument
Expand Down Expand Up @@ -45,7 +44,6 @@ def clear(self):


class NullCache(_BaseCache):

"""A cache which does nothing.
Useful for debugging.
Expand All @@ -66,7 +64,6 @@ def clear(self):


class TimedCache(_BaseCache):

"""A simple thread-safe cache for caching method return values.
The cache key is generated by from the given ``*args`` and ``**kwargs``.
Expand Down Expand Up @@ -201,7 +198,6 @@ def make_key(*args, **kwargs):


class Cache(NullCache):

"""A factory class which returns an instance of a cache subclass.
A `TimedCache` is returned, unless `config.CACHE_ENABLED` is `False`,
Expand Down
1 change: 0 additions & 1 deletion sonos/soco/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
config.VARIABLE = value
"""


SOCO_CLASS = None
"""The class object to use when `SoCo` instances are created.
Expand Down
30 changes: 19 additions & 11 deletions sonos/soco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@


class _ArgsSingleton(type):

"""A metaclass which permits only a single instance of each derived class
sharing the same `_class_group` class attribute to exist for any given set
of positional arguments.
Expand Down Expand Up @@ -124,7 +123,6 @@ def __call__(cls, *args, **kwargs):
class _SocoSingletonBase( # pylint: disable=no-init
_ArgsSingleton("ArgsSingletonMeta", (object,), {})
):

"""The base class for the SoCo class.
Uses a Python 2 and 3 compatible method of declaring a metaclass. See, eg,
Expand Down Expand Up @@ -168,7 +166,6 @@ def inner_function(self, *args, **kwargs):

# pylint: disable=R0904
class SoCo(_SocoSingletonBase):

"""A simple class for controlling a Sonos speaker.
For any given set of arguments to __init__, only one instance of this class
Expand Down Expand Up @@ -515,6 +512,9 @@ def has_subwoofer(self):
Sonos Amp devices support a directly-connected 3rd party subwoofer
connected over RCA. This property is always enabled for those devices.
"""
if not self.speaker_info:
self.get_speaker_info()

model_name = self.speaker_info["model_name"].lower()
if model_name.endswith("sonos amp"):
return True
Expand Down Expand Up @@ -748,12 +748,17 @@ def play_from_queue(self, index, start=True):
self.play()

@only_on_master
def play(self):
"""Play the currently selected track."""
self.avTransport.Play([("InstanceID", 0), ("Speed", 1)])
def play(self, **kwargs):
"""Play the currently selected track.
Args:
kwargs: additional arguments such as timeout."""
self.avTransport.Play([("InstanceID", 0), ("Speed", 1)], **kwargs)

@only_on_master
def play_uri(self, uri="", meta="", title="", start=True, force_radio=False):
def play_uri(
self, uri="", meta="", title="", start=True, force_radio=False, **kwargs
):
"""Play a URI.
Playing a URI will replace what was playing with the stream
Expand All @@ -769,6 +774,7 @@ def play_uri(self, uri="", meta="", title="", start=True, force_radio=False):
title (str): The title to show in the player (if no meta).
start (bool): If the URI that has been set should start playing.
force_radio (bool): forces a uri to play as a radio stream.
kwargs: additional arguments such as timeout.
On a Sonos controller music is shown with one of the following display
formats and controls:
Expand Down Expand Up @@ -835,7 +841,7 @@ def play_uri(self, uri="", meta="", title="", start=True, force_radio=False):
)
# The track is enqueued, now play it if needed
if start:
return self.play()
return self.play(**kwargs)
return False

@only_on_master
Expand Down Expand Up @@ -2411,9 +2417,11 @@ def __get_favorites(self, favorite_type, start=0, max_items=100):
[
(
"ObjectID",
"FV:2"
if favorite_type is SONOS_FAVORITES
else "R:0/{}".format(favorite_type),
(
"FV:2"
if favorite_type is SONOS_FAVORITES
else "R:0/{}".format(favorite_type)
),
),
("BrowseFlag", "BrowseDirectChildren"),
("Filter", "*"),
Expand Down

0 comments on commit 9310578

Please sign in to comment.