diff --git a/homeassistant/components/seventeentrack/config_flow.py b/homeassistant/components/seventeentrack/config_flow.py index f42ff184f81..ae31e1962d7 100644 --- a/homeassistant/components/seventeentrack/config_flow.py +++ b/homeassistant/components/seventeentrack/config_flow.py @@ -67,7 +67,7 @@ class SeventeenTrackConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input: - client = await self._get_client() + client = self._get_client() try: if not await client.profile.login( @@ -101,19 +101,17 @@ class SeventeenTrackConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: """Import 17Track config from configuration.yaml.""" - client = await self._get_client() + client = self._get_client() try: login_result = await client.profile.login( import_data[CONF_USERNAME], import_data[CONF_PASSWORD] ) - except SeventeenTrackError as err: - _LOGGER.error("There was an error while logging in: %s", err) + except SeventeenTrackError: return self.async_abort(reason="cannot_connect") if not login_result: - _LOGGER.error("Invalid username and password provided") - return self.async_abort(reason="invalid_credentials") + return self.async_abort(reason="invalid_auth") account_id = client.profile.account_id @@ -132,6 +130,7 @@ class SeventeenTrackConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): }, ) - async def _get_client(self): + @callback + def _get_client(self): session = aiohttp_client.async_get_clientsession(self.hass) return SeventeenTrackClient(session=session) diff --git a/homeassistant/components/seventeentrack/sensor.py b/homeassistant/components/seventeentrack/sensor.py index bdf4b74ac59..1de627fab39 100644 --- a/homeassistant/components/seventeentrack/sensor.py +++ b/homeassistant/components/seventeentrack/sensor.py @@ -94,12 +94,12 @@ async def async_setup_platform( async_create_issue( hass, DOMAIN, - f"deprecated_yaml_import_issue_${result['reason']}", + f"deprecated_yaml_import_issue_{result['reason']}", breaks_in_ha_version="2024.10.0", is_fixable=False, issue_domain=DOMAIN, severity=IssueSeverity.WARNING, - translation_key=f"deprecated_yaml_import_issue_${result['reason']}", + translation_key=f"deprecated_yaml_import_issue_{result['reason']}", translation_placeholders=ISSUE_PLACEHOLDER, ) diff --git a/homeassistant/components/seventeentrack/strings.json b/homeassistant/components/seventeentrack/strings.json index 1514509d6c2..39ddb5ef8ef 100644 --- a/homeassistant/components/seventeentrack/strings.json +++ b/homeassistant/components/seventeentrack/strings.json @@ -9,11 +9,13 @@ } }, "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_service%]" + "already_configured": "[%key:common::config_flow::abort::already_configured_service%]", + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]" }, "error": { - "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]", - "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", + "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]" } }, "options": { @@ -32,8 +34,8 @@ "title": "The 17Track YAML configuration import cannot connect to server", "description": "Configuring 17Track using YAML is being removed but there was a connection error importing your YAML configuration.\n\nThings you can try:\nMake sure your home assistant can reach the web.\n\nThen restart Home Assistant to try importing this integration again.\n\nAlternatively, you may remove the 17Track configuration from your YAML configuration entirely, restart Home Assistant, and add the 17Track integration manually." }, - "deprecated_yaml_import_issue_invalid_credentials": { - "title": "The 17Track YAML configuration import request failed due to invalid credentials", + "deprecated_yaml_import_issue_invalid_auth": { + "title": "The 17Track YAML configuration import request failed due to invalid authentication", "description": "Configuring 17Track using YAML is being removed but there were invalid credentials provided while importing your existing configuration.\nSetup will not proceed.\n\nVerify that your 17Track credentials are correct and restart Home Assistant to attempt the import again.\n\nAlternatively, you may remove the 17Track configuration from your YAML configuration entirely, restart Home Assistant, and add the 17Track integration manually." } } diff --git a/tests/components/seventeentrack/test_config_flow.py b/tests/components/seventeentrack/test_config_flow.py index 04e4b50d066..ae48fb6c792 100644 --- a/tests/components/seventeentrack/test_config_flow.py +++ b/tests/components/seventeentrack/test_config_flow.py @@ -125,7 +125,7 @@ async def test_import_flow(hass: HomeAssistant, mock_seventeentrack: AsyncMock) ( False, None, - "invalid_credentials", + "invalid_auth", ), ( True,