mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +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):
|
def update(self):
|
||||||
"""Retrieve latest state of the TV."""
|
"""Retrieve latest state of the TV."""
|
||||||
is_on = self._device.get_power_state()
|
is_on = self._device.get_power_state()
|
||||||
if is_on is None:
|
|
||||||
self._state = None
|
if is_on:
|
||||||
return
|
|
||||||
if is_on is False:
|
|
||||||
self._state = STATE_OFF
|
|
||||||
else:
|
|
||||||
self._state = STATE_ON
|
self._state = STATE_ON
|
||||||
|
|
||||||
volume = self._device.get_current_volume()
|
volume = self._device.get_current_volume()
|
||||||
if volume is not None:
|
if volume is not None:
|
||||||
self._volume_level = float(volume) / 100.
|
self._volume_level = float(volume) / 100.
|
||||||
input_ = self._device.get_current_input()
|
|
||||||
if input_ is not None:
|
input_ = self._device.get_current_input()
|
||||||
self._current_input = input_.meta_name
|
if input_ is not None:
|
||||||
inputs = self._device.get_inputs()
|
self._current_input = input_.meta_name
|
||||||
if inputs is not None:
|
|
||||||
self._available_inputs = []
|
inputs = self._device.get_inputs()
|
||||||
for input_ in inputs:
|
if inputs is not None:
|
||||||
self._available_inputs.append(input_.name)
|
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
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user