mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Abort deCONZ config flow if no radio hardware is connected (#40811)
This commit is contained in:
parent
df1e910ac7
commit
2922d4675f
@ -172,6 +172,9 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
return self.async_abort(reason="no_bridges")
|
return self.async_abort(reason="no_bridges")
|
||||||
|
|
||||||
|
if self.bridge_id == "0000000000000000":
|
||||||
|
return self.async_abort(reason="no_hardware_available")
|
||||||
|
|
||||||
return self.async_create_entry(title=self.bridge_id, data=self.deconz_config)
|
return self.async_create_entry(title=self.bridge_id, data=self.deconz_config)
|
||||||
|
|
||||||
async def async_step_ssdp(self, discovery_info):
|
async def async_step_ssdp(self, discovery_info):
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
"already_configured": "Bridge is already configured",
|
"already_configured": "Bridge is already configured",
|
||||||
"already_in_progress": "Config flow for bridge is already in progress.",
|
"already_in_progress": "Config flow for bridge is already in progress.",
|
||||||
"no_bridges": "No deCONZ bridges discovered",
|
"no_bridges": "No deCONZ bridges discovered",
|
||||||
|
"no_hardware_available": "No radio hardware connected to deCONZ",
|
||||||
"not_deconz_bridge": "Not a deCONZ bridge",
|
"not_deconz_bridge": "Not a deCONZ bridge",
|
||||||
"one_instance_only": "Component only supports one deCONZ instance",
|
"one_instance_only": "Component only supports one deCONZ instance",
|
||||||
"updated_instance": "Updated deCONZ instance with new host address"
|
"updated_instance": "Updated deCONZ instance with new host address"
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"already_configured": "Bridge is already configured",
|
"already_configured": "Bridge is already configured",
|
||||||
"already_in_progress": "Config flow for bridge is already in progress.",
|
"already_in_progress": "Config flow for bridge is already in progress.",
|
||||||
"no_bridges": "No deCONZ bridges discovered",
|
"no_bridges": "No deCONZ bridges discovered",
|
||||||
|
"no_hardware_available": "No radio hardware connected to deCONZ",
|
||||||
"not_deconz_bridge": "Not a deCONZ bridge",
|
"not_deconz_bridge": "Not a deCONZ bridge",
|
||||||
"one_instance_only": "Component only supports one deCONZ instance",
|
"one_instance_only": "Component only supports one deCONZ instance",
|
||||||
"updated_instance": "Updated deCONZ instance with new host address"
|
"updated_instance": "Updated deCONZ instance with new host address"
|
||||||
|
@ -24,6 +24,8 @@ from .test_gateway import API_KEY, BRIDGEID, setup_deconz_integration
|
|||||||
|
|
||||||
from tests.async_mock import patch
|
from tests.async_mock import patch
|
||||||
|
|
||||||
|
BAD_BRIDGEID = "0000000000000000"
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_discovered_bridges(hass, aioclient_mock):
|
async def test_flow_discovered_bridges(hass, aioclient_mock):
|
||||||
"""Test that config flow works for discovered bridges."""
|
"""Test that config flow works for discovered bridges."""
|
||||||
@ -391,6 +393,35 @@ async def test_flow_ssdp_discovery(hass, aioclient_mock):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_flow_ssdp_discovery_bad_bridge_id_aborts(hass, aioclient_mock):
|
||||||
|
"""Test that config flow aborts if deCONZ signals no radio hardware available."""
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN,
|
||||||
|
data={
|
||||||
|
ssdp.ATTR_SSDP_LOCATION: "http://1.2.3.4:80/",
|
||||||
|
ssdp.ATTR_UPNP_MANUFACTURER_URL: DECONZ_MANUFACTURERURL,
|
||||||
|
ssdp.ATTR_UPNP_SERIAL: BAD_BRIDGEID,
|
||||||
|
},
|
||||||
|
context={"source": "ssdp"},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
assert result["step_id"] == "link"
|
||||||
|
|
||||||
|
aioclient_mock.post(
|
||||||
|
"http://1.2.3.4:80/api",
|
||||||
|
json=[{"success": {"username": API_KEY}}],
|
||||||
|
headers={"content-type": CONTENT_TYPE_JSON},
|
||||||
|
)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"], user_input={}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
assert result["reason"] == "no_hardware_available"
|
||||||
|
|
||||||
|
|
||||||
async def test_ssdp_discovery_not_deconz_bridge(hass):
|
async def test_ssdp_discovery_not_deconz_bridge(hass):
|
||||||
"""Test a non deconz bridge being discovered over ssdp."""
|
"""Test a non deconz bridge being discovered over ssdp."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user