mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +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 = None
|
||||||
self._current_app_config = None
|
self._current_app_config = None
|
||||||
self._current_sound_mode = None
|
self._current_sound_mode = None
|
||||||
self._available_sound_modes = None
|
self._available_sound_modes = []
|
||||||
self._available_inputs = []
|
self._available_inputs = []
|
||||||
self._available_apps = []
|
self._available_apps = []
|
||||||
self._conf_apps = config_entry.options.get(CONF_APPS, {})
|
self._conf_apps = config_entry.options.get(CONF_APPS, {})
|
||||||
@ -192,12 +192,9 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
self._volume_level = None
|
self._volume_level = None
|
||||||
self._is_volume_muted = None
|
self._is_volume_muted = None
|
||||||
self._current_input = None
|
self._current_input = None
|
||||||
self._available_inputs = None
|
|
||||||
self._current_app = None
|
self._current_app = None
|
||||||
self._current_app_config = None
|
self._current_app_config = None
|
||||||
self._available_apps = None
|
|
||||||
self._current_sound_mode = None
|
self._current_sound_mode = None
|
||||||
self._available_sound_modes = None
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self._state = STATE_ON
|
self._state = STATE_ON
|
||||||
@ -215,7 +212,7 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
if VIZIO_SOUND_MODE in audio_settings:
|
if VIZIO_SOUND_MODE in audio_settings:
|
||||||
self._supported_commands |= SUPPORT_SELECT_SOUND_MODE
|
self._supported_commands |= SUPPORT_SELECT_SOUND_MODE
|
||||||
self._current_sound_mode = audio_settings[VIZIO_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(
|
self._available_sound_modes = await self._device.get_setting_options(
|
||||||
VIZIO_AUDIO_SETTINGS, VIZIO_SOUND_MODE
|
VIZIO_AUDIO_SETTINGS, VIZIO_SOUND_MODE
|
||||||
)
|
)
|
||||||
@ -226,6 +223,7 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
if input_ is not None:
|
if input_ is not None:
|
||||||
self._current_input = input_
|
self._current_input = input_
|
||||||
|
|
||||||
|
if not self._available_inputs:
|
||||||
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
||||||
|
|
||||||
# If no inputs returned, end update
|
# If no inputs returned, end update
|
||||||
@ -242,7 +240,6 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
|
|
||||||
# Create list of available known apps from known app list after
|
# Create list of available known apps from known app list after
|
||||||
# filtering by CONF_INCLUDE/CONF_EXCLUDE
|
# 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(
|
self._current_app_config = await self._device.get_current_app_config(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user