From 0be922dc9cce320b7de17bdbe02b4cf151f14c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9deric=20Kinnaer?= Date: Thu, 24 Jan 2019 12:55:39 +0100 Subject: [PATCH] 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 --- homeassistant/components/media_player/songpal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/songpal.py b/homeassistant/components/media_player/songpal.py index 59293fd3e8c..e67578539ad 100644 --- a/homeassistant/components/media_player/songpal.py +++ b/homeassistant/components/media_player/songpal.py @@ -288,7 +288,8 @@ class SongpalDevice(MediaPlayerDevice): @property def source(self): """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 def volume_level(self):