-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
WIP: Songpal sound mode support #14718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
062db8a
69440e2
8dab888
142a71a
c7df1bb
a5ae281
90924ac
e4da0d4
29659cb
bacb6b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| from homeassistant.components.media_player import ( | ||
| PLATFORM_SCHEMA, SUPPORT_SELECT_SOURCE, SUPPORT_TURN_OFF, | ||
| SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, SUPPORT_VOLUME_SET, | ||
| SUPPORT_TURN_ON, MediaPlayerDevice, DOMAIN) | ||
| SUPPORT_TURN_ON, SUPPORT_SELECT_SOUND_MODE, MediaPlayerDevice, DOMAIN) | ||
| from homeassistant.const import ( | ||
| CONF_NAME, STATE_ON, STATE_OFF, ATTR_ENTITY_ID) | ||
| from homeassistant.exceptions import PlatformNotReady | ||
|
|
@@ -21,7 +21,8 @@ | |
|
|
||
| SUPPORT_SONGPAL = SUPPORT_VOLUME_SET | SUPPORT_VOLUME_STEP | \ | ||
| SUPPORT_VOLUME_MUTE | SUPPORT_SELECT_SOURCE | \ | ||
| SUPPORT_TURN_ON | SUPPORT_TURN_OFF | ||
| SUPPORT_TURN_ON | SUPPORT_TURN_OFF | \ | ||
| SUPPORT_SELECT_SOUND_MODE | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -171,6 +172,15 @@ async def async_update(self): | |
| _LOGGER.debug("Got ins: %s", inputs) | ||
| self._sources = inputs | ||
|
|
||
|
|
||
| try: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. too many blank lines (2) |
||
| soundfields = await self.dev.get_soundfield() | ||
| self._soundmodes = {x.value:x.title for x in soundfields.candidate} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing whitespace after ':' |
||
| self._active_soundmode = self._soundmodes[soundfields.currentValue] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (83 > 79 characters) |
||
| except SongpalException: | ||
| self._soundmodes = None | ||
| self._active_soundmode = None | ||
|
|
||
| self._available = True | ||
| except SongpalException as ex: | ||
| # if we were available, print out the exception | ||
|
|
@@ -192,6 +202,22 @@ def source_list(self): | |
| """Return list of available sources.""" | ||
| return [x.title for x in self._sources] | ||
|
|
||
| async def async_select_sound_mode(self, sound_mode): | ||
| """Select sound mode.""" | ||
| reversed = {v: k for k, v in self._soundmodes.items()} | ||
| return await self.dev.set_soundfield(reversed[sound_mode]) | ||
|
|
||
| @property | ||
| def sound_mode(self): | ||
| """Return currently active sound mode.""" | ||
| return self._active_soundmode | ||
|
|
||
| @property | ||
| def sound_mode_list(self): | ||
| """Return supported sound modes.""" | ||
| if self._soundmodes is not None: | ||
| return list(self._soundmodes.keys()) | ||
|
|
||
| @property | ||
| def state(self): | ||
| """Return current state.""" | ||
|
|
@@ -249,4 +275,7 @@ def is_volume_muted(self): | |
| @property | ||
| def supported_features(self): | ||
| """Return supported features.""" | ||
| return SUPPORT_SONGPAL | ||
| supported = SUPPORT_SONGPAL | ||
| supported |= (self._soundmodes is not None and | ||
| SUPPORT_SELECT_SOUND_MODE) | ||
| return supported | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line over-indented for visual indent