[zigbee] Fix codegen ordering for basic/identify attribute lists (#14343)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Jonathan Swoboda
2026-02-27 11:17:04 -05:00
committed by GitHub
parent 0f7ac1726d
commit ef9fc87351
2 changed files with 9 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ from esphome.components.zephyr import zephyr_add_pm_static, zephyr_data
from esphome.components.zephyr.const import KEY_BOOTLOADER
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_INTERNAL, CONF_NAME
from esphome.core import CORE
from esphome.core import CORE, CoroPriority, coroutine_with_priority
from esphome.types import ConfigType
from .const_zephyr import (
@@ -96,6 +96,7 @@ FINAL_VALIDATE_SCHEMA = cv.All(
)
@coroutine_with_priority(CoroPriority.CORE)
async def to_code(config: ConfigType) -> None:
cg.add_define("USE_ZIGBEE")
if CORE.using_zephyr:

View File

@@ -179,6 +179,13 @@ async def zephyr_to_code(config: ConfigType) -> None:
"USE_ZIGBEE_WIPE_ON_BOOT_MAGIC", random.randint(0x000001, 0xFFFFFF)
)
cg.add_define("USE_ZIGBEE_WIPE_ON_BOOT")
# Generate attribute lists before any await that could yield (e.g., build_automation
# waiting for variables from other components). If the hub's priority decays while
# yielding, deferred entity jobs may add cluster list globals that reference these
# attribute lists before they're declared.
await _attr_to_code(config)
var = cg.new_Pvariable(config[CONF_ID])
if on_join_config := config.get(CONF_ON_JOIN):
@@ -186,7 +193,6 @@ async def zephyr_to_code(config: ConfigType) -> None:
await cg.register_component(var, config)
await _attr_to_code(config)
CORE.add_job(_ctx_to_code, config)