Bust cache for new media player covers (#2882)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2016-08-20 15:14:57 -07:00
1 parent 2558501235
commit 3fae4fefbf
1 file changed
+13 -3
@@ -4,6 +4,7 @@ Component to interface with various media players.
For more details about this component, please refer to the documentation at For more details about this component, please refer to the documentation at
https://home-assistant.io/components/media_player/ https://home-assistant.io/components/media_player/
""" """
import hashlib
import logging import logging
import os import os
import requests import requests
@@ -32,7 +33,7 @@ SCAN_INTERVAL = 10
ENTITY_ID_FORMAT = DOMAIN + '.{}' 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_PLAY_MEDIA = 'play_media'
SERVICE_SELECT_SOURCE = 'select_source' SERVICE_SELECT_SOURCE = 'select_source'
@@ -645,8 +646,17 @@ class MediaPlayerDevice(Entity):
@property @property
def entity_picture(self): def entity_picture(self):
"""Return image of the media playing.""" """Return image of the media playing."""
return None if self.state == STATE_OFF else \ if self.state == STATE_OFF:
ENTITY_IMAGE_URL.format(self.entity_id, self.access_token) 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 @property
def state_attributes(self): def state_attributes(self):