Bump pyvizio version and add additional device info (#31417)
* bump pyvizio version and add additional device info * add patches for get_model and get_version * change keywrod argument to positional for _test_service
This commit is contained in:
parent
744ae82933
commit
ee927fbc9e
7 changed files with 38 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
|||
"domain": "vizio",
|
||||
"name": "Vizio SmartCast TV",
|
||||
"documentation": "https://www.home-assistant.io/integrations/vizio",
|
||||
"requirements": ["pyvizio==0.1.16"],
|
||||
"requirements": ["pyvizio==0.1.19"],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@raman325"],
|
||||
"config_flow": true,
|
||||
|
|
|
@ -107,9 +107,17 @@ class VizioDevice(MediaPlayerDevice):
|
|||
self._max_volume = float(self._device.get_max_volume())
|
||||
self._icon = ICON[device_class]
|
||||
self._available = True
|
||||
self._model = None
|
||||
self._sw_version = None
|
||||
|
||||
async def async_update(self) -> None:
|
||||
"""Retrieve latest state of the device."""
|
||||
if not self._model:
|
||||
self._model = await self._device.get_model()
|
||||
|
||||
if not self._sw_version:
|
||||
self._sw_version = await self._device.get_version()
|
||||
|
||||
is_on = await self._device.get_power_state(log_api_exception=False)
|
||||
|
||||
if is_on is None:
|
||||
|
@ -141,9 +149,9 @@ class VizioDevice(MediaPlayerDevice):
|
|||
|
||||
input_ = await self._device.get_current_input(log_api_exception=False)
|
||||
if input_ is not None:
|
||||
self._current_input = input_.meta_name
|
||||
self._current_input = input_
|
||||
|
||||
inputs = await self._device.get_inputs(log_api_exception=False)
|
||||
inputs = await self._device.get_inputs_list(log_api_exception=False)
|
||||
if inputs is not None:
|
||||
self._available_inputs = [input_.name for input_ in inputs]
|
||||
|
||||
|
@ -235,6 +243,8 @@ class VizioDevice(MediaPlayerDevice):
|
|||
"identifiers": {(DOMAIN, self._config_entry.unique_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": "VIZIO",
|
||||
"model": self._model,
|
||||
"sw_version": self._sw_version,
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -267,7 +277,7 @@ class VizioDevice(MediaPlayerDevice):
|
|||
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Select input source."""
|
||||
await self._device.input_switch(source)
|
||||
await self._device.set_input(source)
|
||||
|
||||
async def async_volume_up(self) -> None:
|
||||
"""Increase volume of the device."""
|
||||
|
|
|
@ -1693,7 +1693,7 @@ pyversasense==0.0.6
|
|||
pyvesync==1.1.0
|
||||
|
||||
# homeassistant.components.vizio
|
||||
pyvizio==0.1.16
|
||||
pyvizio==0.1.19
|
||||
|
||||
# homeassistant.components.velux
|
||||
pyvlx==0.2.12
|
||||
|
|
|
@ -570,7 +570,7 @@ pyvera==0.3.7
|
|||
pyvesync==1.1.0
|
||||
|
||||
# homeassistant.components.vizio
|
||||
pyvizio==0.1.16
|
||||
pyvizio==0.1.19
|
||||
|
||||
# homeassistant.components.html5
|
||||
pywebpush==1.9.2
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
"""Configure py.test."""
|
||||
from asynctest import patch
|
||||
import pytest
|
||||
from pyvizio.const import DEVICE_CLASS_SPEAKER
|
||||
from pyvizio.vizio import MAX_VOLUME
|
||||
from pyvizio.const import DEVICE_CLASS_SPEAKER, MAX_VOLUME
|
||||
|
||||
from .const import CURRENT_INPUT, INPUT_LIST, UNIQUE_ID
|
||||
from .const import CURRENT_INPUT, INPUT_LIST, MODEL, UNIQUE_ID, VERSION
|
||||
|
||||
|
||||
class MockInput:
|
||||
|
@ -91,12 +90,18 @@ def vizio_update_fixture():
|
|||
return_value=int(MAX_VOLUME[DEVICE_CLASS_SPEAKER] / 2),
|
||||
), patch(
|
||||
"homeassistant.components.vizio.media_player.VizioAsync.get_current_input",
|
||||
return_value=MockInput(CURRENT_INPUT),
|
||||
return_value=CURRENT_INPUT,
|
||||
), patch(
|
||||
"homeassistant.components.vizio.media_player.VizioAsync.get_inputs",
|
||||
"homeassistant.components.vizio.media_player.VizioAsync.get_inputs_list",
|
||||
return_value=get_mock_inputs(INPUT_LIST),
|
||||
), patch(
|
||||
"homeassistant.components.vizio.media_player.VizioAsync.get_power_state",
|
||||
return_value=True,
|
||||
), patch(
|
||||
"homeassistant.components.vizio.media_player.VizioAsync.get_model",
|
||||
return_value=MODEL,
|
||||
), patch(
|
||||
"homeassistant.components.vizio.media_player.VizioAsync.get_version",
|
||||
return_value=VERSION,
|
||||
):
|
||||
yield
|
||||
|
|
|
@ -26,6 +26,8 @@ HOST2 = "192.168.1.2:9000"
|
|||
ACCESS_TOKEN = "deadbeef"
|
||||
VOLUME_STEP = 2
|
||||
UNIQUE_ID = "testid"
|
||||
MODEL = "model"
|
||||
VERSION = "version"
|
||||
|
||||
MOCK_USER_VALID_TV_CONFIG = {
|
||||
CONF_NAME: NAME,
|
||||
|
|
|
@ -7,8 +7,8 @@ import pytest
|
|||
from pyvizio.const import (
|
||||
DEVICE_CLASS_SPEAKER as VIZIO_DEVICE_CLASS_SPEAKER,
|
||||
DEVICE_CLASS_TV as VIZIO_DEVICE_CLASS_TV,
|
||||
MAX_VOLUME,
|
||||
)
|
||||
from pyvizio.vizio import MAX_VOLUME
|
||||
|
||||
from homeassistant.components.media_player import (
|
||||
ATTR_INPUT_SOURCE,
|
||||
|
@ -111,7 +111,7 @@ async def _test_service(
|
|||
hass: HomeAssistantType,
|
||||
vizio_func_name: str,
|
||||
ha_service_name: str,
|
||||
additional_service_data: dict = None,
|
||||
additional_service_data: dict,
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> None:
|
||||
|
@ -194,8 +194,8 @@ async def test_services(
|
|||
"""Test all Vizio media player entity services."""
|
||||
await _test_setup(hass, DEVICE_CLASS_TV, True)
|
||||
|
||||
await _test_service(hass, "pow_on", SERVICE_TURN_ON)
|
||||
await _test_service(hass, "pow_off", SERVICE_TURN_OFF)
|
||||
await _test_service(hass, "pow_on", SERVICE_TURN_ON, None)
|
||||
await _test_service(hass, "pow_off", SERVICE_TURN_OFF, None)
|
||||
await _test_service(
|
||||
hass, "mute_on", SERVICE_VOLUME_MUTE, {ATTR_MEDIA_VOLUME_MUTED: True}
|
||||
)
|
||||
|
@ -203,18 +203,18 @@ async def test_services(
|
|||
hass, "mute_off", SERVICE_VOLUME_MUTE, {ATTR_MEDIA_VOLUME_MUTED: False}
|
||||
)
|
||||
await _test_service(
|
||||
hass, "input_switch", SERVICE_SELECT_SOURCE, {ATTR_INPUT_SOURCE: "USB"}, "USB"
|
||||
hass, "set_input", SERVICE_SELECT_SOURCE, {ATTR_INPUT_SOURCE: "USB"}, "USB"
|
||||
)
|
||||
await _test_service(hass, "vol_up", SERVICE_VOLUME_UP)
|
||||
await _test_service(hass, "vol_down", SERVICE_VOLUME_DOWN)
|
||||
await _test_service(hass, "vol_up", SERVICE_VOLUME_UP, None)
|
||||
await _test_service(hass, "vol_down", SERVICE_VOLUME_DOWN, None)
|
||||
await _test_service(
|
||||
hass, "vol_up", SERVICE_VOLUME_SET, {ATTR_MEDIA_VOLUME_LEVEL: 1}
|
||||
)
|
||||
await _test_service(
|
||||
hass, "vol_down", SERVICE_VOLUME_SET, {ATTR_MEDIA_VOLUME_LEVEL: 0}
|
||||
)
|
||||
await _test_service(hass, "ch_up", SERVICE_MEDIA_NEXT_TRACK)
|
||||
await _test_service(hass, "ch_down", SERVICE_MEDIA_PREVIOUS_TRACK)
|
||||
await _test_service(hass, "ch_up", SERVICE_MEDIA_NEXT_TRACK, None)
|
||||
await _test_service(hass, "ch_down", SERVICE_MEDIA_PREVIOUS_TRACK, None)
|
||||
|
||||
|
||||
async def test_options_update(
|
||||
|
@ -231,7 +231,7 @@ async def test_options_update(
|
|||
entry=config_entry, options=new_options,
|
||||
)
|
||||
assert config_entry.options == updated_options
|
||||
await _test_service(hass, "vol_up", SERVICE_VOLUME_UP, num=VOLUME_STEP)
|
||||
await _test_service(hass, "vol_up", SERVICE_VOLUME_UP, None, num=VOLUME_STEP)
|
||||
|
||||
|
||||
async def _test_update_availability_switch(
|
||||
|
|
Loading…
Add table
Reference in a new issue