mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use Coerce(float) on service options for kef (#35659)
* use Coerce(float) on service options * defer the type from options list
This commit is contained in:
parent
f4c5b9f8f8
commit
e6065569ae
@ -160,9 +160,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
platform.async_register_entity_service(SERVICE_UPDATE_DSP, {}, "update_dsp")
|
platform.async_register_entity_service(SERVICE_UPDATE_DSP, {}, "update_dsp")
|
||||||
|
|
||||||
def add_service(name, which, option):
|
def add_service(name, which, option):
|
||||||
|
options = DSP_OPTION_MAPPING[which]
|
||||||
|
dtype = type(options[0]) # int or float
|
||||||
platform.async_register_entity_service(
|
platform.async_register_entity_service(
|
||||||
name,
|
name,
|
||||||
{vol.Required(option): vol.In(DSP_OPTION_MAPPING[which])},
|
{vol.Required(option): vol.All(vol.Coerce(dtype), vol.In(options))},
|
||||||
f"set_{which}",
|
f"set_{which}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user