Use zeroconf resolver for .local domains first

This commit is contained in:
Otto Winter 2019-06-03 14:54:23 +02:00
parent 2f499c71d1
commit 0e813dfd44
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
1 changed files with 6 additions and 6 deletions

View File

@ -50,11 +50,11 @@ async def resolve_ip_address_getaddrinfo(eventloop: asyncio.events.AbstractEvent
async def resolve_ip_address(eventloop: asyncio.events.AbstractEventLoop,
host: str, port: int) -> Tuple[Any, ...]:
try:
return await resolve_ip_address_getaddrinfo(eventloop, host, port)
except APIConnectionError as err:
if host.endswith('.local'):
from aioesphomeapi.host_resolver import resolve_host
if host.endswith('.local'):
from aioesphomeapi.host_resolver import resolve_host
try:
return await eventloop.run_in_executor(None, resolve_host, host), port
raise err
except APIConnectionError:
pass
return await resolve_ip_address_getaddrinfo(eventloop, host, port)