From 65c50e4f0180789454f9261090f6723657c06d53 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 9 Jun 2021 14:23:48 +1200 Subject: [PATCH] Add platform and board to mdns response when API is used (#1871) --- esphome/core/config.py | 1 + esphome/core/defines.h | 2 ++ esphome/core/util.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/esphome/core/config.py b/esphome/core/config.py index cdd98afc66..fd4b7088cc 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -349,6 +349,7 @@ async def to_code(config): if config[CONF_INCLUDES]: CORE.add_job(add_includes, config[CONF_INCLUDES]) + cg.add_define("ESPHOME_BOARD", CORE.board) if CONF_PROJECT in config: cg.add_define("ESPHOME_PROJECT_NAME", config[CONF_PROJECT][CONF_NAME]) cg.add_define("ESPHOME_PROJECT_VERSION", config[CONF_PROJECT][CONF_VERSION]) diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 597cd5e31f..24efd0fd14 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -24,3 +24,5 @@ #define USE_TIME #define USE_DEEP_SLEEP #define USE_CAPTIVE_PORTAL +#define ESPHOME_BOARD "dummy_board" +#define USE_MDNS diff --git a/esphome/core/util.cpp b/esphome/core/util.cpp index 4d27c04d2c..19b8ab89e9 100644 --- a/esphome/core/util.cpp +++ b/esphome/core/util.cpp @@ -94,7 +94,13 @@ void network_setup_mdns(IPAddress address, int interface) { MDNS.addServiceTxt("esphomelib", "tcp", "version", ESPHOME_VERSION); MDNS.addServiceTxt("esphomelib", "tcp", "address", network_get_address().c_str()); MDNS.addServiceTxt("esphomelib", "tcp", "mac", get_mac_address().c_str()); - +#ifdef ARDUINO_ARCH_ESP8266 + MDNS.addServiceTxt("esphomelib", "tcp", "platform", "ESP8266"); +#endif +#ifdef ARDUINO_ARCH_ESP32 + MDNS.addServiceTxt("esphomelib", "tcp", "platform", "ESP32"); +#endif + MDNS.addServiceTxt("esphomelib", "tcp", "board", ESPHOME_BOARD); #ifdef ESPHOME_PROJECT_NAME MDNS.addServiceTxt("esphomelib", "tcp", "project_name", ESPHOME_PROJECT_NAME); MDNS.addServiceTxt("esphomelib", "tcp", "project_version", ESPHOME_PROJECT_VERSION);