1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-01 19:02:18 +01:00

Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-08-29 22:11:17 -05:00
3 changed files with 24 additions and 2 deletions

View File

@@ -423,7 +423,7 @@ async def _add_automations(config):
DATETIME_SUBTYPES = {"date", "time", "datetime"}
@coroutine_with_priority(-100.0)
@coroutine_with_priority(-1000.0)
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

View File

@@ -12,7 +12,7 @@ platformio==6.1.18 # When updating platformio, also update /docker/Dockerfile
esptool==5.0.2
click==8.1.7
esphome-dashboard==20250828.0
aioesphomeapi==39.0.0
aioesphomeapi==39.0.1
zeroconf==0.147.0
puremagic==1.30
ruamel.yaml==0.18.15 # dashboard_import

View File

@@ -8,6 +8,7 @@ import pytest
from esphome import config_validation as cv, core
from esphome.const import CONF_AREA, CONF_AREAS, CONF_DEVICES
from esphome.core import config
from esphome.core.config import Area, validate_area_config
from .common import load_config_from_fixture
@@ -223,3 +224,24 @@ def test_device_duplicate_id(
# Check for the specific error message from IDPassValidationStep
captured = capsys.readouterr()
assert "ID duplicate_device redefined!" in captured.out
def test_add_platform_defines_priority() -> None:
"""Test that _add_platform_defines runs after globals.
This ensures the fix for issue #10431 where sensor counts were incorrect
when lambdas were present. The function must run at a lower priority than
globals (-100.0) to ensure all components (including those using globals
in lambdas) have registered their entities before the count defines are
generated.
Regression test for https://github.com/esphome/esphome/issues/10431
"""
# Import globals to check its priority
from esphome.components.globals import to_code as globals_to_code
# _add_platform_defines must run AFTER globals (lower priority number = runs later)
assert config._add_platform_defines.priority < globals_to_code.priority, (
f"_add_platform_defines priority ({config._add_platform_defines.priority}) must be lower than "
f"globals priority ({globals_to_code.priority}) to fix issue #10431 (sensor count bug with lambdas)"
)