diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index cf03f48be8..702208d9de 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -468,7 +468,8 @@ class ProtoMessage { virtual const char *message_name() const { return "unknown"; } #endif - // Non-virtual: messages are never deleted polymorphically. + protected: + // Non-virtual destructor is protected to prevent polymorphic deletion. ~ProtoMessage() = default; }; diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index b00cbab37a..85352689e6 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -280,6 +280,9 @@ class TypeInfo(ABC): """ field_id_size = self.calculate_field_id_size() method = f"calc_{base_method}_force" if force else f"calc_{base_method}" + # calc_bool_force only takes field_id_size (no value needed - bool is always 1 byte) + if base_method == "bool" and force: + return f"size += ProtoSize::{method}({field_id_size});" value = value_expr or name return f"size += ProtoSize::{method}({field_id_size}, {value});"