mirror of
https://github.com/esphome/esphome.git
synced 2025-09-22 13:12:22 +01:00
fixes
This commit is contained in:
@@ -1167,6 +1167,12 @@ def run_esphome(argv):
|
|||||||
|
|
||||||
# Store cache in CORE for access throughout the application
|
# Store cache in CORE for access throughout the application
|
||||||
CORE.address_cache = address_cache
|
CORE.address_cache = address_cache
|
||||||
|
if address_cache.has_cache():
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Address cache initialized with %d mDNS and %d DNS entries",
|
||||||
|
len(address_cache.mdns_cache),
|
||||||
|
len(address_cache.dns_cache),
|
||||||
|
)
|
||||||
|
|
||||||
# Override log level if verbose is set
|
# Override log level if verbose is set
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
|
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from zeroconf import AddressResolver, IPVersion
|
from zeroconf import AddressResolver, IPVersion
|
||||||
@@ -60,6 +59,7 @@ class MDNSStatus:
|
|||||||
Returns None if not in cache or no zeroconf available.
|
Returns None if not in cache or no zeroconf available.
|
||||||
"""
|
"""
|
||||||
if not self.aiozc:
|
if not self.aiozc:
|
||||||
|
_LOGGER.debug("No zeroconf instance available for %s", host_name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Normalize hostname and get the base name
|
# Normalize hostname and get the base name
|
||||||
@@ -67,11 +67,14 @@ class MDNSStatus:
|
|||||||
base_name = normalized.partition(".")[0]
|
base_name = normalized.partition(".")[0]
|
||||||
|
|
||||||
# Try to load from zeroconf cache without triggering resolution
|
# Try to load from zeroconf cache without triggering resolution
|
||||||
info = AddressResolver(f"{base_name}.local.")
|
resolver_name = f"{base_name}.local."
|
||||||
# Pass current time in milliseconds for cache expiry checking
|
info = AddressResolver(resolver_name)
|
||||||
now = time.time() * 1000
|
# Let zeroconf use its own current time for cache checking
|
||||||
if info.load_from_cache(self.aiozc.zeroconf, now):
|
if info.load_from_cache(self.aiozc.zeroconf):
|
||||||
return info.parsed_scoped_addresses(IPVersion.All)
|
addresses = info.parsed_scoped_addresses(IPVersion.All)
|
||||||
|
_LOGGER.debug("Found %s in zeroconf cache: %s", resolver_name, addresses)
|
||||||
|
return addresses
|
||||||
|
_LOGGER.debug("Not found in zeroconf cache: %s", resolver_name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def async_refresh_hosts(self) -> None:
|
async def async_refresh_hosts(self) -> None:
|
||||||
|
Reference in New Issue
Block a user