diff --git a/homeassistant/components/totalconnect/config_flow.py b/homeassistant/components/totalconnect/config_flow.py index 122b1ad88b4..8f39346f47e 100644 --- a/homeassistant/components/totalconnect/config_flow.py +++ b/homeassistant/components/totalconnect/config_flow.py @@ -65,10 +65,10 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if self.usercodes[location_id] is None: valid = await self.hass.async_add_executor_job( self.client.locations[location_id].set_usercode, - user_entry[CONF_LOCATION], + user_entry[CONF_USERCODES], ) if valid: - self.usercodes[location_id] = user_entry[CONF_LOCATION] + self.usercodes[location_id] = user_entry[CONF_USERCODES] else: errors[CONF_LOCATION] = "usercode" break @@ -93,12 +93,14 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): # show the next location that needs a usercode location_codes = {} + location_for_user = "" for location_id in self.usercodes: if self.usercodes[location_id] is None: + location_for_user = location_id location_codes[ vol.Required( - CONF_LOCATION, - default=location_id, + CONF_USERCODES, + default="0000", ) ] = str break @@ -108,7 +110,7 @@ class TotalConnectConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): step_id="locations", data_schema=data_schema, errors=errors, - description_placeholders={"base": "description"}, + description_placeholders={"location_id": location_for_user}, ) async def async_step_reauth(self, config): diff --git a/homeassistant/components/totalconnect/strings.json b/homeassistant/components/totalconnect/strings.json index f284e4b86da..5c32d19b348 100644 --- a/homeassistant/components/totalconnect/strings.json +++ b/homeassistant/components/totalconnect/strings.json @@ -10,9 +10,9 @@ }, "locations": { "title": "Location Usercodes", - "description": "Enter the usercode for this user at this location", + "description": "Enter the usercode for this user at location {location_id}", "data": { - "location": "[%key:common::config_flow::data::location%]" + "usercode": "Usercode" } }, "reauth_confirm": { diff --git a/homeassistant/components/totalconnect/translations/en.json b/homeassistant/components/totalconnect/translations/en.json index 5071e623701..02ea1bfccbd 100644 --- a/homeassistant/components/totalconnect/translations/en.json +++ b/homeassistant/components/totalconnect/translations/en.json @@ -11,9 +11,9 @@ "step": { "locations": { "data": { - "location": "Location" + "usercode": "Usercode" }, - "description": "Enter the usercode for this user at this location", + "description": "Enter the usercode for this user at location {location_id}", "title": "Location Usercodes" }, "reauth_confirm": { diff --git a/tests/components/totalconnect/test_config_flow.py b/tests/components/totalconnect/test_config_flow.py index 2f89beab0e0..3751abfc361 100644 --- a/tests/components/totalconnect/test_config_flow.py +++ b/tests/components/totalconnect/test_config_flow.py @@ -2,7 +2,7 @@ from unittest.mock import patch from homeassistant import data_entry_flow -from homeassistant.components.totalconnect.const import CONF_LOCATION, DOMAIN +from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER from homeassistant.const import CONF_PASSWORD @@ -67,7 +67,7 @@ async def test_user_show_locations(hass): # user enters an invalid usercode result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - user_input={CONF_LOCATION: "bad"}, + user_input={CONF_USERCODES: "bad"}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM assert result2["step_id"] == "locations" @@ -77,7 +77,7 @@ async def test_user_show_locations(hass): # user enters a valid usercode result3 = await hass.config_entries.flow.async_configure( result2["flow_id"], - user_input={CONF_LOCATION: "7890"}, + user_input={CONF_USERCODES: "7890"}, ) assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY # client should have sent another request to validate usercode