mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Bust cache for new media player covers (#2882)
This commit is contained in:
parent
2558501235
commit
3fae4fefbf
@ -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):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user