Section support for data entry flows (#118369)
* Add expandable support for data entry form flows * Update config_validation.py * optional options * Adjust * Correct translations of data within sections * Update homeassistant/components/kitchen_sink/config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Add missing import * Update tests/components/kitchen_sink/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Format code * Match frontend when serializing * Move section class to data_entry_flow * Correct serializing * Fix import in kitchen_sink * Move and update test --------- Co-authored-by: Bram Kragten <mail@bramkragten.nl> Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
parent
3d1ff72a88
commit
0545ed8082
9 changed files with 222 additions and 1 deletions
|
@ -1037,6 +1037,7 @@ def key_dependency(
|
|||
|
||||
def custom_serializer(schema: Any) -> Any:
|
||||
"""Serialize additional types for voluptuous_serialize."""
|
||||
from .. import data_entry_flow # pylint: disable=import-outside-toplevel
|
||||
from . import selector # pylint: disable=import-outside-toplevel
|
||||
|
||||
if schema is positive_time_period_dict:
|
||||
|
@ -1048,6 +1049,15 @@ def custom_serializer(schema: Any) -> Any:
|
|||
if schema is boolean:
|
||||
return {"type": "boolean"}
|
||||
|
||||
if isinstance(schema, data_entry_flow.section):
|
||||
return {
|
||||
"type": "expandable",
|
||||
"schema": voluptuous_serialize.convert(
|
||||
schema.schema, custom_serializer=custom_serializer
|
||||
),
|
||||
"expanded": not schema.options["collapsed"],
|
||||
}
|
||||
|
||||
if isinstance(schema, multi_select):
|
||||
return {"type": "multi_select", "options": schema.options}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue