From 3fae4fefbfa82e600bfec208af1000f34b0b357b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 20 Aug 2016 15:14:57 -0700 Subject: [PATCH] Bust cache for new media player covers (#2882) --- .../components/media_player/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index 38e476c5d8c..5448671b14d 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -4,6 +4,7 @@ Component to interface with various media players. For more details about this component, please refer to the documentation at https://home-assistant.io/components/media_player/ """ +import hashlib import logging import os import requests @@ -32,7 +33,7 @@ SCAN_INTERVAL = 10 ENTITY_ID_FORMAT = DOMAIN + '.{}' -ENTITY_IMAGE_URL = '/api/media_player_proxy/{0}?token={1}' +ENTITY_IMAGE_URL = '/api/media_player_proxy/{0}?token={1}&cache={2}' SERVICE_PLAY_MEDIA = 'play_media' SERVICE_SELECT_SOURCE = 'select_source' @@ -645,8 +646,17 @@ class MediaPlayerDevice(Entity): @property def entity_picture(self): """Return image of the media playing.""" - return None if self.state == STATE_OFF else \ - ENTITY_IMAGE_URL.format(self.entity_id, self.access_token) + if self.state == STATE_OFF: + return None + + url = self.media_image_url + + if url is None: + return None + + return ENTITY_IMAGE_URL.format( + self.entity_id, self.access_token, + hashlib.md5(url.encode('utf-8')).hexdigest()[:5]) @property def state_attributes(self):