mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Standardize Vizio update service schema (#38636)
* update voluptuous schema to match standards and to handle data transformations * improve test
This commit is contained in:
parent
50cd6be18d
commit
0d5e279509
@ -34,9 +34,9 @@ ATTR_SETTING_NAME = "setting_name"
|
|||||||
ATTR_NEW_VALUE = "new_value"
|
ATTR_NEW_VALUE = "new_value"
|
||||||
|
|
||||||
UPDATE_SETTING_SCHEMA = {
|
UPDATE_SETTING_SCHEMA = {
|
||||||
vol.Required(ATTR_SETTING_TYPE): cv.string,
|
vol.Required(ATTR_SETTING_TYPE): vol.All(cv.string, vol.Lower, cv.slugify),
|
||||||
vol.Required(ATTR_SETTING_NAME): cv.string,
|
vol.Required(ATTR_SETTING_NAME): vol.All(cv.string, vol.Lower, cv.slugify),
|
||||||
vol.Required(ATTR_NEW_VALUE): vol.Or(vol.Coerce(int), cv.string),
|
vol.Required(ATTR_NEW_VALUE): vol.Any(vol.Coerce(int), cv.string),
|
||||||
}
|
}
|
||||||
|
|
||||||
CONF_ADDITIONAL_CONFIGS = "additional_configs"
|
CONF_ADDITIONAL_CONFIGS = "additional_configs"
|
||||||
|
@ -291,9 +291,7 @@ class VizioDevice(MediaPlayerEntity):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Update a setting when update_setting service is called."""
|
"""Update a setting when update_setting service is called."""
|
||||||
await self._device.set_setting(
|
await self._device.set_setting(
|
||||||
setting_type.lower().replace(" ", "_"),
|
setting_type, setting_name, new_value,
|
||||||
setting_name.lower().replace(" ", "_"),
|
|
||||||
new_value,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
|
@ -387,12 +387,26 @@ async def test_services(
|
|||||||
SERVICE_SELECT_SOUND_MODE,
|
SERVICE_SELECT_SOUND_MODE,
|
||||||
{ATTR_SOUND_MODE: "Music"},
|
{ATTR_SOUND_MODE: "Music"},
|
||||||
)
|
)
|
||||||
|
# Test that the update_setting service does config validation/transformation correctly
|
||||||
|
await _test_service(
|
||||||
|
hass,
|
||||||
|
DOMAIN,
|
||||||
|
"set_setting",
|
||||||
|
SERVICE_UPDATE_SETTING,
|
||||||
|
{"setting_type": "Audio", "setting_name": "AV Delay", "new_value": "0"},
|
||||||
|
"audio",
|
||||||
|
"av_delay",
|
||||||
|
0,
|
||||||
|
)
|
||||||
await _test_service(
|
await _test_service(
|
||||||
hass,
|
hass,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
"set_setting",
|
"set_setting",
|
||||||
SERVICE_UPDATE_SETTING,
|
SERVICE_UPDATE_SETTING,
|
||||||
{"setting_type": "Audio", "setting_name": "EQ", "new_value": "Music"},
|
{"setting_type": "Audio", "setting_name": "EQ", "new_value": "Music"},
|
||||||
|
"audio",
|
||||||
|
"eq",
|
||||||
|
"Music",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user