Fix Espalexa being detected as Hue Bridge (#29237)
This commit is contained in:
parent
c0619944fa
commit
d5efd0b352
2 changed files with 27 additions and 4 deletions
|
@ -16,6 +16,7 @@ from .const import DOMAIN, LOGGER
|
||||||
from .errors import AuthenticationRequired, CannotConnect
|
from .errors import AuthenticationRequired, CannotConnect
|
||||||
|
|
||||||
HUE_MANUFACTURERURL = "http://www.philips.com"
|
HUE_MANUFACTURERURL = "http://www.philips.com"
|
||||||
|
HUE_IGNORED_BRIDGE_NAMES = ["HASS Bridge", "Espalexa"]
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -133,14 +134,16 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
This flow is triggered by the SSDP component. It will check if the
|
This flow is triggered by the SSDP component. It will check if the
|
||||||
host is already configured and delegate to the import step if not.
|
host is already configured and delegate to the import step if not.
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.ssdp import ATTR_MANUFACTURERURL
|
from homeassistant.components.ssdp import ATTR_MANUFACTURERURL, ATTR_NAME
|
||||||
|
|
||||||
if discovery_info[ATTR_MANUFACTURERURL] != HUE_MANUFACTURERURL:
|
if discovery_info[ATTR_MANUFACTURERURL] != HUE_MANUFACTURERURL:
|
||||||
return self.async_abort(reason="not_hue_bridge")
|
return self.async_abort(reason="not_hue_bridge")
|
||||||
|
|
||||||
# Filter out emulated Hue
|
if any(
|
||||||
if "HASS Bridge" in discovery_info.get("name", ""):
|
name in discovery_info.get(ATTR_NAME, "")
|
||||||
return self.async_abort(reason="already_configured")
|
for name in HUE_IGNORED_BRIDGE_NAMES
|
||||||
|
):
|
||||||
|
return self.async_abort(reason="not_hue_bridge")
|
||||||
|
|
||||||
host = self.context["host"] = discovery_info.get("host")
|
host = self.context["host"] = discovery_info.get("host")
|
||||||
|
|
||||||
|
|
|
@ -230,6 +230,26 @@ async def test_bridge_ssdp_emulated_hue(hass):
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
assert result["reason"] == "not_hue_bridge"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_bridge_ssdp_espalexa(hass):
|
||||||
|
"""Test if discovery info is from an Espalexa based device."""
|
||||||
|
flow = config_flow.HueFlowHandler()
|
||||||
|
flow.hass = hass
|
||||||
|
flow.context = {}
|
||||||
|
|
||||||
|
result = await flow.async_step_ssdp(
|
||||||
|
{
|
||||||
|
"name": "Espalexa (0.0.0.0)",
|
||||||
|
"host": "0.0.0.0",
|
||||||
|
"serial": "1234",
|
||||||
|
"manufacturerURL": config_flow.HUE_MANUFACTURERURL,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result["type"] == "abort"
|
||||||
|
assert result["reason"] == "not_hue_bridge"
|
||||||
|
|
||||||
|
|
||||||
async def test_bridge_ssdp_already_configured(hass):
|
async def test_bridge_ssdp_already_configured(hass):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue