diff --git a/homeassistant/components/soundtouch/media_player.py b/homeassistant/components/soundtouch/media_player.py index 2f64a2d3605486..bbdc8d7390bcac 100644 --- a/homeassistant/components/soundtouch/media_player.py +++ b/homeassistant/components/soundtouch/media_player.py @@ -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, MediaPlayerDevice @@ -17,6 +18,7 @@ SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_STEP, + SUPPORT_SELECT_SOURCE, ) from homeassistant.const import ( CONF_HOST, @@ -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, + Source.BLUETOOTH, + ] + @property def is_volume_muted(self): """Boolean if volume is currently muted.""" @@ -264,6 +280,15 @@ def set_volume_level(self, volume): """Set volume level, range 0..1.""" self._device.set_volume(int(volume * 100)) + def select_source(self, source): + """Set device source. AUX, BLUETOOTH.""" + if source == Source.AUX: + self._device.select_source_aux() + elif source == Source.BLUETOOTH: + self._device.select_source_bluetooth() + else: + _LOGGER.debug("Source %s is not supported yet", source) + def mute_volume(self, mute): """Send mute command.""" self._device.mute()