Merge pull request #736 from Mosibi/mpd-add-state_on

Added support for MPD to start playing the current song/playlist
This commit is contained in:
Paulus Schoutsen 2015-12-12 12:06:38 -08:00
commit 9fc0d93e44

View File

@ -21,14 +21,14 @@ from homeassistant.const import (
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
MediaPlayerDevice, MediaPlayerDevice,
SUPPORT_PAUSE, SUPPORT_VOLUME_SET, SUPPORT_TURN_OFF, SUPPORT_PAUSE, SUPPORT_VOLUME_SET, SUPPORT_TURN_OFF,
SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK, SUPPORT_TURN_ON, SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK,
MEDIA_TYPE_MUSIC) MEDIA_TYPE_MUSIC)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['python-mpd2==0.5.4'] REQUIREMENTS = ['python-mpd2==0.5.4']
SUPPORT_MPD = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_TURN_OFF | \ SUPPORT_MPD = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_TURN_OFF | \
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK SUPPORT_TURN_ON | SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK
# pylint: disable=unused-argument # pylint: disable=unused-argument
@ -163,9 +163,13 @@ class MpdDevice(MediaPlayerDevice):
return SUPPORT_MPD return SUPPORT_MPD
def turn_off(self): def turn_off(self):
""" Service to exit the running MPD. """ """ Service to send the MPD the command to stop playing. """
self.client.stop() self.client.stop()
def turn_on(self):
""" Service to send the MPD the command to start playing. """
self.client.play()
def set_volume_level(self, volume): def set_volume_level(self, volume):
""" Sets volume """ """ Sets volume """
self.client.setvol(int(volume * 100)) self.client.setvol(int(volume * 100))