Implement soundtouch select source (#31669)
This commit is contained in:
1 parent
3fcd7866cc
commit
8f76f59b8b
5 files changed
+159
-4
No files matched your search
@@ -2,6 +2,6 @@
|
||||
"domain": "soundtouch",
|
||||
"name": "Bose Soundtouch",
|
||||
"documentation": "https://www.home-assistant.io/integrations/soundtouch",
|
||||
"requirements": ["libsoundtouch==0.7.2"],
|
||||
"requirements": ["libsoundtouch==0.8"],
|
||||
"codeowners": []
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
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 @@ from homeassistant.components.media_player.const import (
|
||||
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_SOUNDTOUCH = (
|
||||
| SUPPORT_TURN_ON
|
||||
| SUPPORT_PLAY
|
||||
| SUPPORT_PLAY_MEDIA
|
||||
| SUPPORT_SELECT_SOURCE
|
||||
)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
@@ -234,6 +237,19 @@ class SoundTouchDevice(MediaPlayerEntity):
|
||||
|
||||
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 @@ class SoundTouchDevice(MediaPlayerEntity):
|
||||
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()
|
||||
elif source == Source.BLUETOOTH.value:
|
||||
_LOGGER.debug("Selecting source Bluetooth")
|
||||
self._device.select_source_bluetooth()
|
||||
else:
|
||||
_LOGGER.warning("Source %s is not supported", source)
|
||||
|
||||
def create_zone(self, slaves):
|
||||
"""
|
||||
Create a zone (multi-room) and play on selected devices.
|
||||
|
||||
Reference in new issue
Block a user