diff --git a/homeassistant/components/aprilaire/config_flow.py b/homeassistant/components/aprilaire/config_flow.py index 290f657770b6..270e12364a5a 100644 --- a/homeassistant/components/aprilaire/config_flow.py +++ b/homeassistant/components/aprilaire/config_flow.py @@ -64,6 +64,8 @@ class AprilaireConfigFlow(ConfigFlow, domain=DOMAIN): return self.async_show_form( step_id="user", - data_schema=STEP_USER_DATA_SCHEMA, + data_schema=self.add_suggested_values_to_schema( + STEP_USER_DATA_SCHEMA, user_input + ), errors={"base": "connection_failed"}, ) diff --git a/tests/components/aprilaire/test_config_flow.py b/tests/components/aprilaire/test_config_flow.py index b49a87758098..6c0523df5a61 100644 --- a/tests/components/aprilaire/test_config_flow.py +++ b/tests/components/aprilaire/test_config_flow.py @@ -32,7 +32,7 @@ async def test_config_flow_invalid_data( result["flow_id"], { "host": "localhost", - "port": 7000, + "port": 8000, }, ) @@ -45,6 +45,11 @@ async def test_config_flow_invalid_data( assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "connection_failed"} + suggested_values = { + str(key): key.description["suggested_value"] + for key in result["data_schema"].schema + } + assert suggested_values == {"host": "localhost", "port": 8000} client.data = {"mac_address": "1:2:3:4:5:6"} @@ -59,13 +64,14 @@ async def test_config_flow_invalid_data( result["flow_id"], { "host": "localhost", - "port": 7000, + "port": 8000, }, ) await hass.async_block_till_done() assert result["type"] is FlowResultType.CREATE_ENTRY assert result["result"].unique_id == "1:2:3:4:5:6" + assert result["data"] == {"host": "localhost", "port": 8000} async def test_config_flow_data(client: AprilaireClient, hass: HomeAssistant) -> None: