Use local dashboard object in MDNSStatus

This commit is contained in:
Tucker Kern 2024-11-08 23:11:38 +00:00
parent d027dde769
commit 3088a62c63
2 changed files with 5 additions and 4 deletions

View file

@ -136,7 +136,7 @@ class ESPHomeDashboard:
else: else:
from .status.mdns import MDNSStatus from .status.mdns import MDNSStatus
mdns_status = MDNSStatus(settings.zeroconf_default_interface) mdns_status = MDNSStatus()
await mdns_status.async_refresh_hosts() await mdns_status.async_refresh_hosts()
self.mdns_status = mdns_status self.mdns_status = mdns_status
mdns_task = asyncio.create_task(mdns_status.async_run()) mdns_task = asyncio.create_task(mdns_status.async_run())

View file

@ -18,11 +18,10 @@ from ..entries import DashboardEntry, bool_to_entry_state
class MDNSStatus: class MDNSStatus:
"""Class that updates the mdns status.""" """Class that updates the mdns status."""
def __init__(self, default_interface=False) -> None: def __init__(self) -> None:
"""Initialize the MDNSStatus class.""" """Initialize the MDNSStatus class."""
super().__init__() super().__init__()
self.aiozc: AsyncEsphomeZeroconf | None = None self.aiozc: AsyncEsphomeZeroconf | None = None
self._zc_default_interface: bool = default_interface
# This is the current mdns state for each host (True, False, None) # This is the current mdns state for each host (True, False, None)
self.host_mdns_state: dict[str, bool | None] = {} self.host_mdns_state: dict[str, bool | None] = {}
self._loop = asyncio.get_running_loop() self._loop = asyncio.get_running_loop()
@ -65,7 +64,9 @@ class MDNSStatus:
async def async_run(self) -> None: async def async_run(self) -> None:
dashboard = DASHBOARD dashboard = DASHBOARD
entries = dashboard.entries entries = dashboard.entries
aiozc = AsyncEsphomeZeroconf(default_interface=self._zc_default_interface) aiozc = AsyncEsphomeZeroconf(
default_interface=dashboard.settings.zeroconf_default_interface
)
self.aiozc = aiozc self.aiozc = aiozc
host_mdns_state = self.host_mdns_state host_mdns_state = self.host_mdns_state