Ignore unsupported Sonos favorites (#13195)

pull/13223/head
Anders Melchiorsen 2018-03-14 20:08:41 +01:00 committed by Paulus Schoutsen
parent 8a6370f7c9
commit 4e569ac0c3
1 changed files with 11 additions and 1 deletions

View File

@ -426,7 +426,17 @@ class SonosDevice(MediaPlayerDevice):
self._play_mode = self.soco.play_mode
self._night_sound = self.soco.night_mode
self._speech_enhance = self.soco.dialog_mode
self._favorites = self.soco.music_library.get_sonos_favorites()
self._favorites = []
for fav in self.soco.music_library.get_sonos_favorites():
# SoCo 0.14 raises a generic Exception on invalid xml in favorites.
# Filter those out now so our list is safe to use.
try:
if fav.reference.get_uri():
self._favorites.append(fav)
# pylint: disable=broad-except
except Exception:
_LOGGER.debug("Ignoring invalid favorite '%s'", fav.title)
def _subscribe_to_player_events(self):
"""Add event subscriptions."""