This commit is contained in:
Tomasz Duda 2024-10-29 07:40:27 +01:00
parent f52e76381b
commit 1e4d32e0ea
2 changed files with 14 additions and 20 deletions

View file

@ -1,40 +1,37 @@
import re import re
from esphome import pins
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv
import esphome.final_validate as fv
from esphome.components.esp32.const import ( from esphome.components.esp32.const import (
KEY_ESP32, KEY_ESP32,
VARIANT_ESP32S2,
VARIANT_ESP32S3,
VARIANT_ESP32C2, VARIANT_ESP32C2,
VARIANT_ESP32C3, VARIANT_ESP32C3,
VARIANT_ESP32C6, VARIANT_ESP32C6,
VARIANT_ESP32H2, VARIANT_ESP32H2,
VARIANT_ESP32S2,
VARIANT_ESP32S3,
) )
from esphome import pins import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_CLK_PIN, CONF_CLK_PIN,
CONF_CS_PIN,
CONF_DATA_PINS,
CONF_DATA_RATE,
CONF_ID, CONF_ID,
CONF_INVERTED,
CONF_MISO_PIN, CONF_MISO_PIN,
CONF_MOSI_PIN, CONF_MOSI_PIN,
CONF_SPI_ID,
CONF_CS_PIN,
CONF_NUMBER, CONF_NUMBER,
CONF_INVERTED, CONF_SPI_ID,
KEY_CORE, KEY_CORE,
KEY_TARGET_PLATFORM, KEY_TARGET_PLATFORM,
KEY_VARIANT, KEY_VARIANT,
CONF_DATA_RATE,
PLATFORM_ESP32, PLATFORM_ESP32,
PLATFORM_ESP8266, PLATFORM_ESP8266,
PLATFORM_RP2040, PLATFORM_RP2040,
CONF_DATA_PINS,
)
from esphome.core import (
coroutine_with_priority,
CORE,
) )
from esphome.core import CORE, coroutine_with_priority
import esphome.final_validate as fv
CODEOWNERS = ["@esphome/core", "@clydebarrow"] CODEOWNERS = ["@esphome/core", "@clydebarrow"]
spi_ns = cg.esphome_ns.namespace("spi") spi_ns = cg.esphome_ns.namespace("spi")
@ -96,11 +93,7 @@ RP_SPI_PINSETS = [
def get_target_platform(): def get_target_platform():
return ( return CORE.data[KEY_CORE][KEY_TARGET_PLATFORM]
CORE.data[KEY_CORE][KEY_TARGET_PLATFORM]
if KEY_TARGET_PLATFORM in CORE.data[KEY_CORE]
else ""
)
def get_target_variant(): def get_target_variant():

View file

@ -299,7 +299,8 @@ def preload_core_config(config, result) -> str:
# Insert generated target platform config to main config # Insert generated target platform config to main config
config[plat] = plat_conf config[plat] = plat_conf
config[CONF_ESPHOME] = conf config[CONF_ESPHOME] = conf
return newstyle_found[0] if newstyle_found else plat target_platform = newstyle_found[0] if newstyle_found else plat
return target_platform
def include_file(path, basename): def include_file(path, basename):