Catch Zeroconf exception (#28728)
* Catch Zeroconf exception * Make it an error
This commit is contained in:
parent
2c00a9ec68
commit
f1d4a3cd6e
1 changed files with 14 additions and 3 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue