From b8287d6db6a37172fdd6af891b5417cf0094ad23 Mon Sep 17 00:00:00 2001 From: SNoof85 Date: Tue, 6 Oct 2020 20:00:07 +0200 Subject: [PATCH] Use reference strings in Vesync (#41341) * Update strings.json * Update config_flow.py * Update test_config_flow.py --- homeassistant/components/vesync/config_flow.py | 4 ++-- homeassistant/components/vesync/strings.json | 6 +++--- tests/components/vesync/test_config_flow.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/vesync/config_flow.py b/homeassistant/components/vesync/config_flow.py index 8b0e8ae6781..90db4db14b8 100644 --- a/homeassistant/components/vesync/config_flow.py +++ b/homeassistant/components/vesync/config_flow.py @@ -51,7 +51,7 @@ class VeSyncFlowHandler(config_entries.ConfigFlow): async def async_step_user(self, user_input=None): """Handle a flow start.""" if configured_instances(self.hass): - return self.async_abort(reason="already_setup") + return self.async_abort(reason="single_instance_allowed") if not user_input: return self._show_form() @@ -62,7 +62,7 @@ class VeSyncFlowHandler(config_entries.ConfigFlow): manager = VeSync(self._username, self._password) login = await self.hass.async_add_executor_job(manager.login) if not login: - return self._show_form(errors={"base": "invalid_login"}) + return self._show_form(errors={"base": "invalid_auth"}) return self.async_create_entry( title=self._username, diff --git a/homeassistant/components/vesync/strings.json b/homeassistant/components/vesync/strings.json index 1bdf32e1037..8359691effe 100644 --- a/homeassistant/components/vesync/strings.json +++ b/homeassistant/components/vesync/strings.json @@ -10,10 +10,10 @@ } }, "error": { - "invalid_login": "Invalid username or password" + "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]" }, "abort": { - "already_setup": "Only one Vesync instance is allowed" + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" } } -} \ No newline at end of file +} diff --git a/tests/components/vesync/test_config_flow.py b/tests/components/vesync/test_config_flow.py index aedf94da4ab..c82307d351c 100644 --- a/tests/components/vesync/test_config_flow.py +++ b/tests/components/vesync/test_config_flow.py @@ -17,7 +17,7 @@ async def test_abort_already_setup(hass): result = await flow.async_step_user() assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "already_setup" + assert result["reason"] == "single_instance_allowed" async def test_invalid_login_error(hass): @@ -29,7 +29,7 @@ async def test_invalid_login_error(hass): result = await flow.async_step_user(user_input=test_dict) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["errors"] == {"base": "invalid_login"} + assert result["errors"] == {"base": "invalid_auth"} async def test_config_flow_configuration_yaml(hass):