-
-
Notifications
You must be signed in to change notification settings - Fork 36.4k
Implement soundtouch select source #31669
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
feb3215
3f7672c
23ad0f6
ee82fb3
7337263
92cba97
d527645
7cc4e50
ead29f1
1dddebb
349d2d9
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 |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import re | ||
|
|
||
| from libsoundtouch import soundtouch_device | ||
| from libsoundtouch.utils import Source | ||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity | ||
|
|
@@ -12,6 +13,7 @@ | |
| SUPPORT_PLAY, | ||
| SUPPORT_PLAY_MEDIA, | ||
| SUPPORT_PREVIOUS_TRACK, | ||
| SUPPORT_SELECT_SOURCE, | ||
| SUPPORT_TURN_OFF, | ||
| SUPPORT_TURN_ON, | ||
| SUPPORT_VOLUME_MUTE, | ||
|
|
@@ -80,6 +82,7 @@ | |
| | SUPPORT_TURN_ON | ||
| | SUPPORT_PLAY | ||
| | SUPPORT_PLAY_MEDIA | ||
| | SUPPORT_SELECT_SOURCE | ||
| ) | ||
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( | ||
|
|
@@ -234,6 +237,19 @@ def state(self): | |
|
|
||
| return MAP_STATUS.get(self._status.play_status, STATE_UNAVAILABLE) | ||
|
|
||
| @property | ||
| def source(self): | ||
| """Name of the current input source.""" | ||
| return self._status.source | ||
|
|
||
| @property | ||
| def source_list(self): | ||
| """List of available input sources.""" | ||
| return [ | ||
| Source.AUX.value, | ||
| Source.BLUETOOTH.value, | ||
| ] | ||
|
|
||
| @property | ||
| def is_volume_muted(self): | ||
| """Boolean if volume is currently muted.""" | ||
|
|
@@ -357,6 +373,17 @@ def play_media(self, media_type, media_id, **kwargs): | |
| else: | ||
| _LOGGER.warning("Unable to find preset with id %s", media_id) | ||
|
|
||
| def select_source(self, source): | ||
| """Select input source.""" | ||
| if source == Source.AUX.value: | ||
| _LOGGER.debug("Selecting source AUX") | ||
| self._device.select_source_aux() | ||
|
Member
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. Here I think it would make sense to have a
Contributor
Author
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. Indeed, but the upstream lib isn't maintained anymore, so we're stuck for now. |
||
| elif source == Source.BLUETOOTH.value: | ||
| _LOGGER.debug("Selecting source Bluetooth") | ||
| self._device.select_source_bluetooth() | ||
| else: | ||
| _LOGGER.warning("Source %s is not supported", source) | ||
|
|
||
MartinHjelmare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def create_zone(self, slaves): | ||
| """ | ||
| Create a zone (multi-room) and play on selected devices. | ||
|
|
||
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.
I presume Source is an enum? I'd recommend using something like:
to avoid the need to keep this in sync when/if upstream changes and adds new potential sources.
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.
It is indeed, but it looks like most of them don't have a method for selecting it (which kind of links to your second comment)
https://github.com/CharlesBlonde/libsoundtouch/blob/25163a7ae39de2724e2946e8b1b61484d2a590d6/libsoundtouch/utils.py#L43-50