mirror of
https://github.com/esphome/esphome.git
synced 2025-09-01 10:52:19 +01:00
Merge branch 'entity_count_order_fix' into integration
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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)"
|
||||
)
|
||||
|
Reference in New Issue
Block a user