mirror of
https://github.com/esphome/esphome.git
synced 2025-08-06 10:27:49 +00:00
tweaks
This commit is contained in:
parent
629c891dfc
commit
8677918157
@ -19,6 +19,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
|
|
||||||
@ -237,16 +238,18 @@ def validate_adc_pin(value):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"adc_sensor_esp32.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"adc_sensor_esp32.cpp": {
|
||||||
PlatformFramework.ESP32_IDF,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
},
|
PlatformFramework.ESP32_IDF,
|
||||||
"adc_sensor_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
},
|
||||||
"adc_sensor_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
"adc_sensor_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
"adc_sensor_libretiny.cpp": {
|
"adc_sensor_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"adc_sensor_libretiny.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -9,6 +9,7 @@ from esphome.const import (
|
|||||||
CONF_LOOP_TIME,
|
CONF_LOOP_TIME,
|
||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CODEOWNERS = ["@OttoWinter"]
|
CODEOWNERS = ["@OttoWinter"]
|
||||||
DEPENDENCIES = ["logger"]
|
DEPENDENCIES = ["logger"]
|
||||||
@ -47,14 +48,19 @@ async def to_code(config):
|
|||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"debug_esp32.cpp": {PlatformFramework.ESP32_ARDUINO, PlatformFramework.ESP32_IDF},
|
{
|
||||||
"debug_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
"debug_esp32.cpp": {
|
||||||
"debug_host.cpp": {PlatformFramework.HOST_NATIVE},
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
"debug_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
PlatformFramework.ESP32_IDF,
|
||||||
"debug_libretiny.cpp": {
|
},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"debug_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
"debug_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
"debug_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||||
},
|
"debug_libretiny.cpp": {
|
||||||
}
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -29,6 +29,7 @@ from esphome.const import (
|
|||||||
PLATFORM_ESP8266,
|
PLATFORM_ESP8266,
|
||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
WAKEUP_PINS = {
|
WAKEUP_PINS = {
|
||||||
VARIANT_ESP32: [
|
VARIANT_ESP32: [
|
||||||
@ -316,10 +317,12 @@ async def deep_sleep_action_to_code(config, action_id, template_arg, args):
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"deep_sleep_esp32.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"deep_sleep_esp32.cpp": {
|
||||||
PlatformFramework.ESP32_IDF,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
},
|
PlatformFramework.ESP32_IDF,
|
||||||
"deep_sleep_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
},
|
||||||
}
|
"deep_sleep_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -17,7 +17,7 @@ from esphome.const import (
|
|||||||
__version__,
|
__version__,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, Lambda
|
from esphome.core import CORE, Lambda
|
||||||
from esphome.helpers import IS_MACOS
|
from esphome.helpers import IS_MACOS, filter_source_files_from_platform
|
||||||
|
|
||||||
DEPENDENCIES = ["network"]
|
DEPENDENCIES = ["network"]
|
||||||
AUTO_LOAD = ["json", "watchdog"]
|
AUTO_LOAD = ["json", "watchdog"]
|
||||||
@ -322,15 +322,17 @@ async def http_request_action_to_code(config, action_id, template_arg, args):
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"http_request_host.cpp": {PlatformFramework.HOST_NATIVE},
|
{
|
||||||
"http_request_arduino.cpp": {
|
"http_request_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"http_request_arduino.cpp": {
|
||||||
PlatformFramework.ESP8266_ARDUINO,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
PlatformFramework.RP2040_ARDUINO,
|
PlatformFramework.ESP8266_ARDUINO,
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
PlatformFramework.RP2040_ARDUINO,
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
"http_request_idf.cpp": {PlatformFramework.ESP32_IDF},
|
},
|
||||||
}
|
"http_request_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -22,6 +22,7 @@ from esphome.const import (
|
|||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
@ -208,14 +209,16 @@ def final_validate_device_schema(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"i2c_bus_arduino.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"i2c_bus_arduino.cpp": {
|
||||||
PlatformFramework.ESP8266_ARDUINO,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
PlatformFramework.RP2040_ARDUINO,
|
PlatformFramework.ESP8266_ARDUINO,
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
PlatformFramework.RP2040_ARDUINO,
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
"i2c_bus_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
},
|
||||||
}
|
"i2c_bus_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -24,6 +24,7 @@ from esphome.const import (
|
|||||||
__version__,
|
__version__,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
from . import gpio # noqa
|
from . import gpio # noqa
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -343,10 +344,12 @@ async def component_to_code(config):
|
|||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"gpio_arduino.cpp": {
|
{
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"gpio_arduino.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -45,6 +45,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, Lambda, coroutine_with_priority
|
from esphome.core import CORE, Lambda, coroutine_with_priority
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
logger_ns = cg.esphome_ns.namespace("logger")
|
logger_ns = cg.esphome_ns.namespace("logger")
|
||||||
@ -447,18 +448,23 @@ async def logger_set_level_to_code(config, action_id, template_arg, args):
|
|||||||
return cg.new_Pvariable(action_id, template_arg, lambda_)
|
return cg.new_Pvariable(action_id, template_arg, lambda_)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"logger_esp32.cpp": {PlatformFramework.ESP32_ARDUINO, PlatformFramework.ESP32_IDF},
|
{
|
||||||
"logger_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
"logger_esp32.cpp": {
|
||||||
"logger_host.cpp": {PlatformFramework.HOST_NATIVE},
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
"logger_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
PlatformFramework.ESP32_IDF,
|
||||||
"logger_libretiny.cpp": {
|
},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"logger_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
"logger_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
"logger_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||||
},
|
"logger_libretiny.cpp": {
|
||||||
"task_log_buffer.cpp": {
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
PlatformFramework.ESP32_IDF,
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
},
|
},
|
||||||
}
|
"task_log_buffer.cpp": {
|
||||||
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
|
PlatformFramework.ESP32_IDF,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -11,6 +11,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
DEPENDENCIES = ["network"]
|
DEPENDENCIES = ["network"]
|
||||||
@ -111,14 +112,19 @@ async def to_code(config):
|
|||||||
cg.add(var.add_extra_service(exp))
|
cg.add(var.add_extra_service(exp))
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"mdns_esp32.cpp": {PlatformFramework.ESP32_ARDUINO, PlatformFramework.ESP32_IDF},
|
{
|
||||||
"mdns_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
"mdns_esp32.cpp": {
|
||||||
"mdns_host.cpp": {PlatformFramework.HOST_NATIVE},
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
"mdns_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
PlatformFramework.ESP32_IDF,
|
||||||
"mdns_libretiny.cpp": {
|
},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"mdns_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
"mdns_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
"mdns_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||||
},
|
"mdns_libretiny.cpp": {
|
||||||
}
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -57,6 +57,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
DEPENDENCIES = ["network"]
|
DEPENDENCIES = ["network"]
|
||||||
|
|
||||||
@ -599,9 +600,11 @@ async def mqtt_disable_to_code(config, action_id, template_arg, args):
|
|||||||
return cg.new_Pvariable(action_id, template_arg, paren)
|
return cg.new_Pvariable(action_id, template_arg, paren)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"mqtt_backend_esp32.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"mqtt_backend_esp32.cpp": {
|
||||||
PlatformFramework.ESP32_IDF,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
},
|
PlatformFramework.ESP32_IDF,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
from esphome.components import uart
|
from esphome.components import uart
|
||||||
from esphome.const import PlatformFramework
|
from esphome.const import PlatformFramework
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
nextion_ns = cg.esphome_ns.namespace("nextion")
|
nextion_ns = cg.esphome_ns.namespace("nextion")
|
||||||
Nextion = nextion_ns.class_("Nextion", cg.PollingComponent, uart.UARTDevice)
|
Nextion = nextion_ns.class_("Nextion", cg.PollingComponent, uart.UARTDevice)
|
||||||
@ -10,14 +11,16 @@ CONF_NEXTION_ID = "nextion_id"
|
|||||||
CONF_PUBLISH_STATE = "publish_state"
|
CONF_PUBLISH_STATE = "publish_state"
|
||||||
CONF_SEND_TO_NEXTION = "send_to_nextion"
|
CONF_SEND_TO_NEXTION = "send_to_nextion"
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"nextion_upload_arduino.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"nextion_upload_arduino.cpp": {
|
||||||
PlatformFramework.ESP8266_ARDUINO,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
PlatformFramework.RP2040_ARDUINO,
|
PlatformFramework.ESP8266_ARDUINO,
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
PlatformFramework.RP2040_ARDUINO,
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
"nextion_upload_idf.cpp": {PlatformFramework.ESP32_IDF},
|
},
|
||||||
}
|
"nextion_upload_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -10,6 +10,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
AUTO_LOAD = ["md5", "safe_mode"]
|
AUTO_LOAD = ["md5", "safe_mode"]
|
||||||
@ -123,14 +124,16 @@ async def ota_to_code(var, config):
|
|||||||
cg.add_define("USE_OTA_STATE_CALLBACK")
|
cg.add_define("USE_OTA_STATE_CALLBACK")
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"ota_backend_arduino_esp32.cpp": {PlatformFramework.ESP32_ARDUINO},
|
{
|
||||||
"ota_backend_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
"ota_backend_arduino_esp32.cpp": {PlatformFramework.ESP32_ARDUINO},
|
||||||
"ota_backend_arduino_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
"ota_backend_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
"ota_backend_arduino_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
"ota_backend_arduino_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
"ota_backend_arduino_libretiny.cpp": {
|
"ota_backend_arduino_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"ota_backend_arduino_libretiny.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -18,6 +18,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE, TimePeriod
|
from esphome.core import CORE, TimePeriod
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CONF_FILTER_SYMBOLS = "filter_symbols"
|
CONF_FILTER_SYMBOLS = "filter_symbols"
|
||||||
CONF_RECEIVE_SYMBOLS = "receive_symbols"
|
CONF_RECEIVE_SYMBOLS = "receive_symbols"
|
||||||
@ -173,15 +174,17 @@ async def to_code(config):
|
|||||||
cg.add(var.set_idle_us(config[CONF_IDLE]))
|
cg.add(var.set_idle_us(config[CONF_IDLE]))
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"remote_receiver_esp32.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"remote_receiver_esp32.cpp": {
|
||||||
PlatformFramework.ESP32_IDF,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
},
|
PlatformFramework.ESP32_IDF,
|
||||||
"remote_receiver_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
},
|
||||||
"remote_receiver_libretiny.cpp": {
|
"remote_receiver_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"remote_receiver_libretiny.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -15,6 +15,7 @@ from esphome.const import (
|
|||||||
PlatformFramework,
|
PlatformFramework,
|
||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
AUTO_LOAD = ["remote_base"]
|
AUTO_LOAD = ["remote_base"]
|
||||||
|
|
||||||
@ -98,15 +99,17 @@ async def to_code(config):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"remote_transmitter_esp32.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"remote_transmitter_esp32.cpp": {
|
||||||
PlatformFramework.ESP32_IDF,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
},
|
PlatformFramework.ESP32_IDF,
|
||||||
"remote_transmitter_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
},
|
||||||
"remote_transmitter_libretiny.cpp": {
|
"remote_transmitter_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"remote_transmitter_libretiny.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
|
|
||||||
@ -40,3 +41,21 @@ async def to_code(config):
|
|||||||
elif impl == IMPLEMENTATION_BSD_SOCKETS:
|
elif impl == IMPLEMENTATION_BSD_SOCKETS:
|
||||||
cg.add_define("USE_SOCKET_IMPL_BSD_SOCKETS")
|
cg.add_define("USE_SOCKET_IMPL_BSD_SOCKETS")
|
||||||
cg.add_define("USE_SOCKET_SELECT_SUPPORT")
|
cg.add_define("USE_SOCKET_SELECT_SUPPORT")
|
||||||
|
|
||||||
|
|
||||||
|
def FILTER_SOURCE_FILES() -> list[str]:
|
||||||
|
"""Return list of socket implementation files that aren't selected by the user."""
|
||||||
|
if not hasattr(CORE, "config") or "socket" not in CORE.config:
|
||||||
|
return []
|
||||||
|
|
||||||
|
impl = CORE.config["socket"][CONF_IMPLEMENTATION]
|
||||||
|
|
||||||
|
# Build list of files to exclude based on selected implementation
|
||||||
|
excluded = []
|
||||||
|
if impl != IMPLEMENTATION_LWIP_TCP:
|
||||||
|
excluded.append("lwip_raw_tcp_impl.cpp")
|
||||||
|
if impl != IMPLEMENTATION_BSD_SOCKETS:
|
||||||
|
excluded.append("bsd_sockets_impl.cpp")
|
||||||
|
if impl != IMPLEMENTATION_LWIP_SOCKETS:
|
||||||
|
excluded.append("lwip_sockets_impl.cpp")
|
||||||
|
return excluded
|
||||||
|
@ -35,6 +35,7 @@ from esphome.const import (
|
|||||||
)
|
)
|
||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core", "@clydebarrow"]
|
CODEOWNERS = ["@esphome/core", "@clydebarrow"]
|
||||||
spi_ns = cg.esphome_ns.namespace("spi")
|
spi_ns = cg.esphome_ns.namespace("spi")
|
||||||
@ -426,14 +427,16 @@ def final_validate_device_schema(name: str, *, require_mosi: bool, require_miso:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"spi_arduino.cpp": {
|
{
|
||||||
PlatformFramework.ESP32_ARDUINO,
|
"spi_arduino.cpp": {
|
||||||
PlatformFramework.ESP8266_ARDUINO,
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
PlatformFramework.RP2040_ARDUINO,
|
PlatformFramework.ESP8266_ARDUINO,
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
PlatformFramework.RP2040_ARDUINO,
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
"spi_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
},
|
||||||
}
|
"spi_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -31,6 +31,7 @@ from esphome.const import (
|
|||||||
)
|
)
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
from esphome.yaml_util import make_data_base
|
from esphome.yaml_util import make_data_base
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
@ -441,15 +442,17 @@ async def uart_write_to_code(config, action_id, template_arg, args):
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"uart_component_esp32_arduino.cpp": {PlatformFramework.ESP32_ARDUINO},
|
{
|
||||||
"uart_component_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
"uart_component_esp32_arduino.cpp": {PlatformFramework.ESP32_ARDUINO},
|
||||||
"uart_component_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
"uart_component_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
"uart_component_host.cpp": {PlatformFramework.HOST_NATIVE},
|
"uart_component_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
"uart_component_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
"uart_component_host.cpp": {PlatformFramework.HOST_NATIVE},
|
||||||
"uart_component_libretiny.cpp": {
|
"uart_component_rp2040.cpp": {PlatformFramework.RP2040_ARDUINO},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"uart_component_libretiny.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -43,6 +43,7 @@ from esphome.const import (
|
|||||||
)
|
)
|
||||||
from esphome.core import CORE, HexInt, coroutine_with_priority
|
from esphome.core import CORE, HexInt, coroutine_with_priority
|
||||||
import esphome.final_validate as fv
|
import esphome.final_validate as fv
|
||||||
|
from esphome.helpers import filter_source_files_from_platform
|
||||||
|
|
||||||
from . import wpa2_eap
|
from . import wpa2_eap
|
||||||
|
|
||||||
@ -529,13 +530,15 @@ async def wifi_set_sta_to_code(config, action_id, template_arg, args):
|
|||||||
return var
|
return var
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"wifi_component_esp32_arduino.cpp": {PlatformFramework.ESP32_ARDUINO},
|
{
|
||||||
"wifi_component_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
"wifi_component_esp32_arduino.cpp": {PlatformFramework.ESP32_ARDUINO},
|
||||||
"wifi_component_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
"wifi_component_esp_idf.cpp": {PlatformFramework.ESP32_IDF},
|
||||||
"wifi_component_libretiny.cpp": {
|
"wifi_component_esp8266.cpp": {PlatformFramework.ESP8266_ARDUINO},
|
||||||
PlatformFramework.BK72XX_ARDUINO,
|
"wifi_component_libretiny.cpp": {
|
||||||
PlatformFramework.RTL87XX_ARDUINO,
|
PlatformFramework.BK72XX_ARDUINO,
|
||||||
PlatformFramework.LN882X_ARDUINO,
|
PlatformFramework.RTL87XX_ARDUINO,
|
||||||
},
|
PlatformFramework.LN882X_ARDUINO,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -41,6 +41,7 @@ from esphome.const import (
|
|||||||
from esphome.core import CORE, coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
from esphome.helpers import (
|
from esphome.helpers import (
|
||||||
copy_file_if_changed,
|
copy_file_if_changed,
|
||||||
|
filter_source_files_from_platform,
|
||||||
fnv1a_32bit_hash,
|
fnv1a_32bit_hash,
|
||||||
get_str_env,
|
get_str_env,
|
||||||
walk_files,
|
walk_files,
|
||||||
@ -555,8 +556,13 @@ async def to_code(config: ConfigType) -> None:
|
|||||||
|
|
||||||
|
|
||||||
# Platform-specific source files for core
|
# Platform-specific source files for core
|
||||||
PLATFORM_SOURCE_FILES: dict[str, set[PlatformFramework]] = {
|
FILTER_SOURCE_FILES = filter_source_files_from_platform(
|
||||||
"ring_buffer.cpp": {PlatformFramework.ESP32_ARDUINO, PlatformFramework.ESP32_IDF},
|
{
|
||||||
# Note: lock_free_queue.h and event_pool.h are header files and don't need to be filtered
|
"ring_buffer.cpp": {
|
||||||
# as they are only included when needed by the preprocessor
|
PlatformFramework.ESP32_ARDUINO,
|
||||||
}
|
PlatformFramework.ESP32_IDF,
|
||||||
|
},
|
||||||
|
# Note: lock_free_queue.h and event_pool.h are header files and don't need to be filtered
|
||||||
|
# as they are only included when needed by the preprocessor
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import codecs
|
import codecs
|
||||||
|
from collections.abc import Callable
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import logging
|
import logging
|
||||||
@ -7,8 +8,12 @@ from pathlib import Path
|
|||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from esphome.const import PlatformFramework
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
IS_MACOS = platform.system() == "Darwin"
|
IS_MACOS = platform.system() == "Darwin"
|
||||||
@ -505,3 +510,54 @@ _DISALLOWED_CHARS = re.compile(r"[^a-zA-Z0-9-_]")
|
|||||||
def sanitize(value):
|
def sanitize(value):
|
||||||
"""Same behaviour as `helpers.cpp` method `str_sanitize`."""
|
"""Same behaviour as `helpers.cpp` method `str_sanitize`."""
|
||||||
return _DISALLOWED_CHARS.sub("_", value)
|
return _DISALLOWED_CHARS.sub("_", value)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_source_files_from_platform(
|
||||||
|
files_map: dict[str, set["PlatformFramework"]],
|
||||||
|
) -> Callable[[], list[str]]:
|
||||||
|
"""Helper to build a FILTER_SOURCE_FILES function from platform mapping.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
files_map: Dict mapping filename to set of PlatformFramework enums
|
||||||
|
that should compile this file
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Function that returns list of files to exclude for current platform
|
||||||
|
"""
|
||||||
|
from esphome.const import (
|
||||||
|
KEY_CORE,
|
||||||
|
KEY_TARGET_FRAMEWORK,
|
||||||
|
KEY_TARGET_PLATFORM,
|
||||||
|
PlatformFramework,
|
||||||
|
)
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
|
# Pre-build lookup map from (platform, framework) tuples to PlatformFramework enum
|
||||||
|
_PLATFORM_FRAMEWORK_LOOKUP = {pf.value: pf for pf in PlatformFramework}
|
||||||
|
|
||||||
|
def filter_source_files() -> list[str]:
|
||||||
|
# Get current platform/framework
|
||||||
|
core_data = CORE.data.get(KEY_CORE, {})
|
||||||
|
target_platform = core_data.get(KEY_TARGET_PLATFORM)
|
||||||
|
target_framework = core_data.get(KEY_TARGET_FRAMEWORK)
|
||||||
|
|
||||||
|
if not target_platform or not target_framework:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# Direct lookup of current PlatformFramework
|
||||||
|
current_platform_framework = _PLATFORM_FRAMEWORK_LOOKUP.get(
|
||||||
|
(target_platform, target_framework)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not current_platform_framework:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# Return files that should be excluded for current platform
|
||||||
|
excluded = []
|
||||||
|
for filename, platforms in files_map.items():
|
||||||
|
if current_platform_framework not in platforms:
|
||||||
|
excluded.append(filename)
|
||||||
|
|
||||||
|
return excluded
|
||||||
|
|
||||||
|
return filter_source_files
|
||||||
|
@ -11,26 +11,13 @@ import sys
|
|||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from esphome.const import (
|
from esphome.const import SOURCE_FILE_EXTENSIONS
|
||||||
KEY_CORE,
|
|
||||||
KEY_TARGET_FRAMEWORK,
|
|
||||||
KEY_TARGET_PLATFORM,
|
|
||||||
SOURCE_FILE_EXTENSIONS,
|
|
||||||
Framework,
|
|
||||||
Platform,
|
|
||||||
PlatformFramework,
|
|
||||||
)
|
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
import esphome.core.config
|
import esphome.core.config
|
||||||
from esphome.types import ConfigType
|
from esphome.types import ConfigType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Build unified lookup table from PlatformFramework enum
|
|
||||||
_PLATFORM_FRAMEWORK_LOOKUP: dict[
|
|
||||||
tuple[Platform, Framework | None], PlatformFramework
|
|
||||||
] = {pf.value: pf for pf in PlatformFramework}
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True, order=True)
|
@dataclass(frozen=True, order=True)
|
||||||
class FileResource:
|
class FileResource:
|
||||||
@ -123,28 +110,13 @@ class ComponentManifest:
|
|||||||
"""Return a list of all file resources defined in the package of this component."""
|
"""Return a list of all file resources defined in the package of this component."""
|
||||||
ret: list[FileResource] = []
|
ret: list[FileResource] = []
|
||||||
|
|
||||||
# Get current platform-framework combination
|
# Get filter function for source files
|
||||||
core_data: dict[str, Any] = CORE.data.get(KEY_CORE, {})
|
filter_source_files_func = getattr(self.module, "FILTER_SOURCE_FILES", None)
|
||||||
target_platform: Platform | None = core_data.get(KEY_TARGET_PLATFORM)
|
|
||||||
target_framework: Framework | None = core_data.get(KEY_TARGET_FRAMEWORK)
|
|
||||||
|
|
||||||
# Get platform-specific files mapping
|
# Get list of files to exclude
|
||||||
platform_source_files: dict[str, set[PlatformFramework]] = getattr(
|
excluded_files: set[str] = set()
|
||||||
self.module, "PLATFORM_SOURCE_FILES", {}
|
if filter_source_files_func is not None:
|
||||||
)
|
excluded_files = set(filter_source_files_func())
|
||||||
|
|
||||||
# Get current PlatformFramework
|
|
||||||
lookup_key = (target_platform, target_framework)
|
|
||||||
current_platform_framework: PlatformFramework | None = (
|
|
||||||
_PLATFORM_FRAMEWORK_LOOKUP.get(lookup_key)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Build set of allowed filenames for current platform
|
|
||||||
allowed_filenames: set[str] = set()
|
|
||||||
if current_platform_framework and platform_source_files:
|
|
||||||
for filename, platforms in platform_source_files.items():
|
|
||||||
if current_platform_framework in platforms:
|
|
||||||
allowed_filenames.add(filename)
|
|
||||||
|
|
||||||
# Process all resources
|
# Process all resources
|
||||||
for resource in (
|
for resource in (
|
||||||
@ -157,9 +129,8 @@ class ComponentManifest:
|
|||||||
if not importlib.resources.files(self.package).joinpath(resource).is_file():
|
if not importlib.resources.files(self.package).joinpath(resource).is_file():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check platform restrictions only if file is platform-specific
|
# Skip excluded files
|
||||||
# Common files (not in platform_source_files) are always included
|
if resource in excluded_files:
|
||||||
if resource in platform_source_files and resource not in allowed_filenames:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ret.append(FileResource(self.package, resource))
|
ret.append(FileResource(self.package, resource))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user