Use of reference strings in Almond config flow (#41284)
This commit is contained in:
parent
888c92aa5e
commit
e1578e5389
3 changed files with 11 additions and 9 deletions
|
@ -51,7 +51,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||
"""Handle a flow start."""
|
||||
# Only allow 1 instance.
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_setup")
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
return await super().async_step_user(user_input)
|
||||
|
||||
|
@ -79,7 +79,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||
"""Import data."""
|
||||
# Only allow 1 instance.
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_setup")
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
if not await async_verify_local_connection(self.hass, user_input["host"]):
|
||||
self.logger.warning(
|
||||
|
@ -97,7 +97,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||
async def async_step_hassio(self, discovery_info):
|
||||
"""Receive a Hass.io discovery."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_setup")
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
self.hassio_discovery = discovery_info
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
{
|
||||
"config": {
|
||||
"step": {
|
||||
"pick_implementation": { "title": "[%key:common::config_flow::title::oauth2_pick_implementation%]" },
|
||||
"pick_implementation": {
|
||||
"title": "[%key:common::config_flow::title::oauth2_pick_implementation%]"
|
||||
},
|
||||
"hassio_confirm": {
|
||||
"title": "Almond via Hass.io add-on",
|
||||
"description": "Do you want to configure Home Assistant to connect to Almond provided by the Hass.io add-on: {addon}?"
|
||||
}
|
||||
},
|
||||
"abort": {
|
||||
"already_setup": "You can only configure one Almond account.",
|
||||
"cannot_connect": "Unable to connect to the Almond server.",
|
||||
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"missing_configuration": "Please check the documentation on how to set up Almond.",
|
||||
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]"
|
||||
}
|
||||
|
|
|
@ -80,15 +80,15 @@ async def test_abort_if_existing_entry(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"
|
||||
|
||||
result = await flow.async_step_import()
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
result = await flow.async_step_hassio({})
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request):
|
||||
|
|
Loading…
Add table
Reference in a new issue