Skip to content
Closed
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
25 changes: 25 additions & 0 deletions homeassistant/components/soundtouch/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,6 +18,7 @@
SUPPORT_VOLUME_MUTE,
SUPPORT_VOLUME_SET,
SUPPORT_VOLUME_STEP,
SUPPORT_SELECT_SOURCE,
)
from homeassistant.const import (
CONF_HOST,
Expand Down Expand Up @@ -80,6 +82,7 @@
| SUPPORT_TURN_ON
| SUPPORT_PLAY
| SUPPORT_PLAY_MEDIA
| SUPPORT_SELECT_SOURCE
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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()
Expand Down