Catch Zeroconf exception (#28728)

* Catch Zeroconf exception

* Make it an error
This commit is contained in:
Fabian Affolter 2019-11-23 16:46:06 +01:00 committed by GitHub
parent 2c00a9ec68
commit f1d4a3cd6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,13 @@ import socket
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 (
@ -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,
}
@ -69,7 +75,12 @@ def setup(hass, config):
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)