From 05a4b256db293908d68ccd6f50198558c3dbf02b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Oct 2026 11:45:47 -1000 Subject: [PATCH] Reject an unknown publish= value --- esphome/core/entity_helpers.py | 2 ++ tests/unit_tests/core/test_entity_helpers.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/esphome/core/entity_helpers.py b/esphome/core/entity_helpers.py index 2742c636c07..aeb36c267be 100644 --- a/esphome/core/entity_helpers.py +++ b/esphome/core/entity_helpers.py @@ -559,6 +559,8 @@ class SubEntities: raise ValueError(f"{entity_id}: apply= needs a parent") if publish is not None and (apply is None or self.apply_entity.publish is None): raise ValueError(f"{entity_id}: publish= needs apply= on a stateful domain") + if publish not in (None, "before", "after"): + raise ValueError(f'{entity_id}: publish= must be "before" or "after"') if apply is None: var = await self.new_entity(conf, *args, **kwargs) diff --git a/tests/unit_tests/core/test_entity_helpers.py b/tests/unit_tests/core/test_entity_helpers.py index bd754ca6620..7d6d7960429 100644 --- a/tests/unit_tests/core/test_entity_helpers.py +++ b/tests/unit_tests/core/test_entity_helpers.py @@ -1458,6 +1458,12 @@ async def test_sub_entities_apply_parent_id( {"publish": "before"}, "publish= needs", ), + ( + _SWITCH_APPLY, + _apply_conf("k_id"), + {"apply": "x()", "publish": "Before"}, + "must be", + ), ], ) async def test_sub_entities_apply_errors(