Fix zwave_js manual reconfiguration of add-on managed entry (#47364)
This commit is contained in:
parent
cea4808db8
commit
d64fe6ea32
2 changed files with 23 additions and 3 deletions
|
@ -117,7 +117,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
await self.async_set_unique_id(
|
||||
version_info.home_id, raise_on_progress=False
|
||||
)
|
||||
self._abort_if_unique_id_configured(user_input)
|
||||
# Make sure we disable any add-on handling
|
||||
# if the controller is reconfigured in a manual step.
|
||||
self._abort_if_unique_id_configured(
|
||||
updates={
|
||||
**user_input,
|
||||
CONF_USE_ADDON: False,
|
||||
CONF_INTEGRATION_CREATED_ADDON: False,
|
||||
}
|
||||
)
|
||||
self.ws_address = user_input[CONF_URL]
|
||||
return self._async_create_entry_from_vars()
|
||||
|
||||
|
|
|
@ -184,7 +184,16 @@ async def test_manual_errors(
|
|||
|
||||
async def test_manual_already_configured(hass):
|
||||
"""Test that only one unique instance is allowed."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data={}, title=TITLE, unique_id=1234)
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
"url": "ws://localhost:3000",
|
||||
"use_addon": True,
|
||||
"integration_created_addon": True,
|
||||
},
|
||||
title=TITLE,
|
||||
unique_id=1234,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
@ -198,12 +207,15 @@ async def test_manual_already_configured(hass):
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
"url": "ws://localhost:3000",
|
||||
"url": "ws://1.1.1.1:3001",
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data["url"] == "ws://1.1.1.1:3001"
|
||||
assert entry.data["use_addon"] is False
|
||||
assert entry.data["integration_created_addon"] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize("discovery_info", [{"config": ADDON_DISCOVERY_INFO}])
|
||||
|
|
Loading…
Add table
Reference in a new issue