From 1a2c59ffeb23e25fce5f900dac8d1aecf16674b1 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sun, 24 Nov 2024 19:19:21 +0000 Subject: [PATCH] Fix kitchen sink --- .../components/kitchen_sink/config_flow.py | 11 +++--- .../kitchen_sink/test_config_flow.py | 34 +++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/kitchen_sink/config_flow.py b/homeassistant/components/kitchen_sink/config_flow.py index c3999b317af..349e49805f2 100644 --- a/homeassistant/components/kitchen_sink/config_flow.py +++ b/homeassistant/components/kitchen_sink/config_flow.py @@ -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", []), }, ), } diff --git a/tests/components/kitchen_sink/test_config_flow.py b/tests/components/kitchen_sink/test_config_flow.py index 5f163d1342e..527f8c26ccb 100644 --- a/tests/components/kitchen_sink/test_config_flow.py +++ b/tests/components/kitchen_sink/test_config_flow.py @@ -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()