From c7ebfdb403bebb4470e6c07f919f978718c92e51 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Thu, 1 Oct 2020 20:44:13 +0200 Subject: [PATCH] Use single_instance_allowed for webhook config flows (#40965) --- homeassistant/components/dialogflow/strings.json | 2 +- homeassistant/components/geofency/strings.json | 2 +- homeassistant/components/gpslogger/strings.json | 2 +- homeassistant/components/ifttt/strings.json | 2 +- homeassistant/components/islamic_prayer_times/config_flow.py | 2 +- homeassistant/components/islamic_prayer_times/strings.json | 2 +- homeassistant/components/locative/strings.json | 2 +- homeassistant/components/mailgun/strings.json | 2 +- homeassistant/components/owntracks/config_flow.py | 4 ++-- homeassistant/components/owntracks/strings.json | 4 +++- homeassistant/components/ozw/config_flow.py | 2 +- homeassistant/components/ozw/strings.json | 2 +- homeassistant/components/plaato/strings.json | 2 +- homeassistant/components/speedtestdotnet/config_flow.py | 2 +- homeassistant/components/speedtestdotnet/strings.json | 2 +- homeassistant/components/traccar/strings.json | 2 +- homeassistant/components/twilio/strings.json | 2 +- homeassistant/helpers/config_entry_flow.py | 2 +- tests/components/islamic_prayer_times/test_config_flow.py | 2 +- tests/components/owntracks/test_config_flow.py | 4 ++-- tests/components/ozw/test_config_flow.py | 2 +- tests/components/speedtestdotnet/test_config_flow.py | 2 +- tests/helpers/test_config_entry_flow.py | 2 +- 23 files changed, 27 insertions(+), 25 deletions(-) diff --git a/homeassistant/components/dialogflow/strings.json b/homeassistant/components/dialogflow/strings.json index d1a691dc92bf..f17491a75285 100644 --- a/homeassistant/components/dialogflow/strings.json +++ b/homeassistant/components/dialogflow/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive Dialogflow messages." }, "create_entry": { diff --git a/homeassistant/components/geofency/strings.json b/homeassistant/components/geofency/strings.json index 1c6a72f27c83..a7b6649fb6e6 100644 --- a/homeassistant/components/geofency/strings.json +++ b/homeassistant/components/geofency/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive messages from Geofency." }, "create_entry": { diff --git a/homeassistant/components/gpslogger/strings.json b/homeassistant/components/gpslogger/strings.json index f3d4344cd49c..b757e5c46cb7 100644 --- a/homeassistant/components/gpslogger/strings.json +++ b/homeassistant/components/gpslogger/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive messages from GPSLogger." }, "create_entry": { diff --git a/homeassistant/components/ifttt/strings.json b/homeassistant/components/ifttt/strings.json index b637e0de13da..9002cf307563 100644 --- a/homeassistant/components/ifttt/strings.json +++ b/homeassistant/components/ifttt/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive IFTTT messages." }, "create_entry": { diff --git a/homeassistant/components/islamic_prayer_times/config_flow.py b/homeassistant/components/islamic_prayer_times/config_flow.py index d45997af76f6..065af0bd6110 100644 --- a/homeassistant/components/islamic_prayer_times/config_flow.py +++ b/homeassistant/components/islamic_prayer_times/config_flow.py @@ -23,7 +23,7 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" if self._async_current_entries(): - return self.async_abort(reason="one_instance_allowed") + return self.async_abort(reason="single_instance_allowed") if user_input is None: return self.async_show_form(step_id="user") diff --git a/homeassistant/components/islamic_prayer_times/strings.json b/homeassistant/components/islamic_prayer_times/strings.json index b57c338ecea9..73998913f41f 100644 --- a/homeassistant/components/islamic_prayer_times/strings.json +++ b/homeassistant/components/islamic_prayer_times/strings.json @@ -8,7 +8,7 @@ } }, "abort": { - "one_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" } }, "options": { diff --git a/homeassistant/components/locative/strings.json b/homeassistant/components/locative/strings.json index 53a0c160e99a..3a5821f40b11 100644 --- a/homeassistant/components/locative/strings.json +++ b/homeassistant/components/locative/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive messages from Geofency." }, "create_entry": { diff --git a/homeassistant/components/mailgun/strings.json b/homeassistant/components/mailgun/strings.json index 29ea3c0b952a..a948c6165e79 100644 --- a/homeassistant/components/mailgun/strings.json +++ b/homeassistant/components/mailgun/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive Mailgun messages." }, "create_entry": { diff --git a/homeassistant/components/owntracks/config_flow.py b/homeassistant/components/owntracks/config_flow.py index 0aba24217cc6..f0838b510ec8 100644 --- a/homeassistant/components/owntracks/config_flow.py +++ b/homeassistant/components/owntracks/config_flow.py @@ -19,7 +19,7 @@ class OwnTracksFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input=None): """Handle a user initiated set up flow to create OwnTracks webhook.""" if self._async_current_entries(): - return self.async_abort(reason="one_instance_allowed") + return self.async_abort(reason="single_instance_allowed") if user_input is None: return self.async_show_form(step_id="user") @@ -52,7 +52,7 @@ class OwnTracksFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_import(self, user_input): """Import a config flow from configuration.""" if self._async_current_entries(): - return self.async_abort(reason="one_instance_allowed") + return self.async_abort(reason="single_instance_allowed") webhook_id, _webhook_url, cloudhook = await self._get_webhook_id() secret = secrets.token_hex(16) return self.async_create_entry( diff --git a/homeassistant/components/owntracks/strings.json b/homeassistant/components/owntracks/strings.json index 12aba21be72c..ddb700cc6424 100644 --- a/homeassistant/components/owntracks/strings.json +++ b/homeassistant/components/owntracks/strings.json @@ -6,7 +6,9 @@ "description": "Are you sure you want to set up OwnTracks?" } }, - "abort": { "one_instance_allowed": "Only a single instance is necessary." }, + "abort": { + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]" + }, "create_entry": { "default": "\n\nOn Android, open [the OwnTracks app]({android_url}), go to preferences -> connection. Change the following settings:\n - Mode: Private HTTP\n - Host: {webhook_url}\n - Identification:\n - Username: `''`\n - Device ID: `''`\n\nOn iOS, open [the OwnTracks app]({ios_url}), tap (i) icon in top left -> settings. Change the following settings:\n - Mode: HTTP\n - URL: {webhook_url}\n - Turn on authentication\n - UserID: `''`\n\n{secret}\n\nSee [the documentation]({docs_url}) for more information." } diff --git a/homeassistant/components/ozw/config_flow.py b/homeassistant/components/ozw/config_flow.py index 8822490132c5..3153324322e0 100644 --- a/homeassistant/components/ozw/config_flow.py +++ b/homeassistant/components/ozw/config_flow.py @@ -15,7 +15,7 @@ class DomainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input=None): """Handle the initial step.""" if self._async_current_entries(): - return self.async_abort(reason="one_instance_allowed") + return self.async_abort(reason="single_instance_allowed") if "mqtt" not in self.hass.config.components: return self.async_abort(reason="mqtt_required") if user_input is not None: diff --git a/homeassistant/components/ozw/strings.json b/homeassistant/components/ozw/strings.json index dd2aad7e4ce0..88f8911db0d5 100644 --- a/homeassistant/components/ozw/strings.json +++ b/homeassistant/components/ozw/strings.json @@ -6,7 +6,7 @@ } }, "abort": { - "one_instance_allowed": "The integration only supports one Z-Wave instance", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "mqtt_required": "The MQTT integration is not set up" } } diff --git a/homeassistant/components/plaato/strings.json b/homeassistant/components/plaato/strings.json index f78943ca9418..e03d25080370 100644 --- a/homeassistant/components/plaato/strings.json +++ b/homeassistant/components/plaato/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive messages from Plaato Airlock." }, "create_entry": { diff --git a/homeassistant/components/speedtestdotnet/config_flow.py b/homeassistant/components/speedtestdotnet/config_flow.py index 57076c2a90ba..2bc462afdb0b 100644 --- a/homeassistant/components/speedtestdotnet/config_flow.py +++ b/homeassistant/components/speedtestdotnet/config_flow.py @@ -36,7 +36,7 @@ class SpeedTestFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" if self._async_current_entries(): - return self.async_abort(reason="one_instance_allowed") + return self.async_abort(reason="single_instance_allowed") if user_input is None: return self.async_show_form(step_id="user") diff --git a/homeassistant/components/speedtestdotnet/strings.json b/homeassistant/components/speedtestdotnet/strings.json index f638c25a5494..c4b92b16ff34 100644 --- a/homeassistant/components/speedtestdotnet/strings.json +++ b/homeassistant/components/speedtestdotnet/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "wrong_server_id": "Server id is not valid" } }, diff --git a/homeassistant/components/traccar/strings.json b/homeassistant/components/traccar/strings.json index 8574f4f34f11..aef269defcb3 100644 --- a/homeassistant/components/traccar/strings.json +++ b/homeassistant/components/traccar/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive messages from Traccar." }, "create_entry": { diff --git a/homeassistant/components/twilio/strings.json b/homeassistant/components/twilio/strings.json index 96e0249df9a8..0480fdae7c89 100644 --- a/homeassistant/components/twilio/strings.json +++ b/homeassistant/components/twilio/strings.json @@ -7,7 +7,7 @@ } }, "abort": { - "one_instance_allowed": "Only a single instance is necessary.", + "single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]", "not_internet_accessible": "Your Home Assistant instance needs to be accessible from the internet to receive Twilio messages." }, "create_entry": { diff --git a/homeassistant/helpers/config_entry_flow.py b/homeassistant/helpers/config_entry_flow.py index 2b967286b959..f957d884d8d4 100644 --- a/homeassistant/helpers/config_entry_flow.py +++ b/homeassistant/helpers/config_entry_flow.py @@ -136,7 +136,7 @@ class WebhookFlowHandler(config_entries.ConfigFlow): ) -> Dict[str, Any]: """Handle a user initiated set up flow to create a webhook.""" if not self._allow_multiple and self._async_current_entries(): - return self.async_abort(reason="one_instance_allowed") + return self.async_abort(reason="single_instance_allowed") if user_input is None: return self.async_show_form(step_id="user") diff --git a/tests/components/islamic_prayer_times/test_config_flow.py b/tests/components/islamic_prayer_times/test_config_flow.py index 4ffd6e4f25d4..3b966c9e8611 100644 --- a/tests/components/islamic_prayer_times/test_config_flow.py +++ b/tests/components/islamic_prayer_times/test_config_flow.py @@ -83,4 +83,4 @@ async def test_integration_already_configured(hass): ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "one_instance_allowed" + assert result["reason"] == "single_instance_allowed" diff --git a/tests/components/owntracks/test_config_flow.py b/tests/components/owntracks/test_config_flow.py index 396870c29754..2290e3e17a47 100644 --- a/tests/components/owntracks/test_config_flow.py +++ b/tests/components/owntracks/test_config_flow.py @@ -111,12 +111,12 @@ async def test_abort_if_already_setup(hass): # Should fail, already setup (import) result = await flow.async_step_import({}) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "one_instance_allowed" + assert result["reason"] == "single_instance_allowed" # Should fail, already setup (flow) result = await flow.async_step_user({}) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "one_instance_allowed" + assert result["reason"] == "single_instance_allowed" async def test_user_not_supports_encryption(hass, not_supports_encryption): diff --git a/tests/components/ozw/test_config_flow.py b/tests/components/ozw/test_config_flow.py index 3446bbfc7def..1af6787a9528 100644 --- a/tests/components/ozw/test_config_flow.py +++ b/tests/components/ozw/test_config_flow.py @@ -51,4 +51,4 @@ async def test_one_instance_allowed(hass): DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "abort" - assert result["reason"] == "one_instance_allowed" + assert result["reason"] == "single_instance_allowed" diff --git a/tests/components/speedtestdotnet/test_config_flow.py b/tests/components/speedtestdotnet/test_config_flow.py index 8e7edc2d9866..d421113a2d7d 100644 --- a/tests/components/speedtestdotnet/test_config_flow.py +++ b/tests/components/speedtestdotnet/test_config_flow.py @@ -135,4 +135,4 @@ async def test_integration_already_configured(hass): speedtestdotnet.DOMAIN, context={"source": "user"} ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "one_instance_allowed" + assert result["reason"] == "single_instance_allowed" diff --git a/tests/helpers/test_config_entry_flow.py b/tests/helpers/test_config_entry_flow.py index adbcca63990f..2bb993f11972 100644 --- a/tests/helpers/test_config_entry_flow.py +++ b/tests/helpers/test_config_entry_flow.py @@ -238,7 +238,7 @@ async def test_webhook_single_entry_allowed(hass, webhook_flow_conf): result = await flow.async_step_user() assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT - assert result["reason"] == "one_instance_allowed" + assert result["reason"] == "single_instance_allowed" async def test_webhook_multiple_entries_allowed(hass, webhook_flow_conf):