Use single_instance_allowed for webhook config flows (#40965)
This commit is contained in:
parent
17c6838b7f
commit
c7ebfdb403
23 changed files with 27 additions and 25 deletions
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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: `'<Your name>'`\n - Device ID: `'<Your device name>'`\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: `'<Your name>'`\n\n{secret}\n\nSee [the documentation]({docs_url}) for more information."
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue