From f5db7707bb9e140010b65c0f718a02ab40dab2c2 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Wed, 5 Jun 2019 19:32:43 -0500 Subject: [PATCH] Only update media icon when necessary (#24324) * Only update media icon when necessary * Lint * Comment --- homeassistant/components/webostv/media_player.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/components/webostv/media_player.py b/homeassistant/components/webostv/media_player.py index fa62e29f233..4e7f07af857 100644 --- a/homeassistant/components/webostv/media_player.py +++ b/homeassistant/components/webostv/media_player.py @@ -167,6 +167,7 @@ class LgWebOSDevice(MediaPlayerDevice): self._source_list = {} self._app_list = {} self._channel = None + self._last_icon = None @util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS) def update(self): @@ -271,6 +272,13 @@ class LgWebOSDevice(MediaPlayerDevice): icon = self._app_list[self._current_source_id]['largeIcon'] if not icon.startswith('http'): icon = self._app_list[self._current_source_id]['icon'] + + # 'icon' holds a URL with a transient key. Avoid unnecessary + # updates by returning the same URL until the image changes. + if self._last_icon and \ + (icon.split('/')[-1] == self._last_icon.split('/')[-1]): + return self._last_icon + self._last_icon = icon return icon return None