diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index 9cb9ac257a..b7d3ef4a6d 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -13,6 +13,7 @@ from esphome.const import ( CONF_COMPONENTS, CONF_ESPHOME, CONF_FRAMEWORK, + CONF_IGNORE_EFUSE_CUSTOM_MAC, CONF_IGNORE_EFUSE_MAC_CRC, CONF_NAME, CONF_PATH, @@ -401,6 +402,9 @@ ESP_IDF_FRAMEWORK_SCHEMA = cv.All( }, cv.Optional(CONF_ADVANCED, default={}): cv.Schema( { + cv.Optional( + CONF_IGNORE_EFUSE_CUSTOM_MAC, default=False + ): cv.boolean, cv.Optional(CONF_IGNORE_EFUSE_MAC_CRC, default=False): cv.boolean, } ), @@ -526,6 +530,8 @@ async def to_code(config): for name, value in conf[CONF_SDKCONFIG_OPTIONS].items(): add_idf_sdkconfig_option(name, RawSdkconfigValue(value)) + if conf[CONF_ADVANCED][CONF_IGNORE_EFUSE_CUSTOM_MAC]: + cg.add_define("USE_ESP32_IGNORE_EFUSE_CUSTOM_MAC") if conf[CONF_ADVANCED][CONF_IGNORE_EFUSE_MAC_CRC]: cg.add_define("USE_ESP32_IGNORE_EFUSE_MAC_CRC") if (framework_ver.major, framework_ver.minor) >= (4, 4): diff --git a/esphome/const.py b/esphome/const.py index 40b7a1c419..830f139077 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -376,6 +376,7 @@ CONF_IDLE_ACTION = "idle_action" CONF_IDLE_LEVEL = "idle_level" CONF_IDLE_TIME = "idle_time" CONF_IF = "if" +CONF_IGNORE_EFUSE_CUSTOM_MAC = "ignore_efuse_custom_mac" CONF_IGNORE_EFUSE_MAC_CRC = "ignore_efuse_mac_crc" CONF_IGNORE_OUT_OF_RANGE = "ignore_out_of_range" CONF_IGNORE_PIN_VALIDATION_ERROR = "ignore_pin_validation_error" diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 61fd23508e..492ab6dd1a 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -709,7 +709,7 @@ void set_mac_address(uint8_t *mac) { esp_base_mac_addr_set(mac); } #endif bool has_custom_mac_address() { -#ifdef USE_ESP32 +#if defined(USE_ESP32) && !defined(USE_ESP32_IGNORE_EFUSE_CUSTOM_MAC) uint8_t mac[6]; // do not use 'esp_efuse_mac_get_custom(mac)' because it drops an error in the logs whenever it fails #ifndef USE_ESP32_VARIANT_ESP32