Skip to content
Merged
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions homeassistant/components/bosch_shc/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ async def async_step_zeroconf(

try:
hosts = (
discovery_info[zeroconf.ATTR_HOST]
if isinstance(discovery_info[zeroconf.ATTR_HOST], list)
else [discovery_info[zeroconf.ATTR_HOST]]
discovery_info.host
if isinstance(discovery_info.host, list)
else [discovery_info.host]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdraco can the host in zeroconf be a list?
Is it a mistake in my zeroconf type hint or is this a mistake in this integration?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AsyncServiceInfo returns a list, and we pick the address they hopefully want here:
https://github.com/home-assistant/core/blob/dev/homeassistant/components/zeroconf/__init__.py#L528

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the confirmation.
I have dropped multi-host handling from async_step_zeroconf and from the corresponding tests

)
for host in hosts:
if host.startswith("169."): # skip link local address
Expand All @@ -205,7 +205,7 @@ async def async_step_zeroconf(
except SHCConnectionError:
return self.async_abort(reason="cannot_connect")

local_name = discovery_info[zeroconf.ATTR_HOSTNAME][:-1]
local_name = discovery_info.hostname[:-1]
node_name = local_name[: -len(".local")]

await self.async_set_unique_id(self.info["unique_id"])
Expand Down