mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
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 <roi.dayan@gmail.com>
This commit is contained in:
parent
757f6278eb
commit
5c4f04e9fc
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user