mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Only default if multiple
This commit is contained in:
parent
073ba775b2
commit
6986e12c4d
@ -1136,7 +1136,7 @@ def _custom_serializer(schema: Any, *, allow_section: bool) -> Any:
|
||||
if isinstance(schema, data_entry_flow.section):
|
||||
if not allow_section:
|
||||
raise ValueError("Nesting expandable sections is not supported")
|
||||
return {
|
||||
section_schema = {
|
||||
"type": "expandable",
|
||||
"schema": voluptuous_serialize.convert(
|
||||
schema.schema,
|
||||
@ -1146,8 +1146,10 @@ def _custom_serializer(schema: Any, *, allow_section: bool) -> Any:
|
||||
),
|
||||
"expanded": not schema.options["collapsed"],
|
||||
"multiple": schema.options["multiple"],
|
||||
"default": schema.options.get("default"),
|
||||
}
|
||||
if schema.options["multiple"]:
|
||||
section_schema["default"] = schema.options["default"]
|
||||
return section_schema
|
||||
|
||||
if isinstance(schema, multi_select):
|
||||
return {"type": "multi_select", "options": schema.options}
|
||||
|
@ -1021,7 +1021,7 @@ def test_section_in_serializer() -> None:
|
||||
],
|
||||
"type": "expandable",
|
||||
"multiple": False,
|
||||
"default": [],
|
||||
"default": None,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user