mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-05 12:30:28 +02:00
dashboard: Centralize dashboard entries into DashboardEntries class (#5774)
* Centralize dashboard entries into DashboardEntries class * preen * preen * preen * preen * preen
This commit is contained in:
@@ -10,7 +10,7 @@ from esphome.zeroconf import (
|
||||
DashboardStatus,
|
||||
)
|
||||
|
||||
from ..core import DASHBOARD, list_dashboard_entries
|
||||
from ..core import DASHBOARD
|
||||
|
||||
|
||||
class MDNSStatus:
|
||||
@@ -41,12 +41,13 @@ class MDNSStatus:
|
||||
|
||||
async def async_refresh_hosts(self):
|
||||
"""Refresh the hosts to track."""
|
||||
entries = await self._loop.run_in_executor(None, list_dashboard_entries)
|
||||
dashboard = DASHBOARD
|
||||
entries = dashboard.entries.async_all()
|
||||
host_name_with_mdns_enabled = self.host_name_with_mdns_enabled
|
||||
host_mdns_state = self.host_mdns_state
|
||||
host_name_to_filename = self.host_name_to_filename
|
||||
filename_to_host_name = self.filename_to_host_name
|
||||
ping_result = DASHBOARD.ping_result
|
||||
ping_result = dashboard.ping_result
|
||||
|
||||
for entry in entries:
|
||||
name = entry.name
|
||||
|
||||
@@ -7,7 +7,7 @@ import threading
|
||||
|
||||
from esphome import mqtt
|
||||
|
||||
from ..core import DASHBOARD, list_dashboard_entries
|
||||
from ..core import DASHBOARD
|
||||
|
||||
|
||||
class MqttStatusThread(threading.Thread):
|
||||
@@ -16,7 +16,7 @@ class MqttStatusThread(threading.Thread):
|
||||
def run(self) -> None:
|
||||
"""Run the status thread."""
|
||||
dashboard = DASHBOARD
|
||||
entries = list_dashboard_entries()
|
||||
entries = dashboard.entries.all()
|
||||
|
||||
config = mqtt.config_from_env()
|
||||
topic = "esphome/discover/#"
|
||||
@@ -51,8 +51,7 @@ class MqttStatusThread(threading.Thread):
|
||||
client.loop_start()
|
||||
|
||||
while not dashboard.stop_event.wait(2):
|
||||
# update entries
|
||||
entries = list_dashboard_entries()
|
||||
entries = dashboard.entries.all()
|
||||
|
||||
# will be set to true on on_message
|
||||
for entry in entries:
|
||||
|
||||
@@ -6,7 +6,6 @@ from typing import cast
|
||||
|
||||
from ..core import DASHBOARD
|
||||
from ..entries import DashboardEntry
|
||||
from ..core import list_dashboard_entries
|
||||
from ..util.itertools import chunked
|
||||
from ..util.subprocess import async_system_command_status
|
||||
|
||||
@@ -32,7 +31,7 @@ class PingStatus:
|
||||
# Only ping if the dashboard is open
|
||||
await dashboard.ping_request.wait()
|
||||
dashboard.ping_result.clear()
|
||||
entries = await self._loop.run_in_executor(None, list_dashboard_entries)
|
||||
entries = dashboard.entries.async_all()
|
||||
to_ping: list[DashboardEntry] = [
|
||||
entry for entry in entries if entry.address is not None
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user