diff --git a/esphome/components/light/automation.h b/esphome/components/light/automation.h index 817c0e3296..eda30bd786 100644 --- a/esphome/components/light/automation.h +++ b/esphome/components/light/automation.h @@ -77,6 +77,7 @@ template class LightControlAction : public Acti #undef LIGHT_FIELD_APPLY_ #undef LIGHT_FIELD_SETTER_ }; +#undef LIGHT_CONTROL_FIELDS template class DimRelativeAction : public Action { public: diff --git a/esphome/components/light/automation.py b/esphome/components/light/automation.py index 1062d6de3a..ea953e3199 100644 --- a/esphome/components/light/automation.py +++ b/esphome/components/light/automation.py @@ -197,6 +197,8 @@ async def light_control_to_code(config, action_id, template_arg, args): (CONF_WARM_WHITE, "set_warm_white", cg.float_), (CONF_EFFECT, None, cg.uint32), ) + # Bitmask is passed as uint16_t in C++ — must stay within 16 bits. + assert len(FIELDS) <= 16, "LightControlAction Fields bitmask exceeds uint16_t" field_mask = sum(1 << i for i, (k, _, _) in enumerate(FIELDS) if k in config) control_template_arg = cg.TemplateArguments(