Add platform and board to mdns response when API is used (#1871)

This commit is contained in:
Jesse Hills 2021-06-09 14:23:48 +12:00 committed by GitHub
parent 5cf18235e3
commit 65c50e4f01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -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])

View File

@ -24,3 +24,5 @@
#define USE_TIME
#define USE_DEEP_SLEEP
#define USE_CAPTIVE_PORTAL
#define ESPHOME_BOARD "dummy_board"
#define USE_MDNS

View File

@ -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);