diff --git a/esphome/components/mdns/mdns_component.cpp b/esphome/components/mdns/mdns_component.cpp index 31858c0d3c..e1fcf320ed 100644 --- a/esphome/components/mdns/mdns_component.cpp +++ b/esphome/components/mdns/mdns_component.cpp @@ -45,6 +45,12 @@ void MDNSComponent::compile_records_() { service.txt_records.push_back({"board", ESPHOME_BOARD}); +#if defined(USE_WIFI) + service.txt_records.push_back({"network", "wifi"}); +#elif defined(USE_ETHERNET) + service.txt_records.push_back({"network", "ethernet"}); +#endif + #ifdef ESPHOME_PROJECT_NAME service.txt_records.push_back({"project_name", ESPHOME_PROJECT_NAME}); service.txt_records.push_back({"project_version", ESPHOME_PROJECT_VERSION}); diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index 9a8f072237..c812ec4b49 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -613,6 +613,7 @@ class ListDevicesHandler(BaseHandler): "package_import_url": res.package_import_url, "project_name": res.project_name, "project_version": res.project_version, + "network": res.network, } for res in IMPORT_RESULT.values() if res.device_name not in configured diff --git a/esphome/zeroconf.py b/esphome/zeroconf.py index 1fbdf7e93f..089ae4f1c2 100644 --- a/esphome/zeroconf.py +++ b/esphome/zeroconf.py @@ -118,6 +118,7 @@ ESPHOME_SERVICE_TYPE = "_esphomelib._tcp.local." TXT_RECORD_PACKAGE_IMPORT_URL = b"package_import_url" TXT_RECORD_PROJECT_NAME = b"project_name" TXT_RECORD_PROJECT_VERSION = b"project_version" +TXT_RECORD_NETWORK = b"network" @dataclass @@ -126,6 +127,7 @@ class DiscoveredImport: package_import_url: str project_name: str project_version: str + network: str class DashboardImportDiscovery: @@ -134,7 +136,7 @@ class DashboardImportDiscovery: self.service_browser = ServiceBrowser( self.zc, ESPHOME_SERVICE_TYPE, [self._on_update] ) - self.import_state = {} + self.import_state: dict[str, DiscoveredImport] = {} def _on_update( self, @@ -171,12 +173,14 @@ class DashboardImportDiscovery: import_url = info.properties[TXT_RECORD_PACKAGE_IMPORT_URL].decode() project_name = info.properties[TXT_RECORD_PROJECT_NAME].decode() project_version = info.properties[TXT_RECORD_PROJECT_VERSION].decode() + network = info.properties.get(TXT_RECORD_NETWORK, b"wifi").decode() self.import_state[name] = DiscoveredImport( device_name=node_name, package_import_url=import_url, project_name=project_name, project_version=project_version, + network=network, ) def cancel(self) -> None: