From 5c4f04e9fc54a192f368be343a7426df55839d08 Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Fri, 16 Dec 2016 08:51:08 +0200 Subject: [PATCH] Fix webostv component to accept any custom sources (#4915) Updated the schema check to accept any string Search custom sources in app title and app id The makes the short list redundant and thus removed Tested by adding livetv, netflix, youtube, makovod and others This is also compatible with the list that was supported till now so current users won't see any difference. Signed-off-by: Roi Dayan --- .../components/media_player/webostv.py | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/media_player/webostv.py b/homeassistant/components/media_player/webostv.py index e131cad97cd..40792c338b2 100644 --- a/homeassistant/components/media_player/webostv.py +++ b/homeassistant/components/media_player/webostv.py @@ -41,19 +41,9 @@ SUPPORT_WEBOSTV = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \ MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(seconds=1) -WEBOS_APP_LIVETV = 'com.webos.app.livetv' -WEBOS_APP_YOUTUBE = 'youtube.leanback.v4' -WEBOS_APP_MAKO = 'makotv' - -WEBOS_APPS_SHORT = { - 'livetv': WEBOS_APP_LIVETV, - 'youtube': WEBOS_APP_YOUTUBE, - 'makotv': WEBOS_APP_MAKO -} - CUSTOMIZE_SCHEMA = vol.Schema({ vol.Optional(CONF_SOURCES): - vol.All(cv.ensure_list, [vol.In(WEBOS_APPS_SHORT)]), + vol.All(cv.ensure_list, [cv.string]), }) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @@ -175,20 +165,16 @@ class LgWebOSDevice(MediaPlayerDevice): self._source_list = {} self._app_list = {} - custom_sources = [] - for source in self._customize.get(CONF_SOURCES, []): - app_id = WEBOS_APPS_SHORT.get(source, None) - if app_id: - custom_sources.append(app_id) - else: - custom_sources.append(source) + custom_sources = self._customize.get(CONF_SOURCES, []) for app in self._client.get_apps(): self._app_list[app['id']] = app if app['id'] == self._current_source_id: self._current_source = app['title'] self._source_list[app['title']] = app - if app['id'] in custom_sources: + elif (app['id'] in custom_sources or + any(word in app['title'] for word in custom_sources) or + any(word in app['id'] for word in custom_sources)): self._source_list[app['title']] = app for source in self._client.get_inputs():