mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use of reference strings in Almond config flow (#41284)
This commit is contained in:
parent
888c92aa5e
commit
e1578e5389
@ -51,7 +51,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||||||
"""Handle a flow start."""
|
"""Handle a flow start."""
|
||||||
# Only allow 1 instance.
|
# Only allow 1 instance.
|
||||||
if self._async_current_entries():
|
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)
|
return await super().async_step_user(user_input)
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||||||
"""Import data."""
|
"""Import data."""
|
||||||
# Only allow 1 instance.
|
# Only allow 1 instance.
|
||||||
if self._async_current_entries():
|
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"]):
|
if not await async_verify_local_connection(self.hass, user_input["host"]):
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
@ -97,7 +97,7 @@ class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||||||
async def async_step_hassio(self, discovery_info):
|
async def async_step_hassio(self, discovery_info):
|
||||||
"""Receive a Hass.io discovery."""
|
"""Receive a Hass.io discovery."""
|
||||||
if self._async_current_entries():
|
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
|
self.hassio_discovery = discovery_info
|
||||||
|
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"step": {
|
"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": {
|
"hassio_confirm": {
|
||||||
"title": "Almond via Hass.io add-on",
|
"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}?"
|
"description": "Do you want to configure Home Assistant to connect to Almond provided by the Hass.io add-on: {addon}?"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_setup": "You can only configure one Almond account.",
|
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]",
|
||||||
"cannot_connect": "Unable to connect to the Almond server.",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"missing_configuration": "Please check the documentation on how to set up Almond.",
|
"missing_configuration": "Please check the documentation on how to set up Almond.",
|
||||||
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]"
|
"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()
|
result = await flow.async_step_user()
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
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()
|
result = await flow.async_step_import()
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
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({})
|
result = await flow.async_step_hassio({})
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
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):
|
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user