From 87c0fd98c755f65f14f067e24c921f24fd7421bd Mon Sep 17 00:00:00 2001 From: Eleftherios Chamakiotis Date: Fri, 2 Feb 2018 16:54:47 +0200 Subject: [PATCH] Add support for "off" function to iTunes (#12109) fixes #7614 --- homeassistant/components/media_player/itunes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/itunes.py b/homeassistant/components/media_player/itunes.py index 575ea414fa3..3291c1ae13d 100644 --- a/homeassistant/components/media_player/itunes.py +++ b/homeassistant/components/media_player/itunes.py @@ -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."""