Fix kitchen sink

This commit is contained in:
G Johansson 2024-11-24 19:19:21 +00:00
parent bbba064acf
commit 1a2c59ffeb
2 changed files with 39 additions and 6 deletions

View File

@ -79,17 +79,20 @@ class OptionsFlowHandler(OptionsFlow):
{
vol.Optional(
CONF_BOOLEAN,
default=False,
default=self.config_entry.options.get(
"section_1", {}
).get(CONF_BOOLEAN, False),
): bool,
vol.Optional(
CONF_INT,
default=10,
self.config_entry.options.get("section_1", {}).get(
CONF_INT, 10
),
): int,
}
),
{
"collapsed": False,
"default": self.config_entry.options.get("section_1"),
},
),
vol.Required("section_2"): data_entry_flow.section(
@ -108,7 +111,7 @@ class OptionsFlowHandler(OptionsFlow):
{
"collapsed": False,
"multiple": True,
"default": self.config_entry.options.get("section_2"),
"default": self.config_entry.options.get("section_2", []),
},
),
}

View File

@ -98,9 +98,39 @@ async def test_options_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={"section_1": {"bool": True, "int": 15}},
user_input={
"section_1": {
"bool": True,
"int": 15,
},
"section_2": [
{
"a": 2,
"b": 4,
},
{
"a": 5,
"b": 7,
},
],
},
)
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {"section_1": {"bool": True, "int": 15}}
assert config_entry.options == {
"section_1": {
"bool": True,
"int": 15,
},
"section_2": [
{
"a": 2,
"b": 4,
},
{
"a": 5,
"b": 7,
},
],
}
await hass.async_block_till_done()