diff --git a/homeassistant/components/smlight/config_flow.py b/homeassistant/components/smlight/config_flow.py index 98da153ce751d2..e8984300ff15bc 100644 --- a/homeassistant/components/smlight/config_flow.py +++ b/homeassistant/components/smlight/config_flow.py @@ -139,10 +139,6 @@ async def async_step_reauth( self.context["entry_id"] ) host = entry_data[CONF_HOST] - self.context["title_placeholders"] = { - "host": host, - "name": entry_data.get(CONF_USERNAME, "unknown"), - } self.client = Api2(host, session=async_get_clientsession(self.hass)) self.host = host @@ -166,7 +162,8 @@ async def async_step_reauth_confirm( assert self._reauth_entry is not None return self.async_update_reload_and_abort( - self._reauth_entry, data={**user_input, CONF_HOST: self.host} + self._reauth_entry, + data={**self._reauth_entry.data, **user_input}, ) return self.async_show_form( @@ -197,4 +194,5 @@ async def _async_complete_entry( user_input[CONF_HOST] = self.host assert info.model is not None - return self.async_create_entry(title=info.model, data=user_input) + title = self.context.get("title_placeholders", {}).get(CONF_NAME) or info.model + return self.async_create_entry(title=title, data=user_input) diff --git a/homeassistant/components/smlight/strings.json b/homeassistant/components/smlight/strings.json index 7e17a53a38a6cd..bca42f642b72c4 100644 --- a/homeassistant/components/smlight/strings.json +++ b/homeassistant/components/smlight/strings.json @@ -19,7 +19,7 @@ }, "reauth_confirm": { "title": "[%key:common::config_flow::title::reauth%]", - "description": "Please enter the correct username and password for host: {host}", + "description": "Please enter the correct username and password", "data": { "username": "[%key:common::config_flow::data::username%]", "password": "[%key:common::config_flow::data::password%]" diff --git a/tests/components/smlight/test_config_flow.py b/tests/components/smlight/test_config_flow.py index fb07e29edd486a..dae727c7a29651 100644 --- a/tests/components/smlight/test_config_flow.py +++ b/tests/components/smlight/test_config_flow.py @@ -91,7 +91,7 @@ async def test_zeroconf_flow( assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["context"]["source"] == "zeroconf" assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff" - assert result2["title"] == "SLZB-06p7" + assert result2["title"] == "slzb-06" assert result2["data"] == { CONF_HOST: MOCK_HOST, } @@ -143,7 +143,7 @@ async def test_zeroconf_flow_auth( assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["context"]["source"] == "zeroconf" assert result3["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff" - assert result3["title"] == "SLZB-06p7" + assert result3["title"] == "slzb-06" assert result3["data"] == { CONF_USERNAME: MOCK_USERNAME, CONF_PASSWORD: MOCK_PASSWORD, @@ -356,7 +356,7 @@ async def test_zeroconf_legacy_mac( assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["context"]["source"] == "zeroconf" assert result2["context"]["unique_id"] == "aa:bb:cc:dd:ee:ff" - assert result2["title"] == "SLZB-06p7" + assert result2["title"] == "slzb-06" assert result2["data"] == { CONF_HOST: MOCK_HOST, }