From 71dbd10b3998f9eeacfbb8bb48f9031dfe0974c5 Mon Sep 17 00:00:00 2001 From: Jon Maddox Date: Thu, 21 Jan 2016 17:18:52 -0500 Subject: [PATCH 1/3] let port be optional --- homeassistant/components/media_player/itunes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/media_player/itunes.py b/homeassistant/components/media_player/itunes.py index 5d08a7e95d4..7bd5f9b928e 100644 --- a/homeassistant/components/media_player/itunes.py +++ b/homeassistant/components/media_player/itunes.py @@ -40,7 +40,10 @@ class Itunes(object): @property def _base_url(self): """ Returns the base url for endpoints. """ - return self.host + ":" + str(self.port) + if self.port: + return self.host + ":" + str(self.port) + else: + return self.host def _request(self, method, path, params=None): """ Makes the actual request and returns the parsed response. """ From 682e3460e068438d98aeddd7d1184e1c950f0c6b Mon Sep 17 00:00:00 2001 From: Jon Maddox Date: Thu, 21 Jan 2016 17:45:30 -0500 Subject: [PATCH 2/3] use custom material icons to represent speaker state --- .../components/media_player/itunes.py | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/media_player/itunes.py b/homeassistant/components/media_player/itunes.py index 7bd5f9b928e..94ca5166ef6 100644 --- a/homeassistant/components/media_player/itunes.py +++ b/homeassistant/components/media_player/itunes.py @@ -383,6 +383,14 @@ class AirPlayDevice(MediaPlayerDevice): """ Returns the name of the device. """ return self.device_name + @property + def icon(self): + """ Icon to use in the frontend, if any. """ + if self.selected is True: + return "mdi:volume-high" + else: + return "mdi:volume-off" + @property def state(self): """ Returns the state of the device. """ @@ -408,23 +416,6 @@ class AirPlayDevice(MediaPlayerDevice): """ Flags of media commands that are supported. """ return SUPPORT_AIRPLAY - @property - def device_state_attributes(self): - """ Return the state attributes. """ - state_attr = {} - state_attr[ATTR_SUPPORTED_MEDIA_COMMANDS] = SUPPORT_AIRPLAY - - if self.state == STATE_OFF: - state_attr[ATTR_ENTITY_PICTURE] = \ - ('https://cloud.githubusercontent.com/assets/260/9833073' - '/6eb5c906-5958-11e5-9b4a-472cdf36be16.png') - else: - state_attr[ATTR_ENTITY_PICTURE] = \ - ('https://cloud.githubusercontent.com/assets/260/9833072' - '/6eb13cce-5958-11e5-996f-e2aaefbc9a24.png') - - return state_attr - def set_volume_level(self, volume): """ set volume level, range 0..1. """ volume = int(volume * 100) From a3b8122707abf00c7d99dcc53f70d4c5c8db0e8d Mon Sep 17 00:00:00 2001 From: Jon Maddox Date: Thu, 21 Jan 2016 17:54:26 -0500 Subject: [PATCH 3/3] not using these --- homeassistant/components/media_player/itunes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/media_player/itunes.py b/homeassistant/components/media_player/itunes.py index 94ca5166ef6..1f51885d731 100644 --- a/homeassistant/components/media_player/itunes.py +++ b/homeassistant/components/media_player/itunes.py @@ -14,8 +14,7 @@ from homeassistant.components.media_player import ( MediaPlayerDevice, MEDIA_TYPE_MUSIC, MEDIA_TYPE_PLAYLIST, SUPPORT_PAUSE, SUPPORT_SEEK, SUPPORT_VOLUME_SET, SUPPORT_VOLUME_MUTE, SUPPORT_PREVIOUS_TRACK, SUPPORT_NEXT_TRACK, SUPPORT_TURN_ON, - SUPPORT_TURN_OFF, SUPPORT_PLAY_MEDIA, - ATTR_ENTITY_PICTURE, ATTR_SUPPORTED_MEDIA_COMMANDS) + SUPPORT_TURN_OFF, SUPPORT_PLAY_MEDIA) from homeassistant.const import ( STATE_IDLE, STATE_PLAYING, STATE_PAUSED, STATE_OFF, STATE_ON)