Add support for "off" function to iTunes (#12109)

fixes #7614
This commit is contained in:
Eleftherios Chamakiotis 2018-02-02 16:54:47 +02:00 committed by Phil Frost
parent 1d2e930900
commit 87c0fd98c7

View File

@ -29,7 +29,7 @@ DOMAIN = 'itunes'
SUPPORT_ITUNES = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
SUPPORT_PREVIOUS_TRACK | SUPPORT_NEXT_TRACK | SUPPORT_SEEK | \
SUPPORT_PLAY_MEDIA | SUPPORT_PLAY
SUPPORT_PLAY_MEDIA | SUPPORT_PLAY | SUPPORT_TURN_OFF
SUPPORT_AIRPLAY = SUPPORT_VOLUME_SET | SUPPORT_TURN_ON | SUPPORT_TURN_OFF
@ -115,6 +115,10 @@ class Itunes(object):
"""Skip back and returns the current state."""
return self._command('previous')
def stop(self):
"""Stop playback and return the current state."""
return self._command('stop')
def play_playlist(self, playlist_id_or_name):
"""Set a playlist to be current and returns the current state."""
response = self._request('GET', '/playlists')
@ -346,6 +350,11 @@ class ItunesDevice(MediaPlayerDevice):
response = self.client.play_playlist(media_id)
self.update_state(response)
def turn_off(self):
"""Turn the media player off."""
response = self.client.stop()
self.update_state(response)
class AirPlayDevice(MediaPlayerDevice):
"""Representation an AirPlay device via an iTunes API instance."""