Allow manual overriding of esp-adf board

This commit is contained in:
Jesse Hills 2023-09-13 11:49:27 +12:00
parent c19f0cf6bc
commit fce2eafda0
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -5,7 +5,7 @@ import esphome.codegen as cg
from esphome.components import esp32
from esphome.const import CONF_ID
from esphome.const import CONF_ID, CONF_BOARD
CONFLICTS_WITH = ["i2s_audio"]
CODEOWNERS = ["@jesserockz"]
@ -17,18 +17,26 @@ esp_adf_ns = cg.esphome_ns.namespace("esp_adf")
ESPADF = esp_adf_ns.class_("ESPADF", cg.Component)
ESPADFPipeline = esp_adf_ns.class_("ESPADFPipeline", cg.Parented.template(ESPADF))
SUPPORTED_BOARDS = {"esp32s3box": "CONFIG_ESP32_S3_BOX_BOARD"}
SUPPORTED_BOARDS = {
"esp32s3box": "CONFIG_ESP32_S3_BOX_BOARD",
"esp32s3boxlite": "CONFIG_ESP32_S3_BOX_LITE_BOARD",
}
def _validate_board(config):
board = esp32.get_board()
board = config.get(CONF_BOARD, esp32.get_board())
if board not in SUPPORTED_BOARDS:
raise cv.Invalid(f"Board {board} is not supported by esp-adf")
return config
CONFIG_SCHEMA = cv.All(
cv.Schema({cv.GenerateID(): cv.declare_id(ESPADF)}),
cv.Schema(
{
cv.GenerateID(): cv.declare_id(ESPADF),
cv.Optional(CONF_BOARD): cv.string_strict,
}
),
_validate_board,
cv.only_with_esp_idf,
)
@ -54,7 +62,8 @@ async def to_code(config):
cg.add_platformio_option(
"board_build.embed_txtfiles", "components/dueros_service/duer_profile"
)
esp32.add_idf_sdkconfig_option(SUPPORTED_BOARDS[esp32.get_board()], True)
board = config.get(CONF_BOARD, esp32.get_board())
esp32.add_idf_sdkconfig_option(SUPPORTED_BOARDS[board], True)
esp32.add_extra_script(
"pre",