Use of reference strings in Heos config flow (#41282)
parent
ac795ddcd0
commit
7eaa304fc3
|
@ -32,7 +32,7 @@ class HeosFlowHandler(config_entries.ConfigFlow):
|
|||
self.hass.data[DATA_DISCOVERED_HOSTS][friendly_name] = hostname
|
||||
# Abort if other flows in progress or an entry already exists
|
||||
if self._async_in_progress() or self._async_current_entries():
|
||||
return self.async_abort(reason="already_setup")
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
await self.async_set_unique_id(DOMAIN)
|
||||
# Show selection form
|
||||
return self.async_show_form(step_id="user")
|
||||
|
@ -50,7 +50,7 @@ class HeosFlowHandler(config_entries.ConfigFlow):
|
|||
self.hass.data.setdefault(DATA_DISCOVERED_HOSTS, {})
|
||||
# Only a single entry is needed for all devices
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="already_setup")
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
# Try connecting to host if provided
|
||||
errors = {}
|
||||
host = None
|
||||
|
@ -64,7 +64,7 @@ class HeosFlowHandler(config_entries.ConfigFlow):
|
|||
self.hass.data.pop(DATA_DISCOVERED_HOSTS)
|
||||
return await self.async_step_import({CONF_HOST: host})
|
||||
except HeosError:
|
||||
errors[CONF_HOST] = "connection_failure"
|
||||
errors[CONF_HOST] = "cannot_connect"
|
||||
finally:
|
||||
await heos.disconnect()
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
}
|
||||
},
|
||||
"error": {
|
||||
"connection_failure": "Unable to connect to the specified host."
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||
},
|
||||
"abort": {
|
||||
"already_setup": "You can only configure a single Heos connection as it will support all devices on the network."
|
||||
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ async def test_flow_aborts_already_setup(hass, config_entry):
|
|||
flow.hass = 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_no_host_shows_form(hass):
|
||||
|
@ -41,7 +41,7 @@ async def test_cannot_connect_shows_error_form(hass, controller):
|
|||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"][CONF_HOST] == "connection_failure"
|
||||
assert result["errors"][CONF_HOST] == "cannot_connect"
|
||||
assert controller.connect.call_count == 1
|
||||
assert controller.disconnect.call_count == 1
|
||||
controller.connect.reset_mock()
|
||||
|
@ -118,7 +118,7 @@ async def test_discovery_flow_aborts_already_setup(
|
|||
flow.hass = hass
|
||||
result = await flow.async_step_ssdp(discovery_data)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
async def test_discovery_sets_the_unique_id(hass, controller, discovery_data):
|
||||
|
|
Loading…
Reference in New Issue