Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Zeroconf exception #28728

Merged
merged 2 commits into from
Nov 23, 2019
Merged
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
17 changes: 14 additions & 3 deletions homeassistant/components/zeroconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import ipaddress
import voluptuous as vol

from zeroconf import ServiceBrowser, ServiceInfo, ServiceStateChange, Zeroconf
from zeroconf import (
ServiceBrowser,
ServiceInfo,
ServiceStateChange,
Zeroconf,
NonUniqueNameException,
)

from homeassistant import util
from homeassistant.const import (
Expand Down Expand Up @@ -43,7 +49,7 @@ def setup(hass, config):
params = {
"version": __version__,
"base_url": hass.config.api.base_url,
# always needs authentication
# Always needs authentication
"requires_api_password": True,
}

Expand All @@ -69,7 +75,12 @@ def zeroconf_hass_start(_event):
Wait till started or otherwise HTTP is not up and running.
"""
_LOGGER.info("Starting Zeroconf broadcast")
zeroconf.register_service(info)
try:
zeroconf.register_service(info)
except NonUniqueNameException:
_LOGGER.error(
"Home Assistant instance with identical name present in the local network"
)

hass.bus.listen_once(EVENT_HOMEASSISTANT_START, zeroconf_hass_start)

Expand Down