SongPal: do not crash if active_source is not (yet) available - fixes #20343 (#20344)

* SongPal: error handling if active_source can't be detected

* sonpal: Add comment to the use of getattr() for property source

* songpal: make comment single-line
This commit is contained in:
Fréderic Kinnaer 2019-01-24 12:55:39 +01:00 committed by Teemu R
parent 7038dd484a
commit 0be922dc9c

View File

@ -288,7 +288,8 @@ class SongpalDevice(MediaPlayerDevice):
@property @property
def source(self): def source(self):
"""Return currently active source.""" """Return currently active source."""
return self._active_source.title # Avoid a KeyError when _active_source is not (yet) populated
return getattr(self._active_source, 'title', None)
@property @property
def volume_level(self): def volume_level(self):