Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion homeassistant/components/media_player/songpal.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def state(self):
@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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a single-line comment here describing the necessity of using getattr instead of regular attribute access here, then it's okay to merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - here you go. Is this comment sufficient?

Copy link
Copy Markdown
Member

@rytilahti rytilahti Jan 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good, thanks! I changed the title to be a bit more descriptive :-)


@property
def volume_level(self):
Expand Down