Handle IPv6 in zeroconf (#4052)
This commit is contained in:
parent
2e6a48ff5f
commit
443553ff16
1 changed files with 10 additions and 3 deletions
|
@ -40,9 +40,16 @@ def setup(hass, config):
|
|||
'requires_api_password': requires_api_password,
|
||||
}
|
||||
|
||||
info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name,
|
||||
socket.inet_aton(hass.config.api.host),
|
||||
hass.config.api.port, 0, 0, params)
|
||||
try:
|
||||
info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name,
|
||||
socket.inet_pton(
|
||||
socket.AF_INET, hass.config.api.host),
|
||||
hass.config.api.port, 0, 0, params)
|
||||
except socket.error:
|
||||
info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name,
|
||||
socket.inet_pton(
|
||||
socket.AF_INET6, hass.config.api.host),
|
||||
hass.config.api.port, 0, 0, params)
|
||||
|
||||
zeroconf.register_service(info)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue