mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Reduce Vizio API calls (#35726)
* reduce calls to API * get apps list every time * fix typo
This commit is contained in:
parent
e2551b4e21
commit
eec1b3e7a7
@ -137,7 +137,7 @@ class VizioDevice(MediaPlayerEntity):
|
||||
self._current_app = None
|
||||
self._current_app_config = None
|
||||
self._current_sound_mode = None
|
||||
self._available_sound_modes = None
|
||||
self._available_sound_modes = []
|
||||
self._available_inputs = []
|
||||
self._available_apps = []
|
||||
self._conf_apps = config_entry.options.get(CONF_APPS, {})
|
||||
@ -192,12 +192,9 @@ class VizioDevice(MediaPlayerEntity):
|
||||
self._volume_level = None
|
||||
self._is_volume_muted = None
|
||||
self._current_input = None
|
||||
self._available_inputs = None
|
||||
self._current_app = None
|
||||
self._current_app_config = None
|
||||
self._available_apps = None
|
||||
self._current_sound_mode = None
|
||||
self._available_sound_modes = None
|
||||
return
|
||||
|
||||
self._state = STATE_ON
|
||||
@ -215,7 +212,7 @@ class VizioDevice(MediaPlayerEntity):
|
||||
if VIZIO_SOUND_MODE in audio_settings:
|
||||
self._supported_commands |= SUPPORT_SELECT_SOUND_MODE
|
||||
self._current_sound_mode = audio_settings[VIZIO_SOUND_MODE]
|
||||
if self._available_sound_modes is None:
|
||||
if not self._available_sound_modes:
|
||||
self._available_sound_modes = await self._device.get_setting_options(
|
||||
VIZIO_AUDIO_SETTINGS, VIZIO_SOUND_MODE
|
||||
)
|
||||
@ -226,13 +223,14 @@ class VizioDevice(MediaPlayerEntity):
|
||||
if input_ is not None:
|
||||
self._current_input = input_
|
||||
|
||||
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
||||
if not self._available_inputs:
|
||||
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
||||
|
||||
# If no inputs returned, end update
|
||||
if not inputs:
|
||||
return
|
||||
# If no inputs returned, end update
|
||||
if not inputs:
|
||||
return
|
||||
|
||||
self._available_inputs = [input_.name for input_ in inputs]
|
||||
self._available_inputs = [input_.name for input_ in inputs]
|
||||
|
||||
# Return before setting app variables if INPUT_APPS isn't in available inputs
|
||||
if self._device_class == DEVICE_CLASS_SPEAKER or not any(
|
||||
@ -242,8 +240,7 @@ class VizioDevice(MediaPlayerEntity):
|
||||
|
||||
# Create list of available known apps from known app list after
|
||||
# filtering by CONF_INCLUDE/CONF_EXCLUDE
|
||||
if not self._available_apps:
|
||||
self._available_apps = self._apps_list(self._device.get_apps_list())
|
||||
self._available_apps = self._apps_list(self._device.get_apps_list())
|
||||
|
||||
self._current_app_config = await self._device.get_current_app_config(
|
||||
log_api_exception=False
|
||||
|
Loading…
x
Reference in New Issue
Block a user