[light] Undef LIGHT_CONTROL_FIELDS macro and assert <=16 fields

This commit is contained in:
J. Nick Koston
2026-04-26 21:54:33 -05:00
parent dae15301e1
commit 9a468eef8c
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -77,6 +77,7 @@ template<uint16_t Fields, typename... Ts> class LightControlAction : public Acti
#undef LIGHT_FIELD_APPLY_
#undef LIGHT_FIELD_SETTER_
};
#undef LIGHT_CONTROL_FIELDS
template<typename... Ts> class DimRelativeAction : public Action<Ts...> {
public:
+2
View File
@@ -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(