Use ZeroconfServiceInfo in hue (#59980)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/60058/head
parent
66132e133f
commit
df3f3321f2
|
@ -232,7 +232,8 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
host is already configured and delegate to the import step if not.
|
||||
"""
|
||||
bridge = await self._get_bridge(
|
||||
discovery_info["host"], discovery_info["properties"]["bridgeid"]
|
||||
discovery_info[zeroconf.ATTR_HOST],
|
||||
discovery_info[zeroconf.ATTR_PROPERTIES]["bridgeid"],
|
||||
)
|
||||
|
||||
await self.async_set_unique_id(bridge.id)
|
||||
|
@ -252,7 +253,7 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
as the unique identifier. Therefore, this method uses discovery without
|
||||
a unique ID.
|
||||
"""
|
||||
self.bridge = await self._get_bridge(discovery_info[CONF_HOST])
|
||||
self.bridge = await self._get_bridge(discovery_info[zeroconf.ATTR_HOST])
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return await self.async_step_link()
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.components.hue import config_flow, const
|
||||
from homeassistant.components.hue.errors import CannotConnect
|
||||
|
||||
|
@ -515,12 +515,10 @@ async def test_bridge_homekit(hass, aioclient_mock):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={
|
||||
"host": "0.0.0.0",
|
||||
"serial": "1234",
|
||||
"manufacturerURL": config_flow.HUE_MANUFACTURERURL,
|
||||
"properties": {"id": "aa:bb:cc:dd:ee:ff"},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="0.0.0.0",
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
|
@ -560,7 +558,10 @@ async def test_bridge_homekit_already_configured(hass, aioclient_mock):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="0.0.0.0",
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
|
@ -659,18 +660,18 @@ async def test_bridge_zeroconf(hass, aioclient_mock):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "192.168.1.217",
|
||||
"port": 443,
|
||||
"hostname": "Philips-hue.local.",
|
||||
"type": "_hue._tcp.local.",
|
||||
"name": "Philips Hue - ABCABC._hue._tcp.local.",
|
||||
"properties": {
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.217",
|
||||
port=443,
|
||||
hostname="Philips-hue.local.",
|
||||
type="_hue._tcp.local.",
|
||||
name="Philips Hue - ABCABC._hue._tcp.local.",
|
||||
properties={
|
||||
"_raw": {"bridgeid": b"ecb5fafffeabcabc", "modelid": b"BSB002"},
|
||||
"bridgeid": "ecb5fafffeabcabc",
|
||||
"modelid": "BSB002",
|
||||
},
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
|
@ -690,18 +691,18 @@ async def test_bridge_zeroconf_already_exists(hass, aioclient_mock):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "192.168.1.217",
|
||||
"port": 443,
|
||||
"hostname": "Philips-hue.local.",
|
||||
"type": "_hue._tcp.local.",
|
||||
"name": "Philips Hue - ABCABC._hue._tcp.local.",
|
||||
"properties": {
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="192.168.1.217",
|
||||
port=443,
|
||||
hostname="Philips-hue.local.",
|
||||
type="_hue._tcp.local.",
|
||||
name="Philips Hue - ABCABC._hue._tcp.local.",
|
||||
properties={
|
||||
"_raw": {"bridgeid": b"ecb5faabcabc", "modelid": b"BSB002"},
|
||||
"bridgeid": "ecb5faabcabc",
|
||||
"modelid": "BSB002",
|
||||
},
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
|
|
Loading…
Reference in New Issue