Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions homeassistant/components/hue/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ async def async_step_zeroconf(
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)
Expand All @@ -252,7 +253,7 @@ async def async_step_homekit(
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()

Expand Down
49 changes: 25 additions & 24 deletions tests/components/hue/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down