Make deCONZ SSDP discovery more strict by matching on manufacturerURL (#71124)

This commit is contained in:
Robert Svensson 2022-04-30 19:33:47 +02:00 committed by GitHub
parent e3f224e115
commit a0fe5b0247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 4 additions and 25 deletions

View File

@ -215,12 +215,6 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
"""Handle a discovered deCONZ bridge."""
if (
discovery_info.upnp.get(ssdp.ATTR_UPNP_MANUFACTURER_URL)
!= DECONZ_MANUFACTURERURL
):
return self.async_abort(reason="not_deconz_bridge")
LOGGER.debug("deCONZ SSDP discovery %s", pformat(discovery_info))
self.bridge_id = normalize_bridge_id(discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL])

View File

@ -6,7 +6,8 @@
"requirements": ["pydeconz==91"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics"
"manufacturer": "Royal Philips Electronics",
"manufacturerURL": "http://www.dresden-elektronik.de"
}
],
"codeowners": ["@Kane610"],

View File

@ -31,7 +31,6 @@
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
"no_bridges": "No deCONZ bridges discovered",
"no_hardware_available": "No radio hardware connected to deCONZ",
"not_deconz_bridge": "Not a deCONZ bridge",
"updated_instance": "Updated deCONZ instance with new host address"
}
},

View File

@ -24,7 +24,8 @@ SSDP = {
],
"deconz": [
{
"manufacturer": "Royal Philips Electronics"
"manufacturer": "Royal Philips Electronics",
"manufacturerURL": "http://www.dresden-elektronik.de"
}
],
"denonavr": [

View File

@ -459,22 +459,6 @@ async def test_flow_ssdp_discovery(hass, aioclient_mock):
}
async def test_flow_ssdp_bad_discovery(hass, aioclient_mock):
"""Test that SSDP discovery aborts if manufacturer URL is wrong."""
result = await hass.config_entries.flow.async_init(
DECONZ_DOMAIN,
data=ssdp.SsdpServiceInfo(
ssdp_usn="mock_usn",
ssdp_st="mock_st",
upnp={ATTR_UPNP_MANUFACTURER_URL: "other"},
),
context={"source": SOURCE_SSDP},
)
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "not_deconz_bridge"
async def test_ssdp_discovery_update_configuration(hass, aioclient_mock):
"""Test if a discovered bridge is configured but updates with new attributes."""
config_entry = await setup_deconz_integration(hass, aioclient_mock)