diff --git a/homeassistant/components/zeroconf/__init__.py b/homeassistant/components/zeroconf/__init__.py index a14efb70411..e745cb53f6b 100644 --- a/homeassistant/components/zeroconf/__init__.py +++ b/homeassistant/components/zeroconf/__init__.py @@ -1,10 +1,8 @@ """Support for exposing Home Assistant via Zeroconf.""" import logging -import socket import voluptuous as vol -from homeassistant import util from homeassistant.const import (EVENT_HOMEASSISTANT_STOP, __version__) _LOGGER = logging.getLogger(__name__) @@ -23,8 +21,6 @@ async def async_setup(hass, config): """Set up Zeroconf and make Home Assistant discoverable.""" from aiozeroconf import Zeroconf, ServiceInfo - zeroconf = Zeroconf(hass.loop) - zeroconf_name = '{}.{}'.format(hass.config.location_name, ZEROCONF_TYPE) params = { @@ -34,18 +30,10 @@ async def async_setup(hass, config): 'requires_api_password': True, } - host_ip = util.get_local_ip() + info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name, + port=hass.http.server_port, properties=params) - try: - host_ip_pton = socket.inet_pton(socket.AF_INET, host_ip) - info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name, address=host_ip_pton, - port=hass.http.server_port, weight=0, priority=0, - properties=params) - except socket.error: - host_ip_pton = socket.inet_pton(socket.AF_INET6, host_ip) - info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name, address6=host_ip_pton, - port=hass.http.server_port, weight=0, priority=0, - properties=params) + zeroconf = Zeroconf(hass.loop) await zeroconf.register_service(info)