mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Avoid unnecessary commands in Vizio update function (#20867)
This commit is contained in:
parent
8a026bf214
commit
0ebd12fa6c
@ -92,25 +92,31 @@ class VizioDevice(MediaPlayerDevice):
|
||||
def update(self):
|
||||
"""Retrieve latest state of the TV."""
|
||||
is_on = self._device.get_power_state()
|
||||
if is_on is None:
|
||||
self._state = None
|
||||
return
|
||||
if is_on is False:
|
||||
self._state = STATE_OFF
|
||||
else:
|
||||
|
||||
if is_on:
|
||||
self._state = STATE_ON
|
||||
|
||||
volume = self._device.get_current_volume()
|
||||
if volume is not None:
|
||||
self._volume_level = float(volume) / 100.
|
||||
input_ = self._device.get_current_input()
|
||||
if input_ is not None:
|
||||
self._current_input = input_.meta_name
|
||||
inputs = self._device.get_inputs()
|
||||
if inputs is not None:
|
||||
self._available_inputs = []
|
||||
for input_ in inputs:
|
||||
self._available_inputs.append(input_.name)
|
||||
volume = self._device.get_current_volume()
|
||||
if volume is not None:
|
||||
self._volume_level = float(volume) / 100.
|
||||
|
||||
input_ = self._device.get_current_input()
|
||||
if input_ is not None:
|
||||
self._current_input = input_.meta_name
|
||||
|
||||
inputs = self._device.get_inputs()
|
||||
if inputs is not None:
|
||||
self._available_inputs = [input_.name for input_ in inputs]
|
||||
|
||||
else:
|
||||
if is_on is None:
|
||||
self._state = None
|
||||
else:
|
||||
self._state = STATE_OFF
|
||||
|
||||
self._volume_level = None
|
||||
self._current_input = None
|
||||
self._available_inputs = None
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user