diff --git a/homeassistant/components/honeywell/config_flow.py b/homeassistant/components/honeywell/config_flow.py index 8b24fc912f1..dab8353c773 100644 --- a/homeassistant/components/honeywell/config_flow.py +++ b/homeassistant/components/honeywell/config_flow.py @@ -22,7 +22,12 @@ from .const import ( DOMAIN, ) -REAUTH_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str}) +REAUTH_SCHEMA = vol.Schema( + { + vol.Required(CONF_USERNAME): str, + vol.Required(CONF_PASSWORD): str, + } +) class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @@ -42,18 +47,12 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) -> FlowResult: """Confirm re-authentication with Honeywell.""" errors: dict[str, str] = {} - + assert self.entry is not None if user_input: - assert self.entry is not None - password = user_input[CONF_PASSWORD] - data = { - CONF_USERNAME: self.entry.data[CONF_USERNAME], - CONF_PASSWORD: password, - } - try: await self.is_valid( - username=data[CONF_USERNAME], password=data[CONF_PASSWORD] + username=user_input[CONF_USERNAME], + password=user_input[CONF_PASSWORD], ) except aiosomecomfort.AuthError: @@ -71,7 +70,7 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self.entry, data={ **self.entry.data, - CONF_PASSWORD: password, + **user_input, }, ) await self.hass.config_entries.async_reload(self.entry.entry_id) @@ -79,7 +78,9 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self.async_show_form( step_id="reauth_confirm", - data_schema=REAUTH_SCHEMA, + data_schema=self.add_suggested_values_to_schema( + REAUTH_SCHEMA, self.entry.data + ), errors=errors, ) diff --git a/tests/components/honeywell/test_config_flow.py b/tests/components/honeywell/test_config_flow.py index a416f030a05..25ffa0a6093 100644 --- a/tests/components/honeywell/test_config_flow.py +++ b/tests/components/honeywell/test_config_flow.py @@ -156,14 +156,14 @@ async def test_reauth_flow(hass: HomeAssistant) -> None: ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_PASSWORD: "new-password"}, + {CONF_USERNAME: "new-username", CONF_PASSWORD: "new-password"}, ) await hass.async_block_till_done() assert result2["type"] == FlowResultType.ABORT assert result2["reason"] == "reauth_successful" assert mock_entry.data == { - CONF_USERNAME: "test-username", + CONF_USERNAME: "new-username", CONF_PASSWORD: "new-password", } @@ -200,7 +200,7 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, client: MagicMock) -> ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_PASSWORD: "new-password"}, + {CONF_USERNAME: "new-username", CONF_PASSWORD: "new-password"}, ) await hass.async_block_till_done() @@ -246,7 +246,7 @@ async def test_reauth_flow_connnection_error( result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {CONF_PASSWORD: "new-password"}, + {CONF_USERNAME: "new-username", CONF_PASSWORD: "new-password"}, ) await hass.async_block_till_done()