[core] Fix compilation errors when platform sections have no entities (#10023)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.12) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Component test ${{ matrix.file }} (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Publish Release / Initialize build (push) Has been cancelled
Publish Release / Build and publish to PyPi (push) Has been cancelled
Publish Release / Build ESPHome amd64 (push) Has been cancelled
Publish Release / Build ESPHome arm64 (push) Has been cancelled
Publish Release / Publish ESPHome docker to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome docker to ghcr (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to ghcr (push) Has been cancelled
Publish Release / deploy-ha-addon-repo (push) Has been cancelled
Publish Release / deploy-esphome-schema (push) Has been cancelled
Synchronise Device Classes from Home Assistant / Sync Device Classes (push) Has been cancelled

This commit is contained in:
J. Nick Koston
2025-08-02 13:59:20 -10:00
committed by GitHub
parent fd442cc485
commit 296442d8f1
19 changed files with 18 additions and 22 deletions
@@ -348,4 +348,3 @@ async def alarm_control_panel_is_armed_to_code(
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_global(alarm_control_panel_ns.using)
cg.add_define("USE_ALARM_CONTROL_PANEL")
@@ -654,7 +654,6 @@ async def binary_sensor_is_off_to_code(config, condition_id, template_arg, args)
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_BINARY_SENSOR")
cg.add_global(binary_sensor_ns.using)
-1
View File
@@ -137,4 +137,3 @@ async def button_press_to_code(config, action_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_global(button_ns.using)
cg.add_define("USE_BUTTON")
-1
View File
@@ -519,5 +519,4 @@ async def climate_control_to_code(config, action_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_CLIMATE")
cg.add_global(climate_ns.using)
-1
View File
@@ -265,5 +265,4 @@ async def cover_control_to_code(config, action_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_COVER")
cg.add_global(cover_ns.using)
-2
View File
@@ -164,7 +164,6 @@ async def register_datetime(var, config):
cg.add(getattr(cg.App, f"register_{entity_type}")(var))
CORE.register_platform_component(entity_type, var)
await setup_datetime_core_(var, config)
cg.add_define(f"USE_DATETIME_{config[CONF_TYPE]}")
async def new_datetime(config, *args):
@@ -175,7 +174,6 @@ async def new_datetime(config, *args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_DATETIME")
cg.add_global(datetime_ns.using)
-1
View File
@@ -145,5 +145,4 @@ async def event_fire_to_code(config, action_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_EVENT")
cg.add_global(event_ns.using)
-1
View File
@@ -400,5 +400,4 @@ async def fan_is_on_off_to_code(config, condition_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_FAN")
cg.add_global(fan_ns.using)
-1
View File
@@ -285,5 +285,4 @@ async def new_light(config, *args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_LIGHT")
cg.add_global(light_ns.using)
-1
View File
@@ -158,4 +158,3 @@ async def lock_is_off_to_code(config, condition_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_global(lock_ns.using)
cg.add_define("USE_LOCK")
-1
View File
@@ -323,7 +323,6 @@ async def number_in_range_to_code(config, condition_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_NUMBER")
cg.add_global(number_ns.using)
-1
View File
@@ -126,7 +126,6 @@ async def new_select(config, *, options: list[str]):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_SELECT")
cg.add_global(select_ns.using)
-1
View File
@@ -1139,5 +1139,4 @@ def _lstsq(a, b):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_SENSOR")
cg.add_global(sensor_ns.using)
-1
View File
@@ -202,4 +202,3 @@ async def switch_is_off_to_code(config, condition_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_global(switch_ns.using)
cg.add_define("USE_SWITCH")
-1
View File
@@ -151,7 +151,6 @@ async def new_text(
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_TEXT")
cg.add_global(text_ns.using)
@@ -232,7 +232,6 @@ async def new_text_sensor(config, *args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_TEXT_SENSOR")
cg.add_global(text_sensor_ns.using)
-1
View File
@@ -126,7 +126,6 @@ async def new_update(config):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_UPDATE")
cg.add_global(update_ns.using)
-1
View File
@@ -235,5 +235,4 @@ async def valve_control_to_code(config, action_id, template_arg, args):
@coroutine_with_priority(100.0)
async def to_code(config):
cg.add_define("USE_VALVE")
cg.add_global(valve_ns.using)
+18 -3
View File
@@ -419,13 +419,28 @@ async def _add_automations(config):
await automation.build_automation(trigger, [], conf)
# Datetime component has special subtypes that need additional defines
DATETIME_SUBTYPES = {"date", "time", "datetime"}
@coroutine_with_priority(-100.0)
async def _add_platform_reserves() -> None:
# Generate compile-time entity count defines for static_entity_vector
async def _add_platform_defines() -> None:
# Generate compile-time defines for platforms that have actual entities
# Only add USE_* and count defines when there are entities
for platform_name, count in sorted(CORE.platform_counts.items()):
if count <= 0:
continue
define_name = f"ESPHOME_ENTITY_{platform_name.upper()}_COUNT"
cg.add_define(define_name, count)
# Datetime subtypes only use USE_DATETIME_* defines
if platform_name in DATETIME_SUBTYPES:
cg.add_define(f"USE_DATETIME_{platform_name.upper()}")
else:
# Regular platforms use USE_* defines
cg.add_define(f"USE_{platform_name.upper()}")
@coroutine_with_priority(100.0)
async def to_code(config: ConfigType) -> None:
@@ -449,7 +464,7 @@ async def to_code(config: ConfigType) -> None:
cg.RawStatement(f"App.reserve_components({len(CORE.component_ids)});"),
)
CORE.add_job(_add_platform_reserves)
CORE.add_job(_add_platform_defines)
CORE.add_job(_add_automations, config)