From dc596bfa755830244519e9fdfd4a087d61e02764 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 9 Apr 2026 14:46:23 -1000 Subject: [PATCH] [core] Exclude entity_types.h from generated esphome.h The X-macro file requires ENTITY_TYPE_ and ENTITY_CONTROLLER_TYPE_ macros to be defined before inclusion. The generated esphome.h includes all .h files bare, which causes compilation errors. --- esphome/writer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/writer.py b/esphome/writer.py index 06a2230118..6bc4c456c3 100644 --- a/esphome/writer.py +++ b/esphome/writer.py @@ -196,9 +196,12 @@ def copy_src_tree(): source_files_l.sort() # Build #include list for esphome.h + # X-macro files are included multiple times with different macro definitions + # and must not be included bare in esphome.h + esphome_h_exclude = {Path("esphome/core/entity_types.h")} include_l = [] for target, _ in source_files_l: - if target.suffix in HEADER_FILE_EXTENSIONS: + if target.suffix in HEADER_FILE_EXTENSIONS and target not in esphome_h_exclude: include_l.append(f'#include "{target}"') include_l.append("") include_s = "\n".join(include_l)