Fix missing title placeholders in powerwall reauth (#130389)

pull/130713/head
J. Nick Koston 2024-11-11 13:48:49 -06:00 committed by Franck Nijhof
parent 929164251a
commit 79329e16cf
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 10 additions and 1 deletions

View File

@ -251,8 +251,8 @@ class PowerwallConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle reauth confirmation."""
errors: dict[str, str] | None = {}
description_placeholders: dict[str, str] = {}
if user_input is not None:
reauth_entry = self._get_reauth_entry()
if user_input is not None:
errors, _, description_placeholders = await self._async_try_connect(
{CONF_IP_ADDRESS: reauth_entry.data[CONF_IP_ADDRESS], **user_input}
)
@ -261,6 +261,10 @@ class PowerwallConfigFlow(ConfigFlow, domain=DOMAIN):
reauth_entry, data_updates=user_input
)
self.context["title_placeholders"] = {
"name": reauth_entry.title,
"ip_address": reauth_entry.data[CONF_IP_ADDRESS],
}
return self.async_show_form(
step_id="reauth_confirm",
data_schema=vol.Schema({vol.Optional(CONF_PASSWORD): str}),

View File

@ -339,6 +339,11 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
result = await entry.start_reauth_flow(hass)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
flow = hass.config_entries.flow.async_get(result["flow_id"])
assert flow["context"]["title_placeholders"] == {
"ip_address": VALID_CONFIG[CONF_IP_ADDRESS],
"name": entry.title,
}
mock_powerwall = await _mock_powerwall_site_name(hass, "My site")