diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index 8ea08b37d2..b0290d7a84 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -246,7 +246,7 @@ DEFAULT_EXCLUDED_IDF_COMPONENTS = ( "esp_https_server", # HTTPS server - ESPHome has its own web server "esp_lcd", # LCD controller drivers - only needed by display component "esp_local_ctrl", # Local control over HTTPS/BLE - ESPHome has native API - "esp_phy", # RF PHY - esp_wifi/bt/ieee802154 pull it back when they are in the build + "esp_phy", # RF PHY - re-included by internal_temperature on the original ESP32; esp_wifi/bt/ieee802154 pull it back "esp_wifi", # WiFi stack - re-included by request_wifi(), espnow; bt pulls it back for BLE builds "espcoredump", # Core dump support - ESPHome has its own debug component "fatfs", # FAT filesystem - ESPHome doesn't use filesystem storage diff --git a/esphome/components/internal_temperature/sensor.py b/esphome/components/internal_temperature/sensor.py index d3101f4a7c..40ac216f0c 100644 --- a/esphome/components/internal_temperature/sensor.py +++ b/esphome/components/internal_temperature/sensor.py @@ -1,5 +1,7 @@ import esphome.codegen as cg from esphome.components import sensor +from esphome.components.esp32 import get_esp32_variant, include_builtin_idf_component +from esphome.components.esp32.const import VARIANT_ESP32 from esphome.components.zephyr import zephyr_add_prj_conf from esphome.config_helpers import filter_source_files_from_platform import esphome.config_validation as cv @@ -48,6 +50,10 @@ async def to_code(config: ConfigType) -> None: var = await sensor.new_sensor(config) await cg.register_component(var, config) + if CORE.is_esp32 and get_esp32_variant() == VARIANT_ESP32: + # temprature_sens_read() lives in the esp_phy blob, which is excluded by default + include_builtin_idf_component("esp_phy") + if CORE.using_zephyr and CORE.is_nrf52: zephyr_add_prj_conf("SENSOR", True) zephyr_add_prj_conf("TEMP_NRF5", True) diff --git a/tests/component_tests/esp32/config/exclusion_reincludes_internal_temperature.yaml b/tests/component_tests/esp32/config/exclusion_reincludes_internal_temperature.yaml new file mode 100644 index 0000000000..d5a0aaf157 --- /dev/null +++ b/tests/component_tests/esp32/config/exclusion_reincludes_internal_temperature.yaml @@ -0,0 +1,11 @@ +esphome: + name: test + +esp32: + board: esp32dev + framework: + type: esp-idf + +sensor: + - platform: internal_temperature + name: Internal Temperature diff --git a/tests/component_tests/esp32/config/exclusion_stays_internal_temperature_s3.yaml b/tests/component_tests/esp32/config/exclusion_stays_internal_temperature_s3.yaml new file mode 100644 index 0000000000..6d4dbf90b5 --- /dev/null +++ b/tests/component_tests/esp32/config/exclusion_stays_internal_temperature_s3.yaml @@ -0,0 +1,11 @@ +esphome: + name: test + +esp32: + board: esp32-s3-devkitc-1 + framework: + type: esp-idf + +sensor: + - platform: internal_temperature + name: Internal Temperature diff --git a/tests/component_tests/esp32/test_esp32.py b/tests/component_tests/esp32/test_esp32.py index c72c4c3a6b..db7ed6b3fc 100644 --- a/tests/component_tests/esp32/test_esp32.py +++ b/tests/component_tests/esp32/test_esp32.py @@ -313,6 +313,12 @@ def test_esp32_configuration_errors( ("esp_wifi",), id="espnow", ), + pytest.param( + # temprature_sens_read() on the original ESP32 lives in the esp_phy blob. + "exclusion_reincludes_internal_temperature.yaml", + ("esp_phy",), + id="internal_temperature", + ), ], ) def test_default_exclusions_reincluded_by_owning_components( @@ -337,6 +343,15 @@ def test_default_exclusions_reincluded_by_owning_components( assert ("esp_http_server" in excluded) == ("esp_http_server" not in reincluded) +def test_esp_phy_stays_excluded_for_internal_temperature_on_newer_variants( + generate_main: Callable[[str | Path], str], + component_config_path: Callable[[str], Path], +) -> None: + """Only the original ESP32 reads the PHY blob; other variants use esp_driver_tsens.""" + generate_main(component_config_path("exclusion_stays_internal_temperature_s3.yaml")) + assert "esp_phy" in CORE.data[KEY_ESP32][KEY_EXCLUDE_COMPONENTS] + + def test_nvs_sec_provider_stays_excluded_when_encryption_is_off( generate_main: Callable[[str | Path], str], component_config_path: Callable[[str], Path],