single func

This commit is contained in:
J. Nick Koston 2025-07-13 18:02:37 -10:00
parent 873f4125c5
commit 221f380ca3
No known key found for this signature in database
3 changed files with 149 additions and 109 deletions

View File

@ -186,7 +186,7 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->device_class); ProtoSize::add_string_field(total_size, 1, this->device_class);
@ -203,7 +203,7 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const { void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
@ -227,7 +227,7 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_bool_field(total_size, 1, this->assumed_state); ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
@ -249,10 +249,10 @@ void CoverStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(6, this->device_id); buffer.encode_uint32(6, this->device_id);
} }
void CoverStateResponse::calculate_size(uint32_t &total_size) const { void CoverStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_state)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_state));
ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f); ProtoSize::add_float_field(total_size, 1, this->position);
ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f); ProtoSize::add_float_field(total_size, 1, this->tilt);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -325,7 +325,7 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation); ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation);
@ -353,7 +353,7 @@ void FanStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(8, this->device_id); buffer.encode_uint32(8, this->device_id);
} }
void FanStateResponse::calculate_size(uint32_t &total_size) const { void FanStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->oscillating); ProtoSize::add_bool_field(total_size, 1, this->oscillating);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->speed)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->speed));
@ -462,7 +462,7 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
if (!this->supported_color_modes.empty()) { if (!this->supported_color_modes.empty()) {
@ -474,8 +474,8 @@ void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb); ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb);
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value); ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value);
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature); ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature);
ProtoSize::add_fixed_field<4>(total_size, 1, this->min_mireds != 0.0f); ProtoSize::add_float_field(total_size, 1, this->min_mireds);
ProtoSize::add_fixed_field<4>(total_size, 1, this->max_mireds != 0.0f); ProtoSize::add_float_field(total_size, 1, this->max_mireds);
if (!this->effects.empty()) { if (!this->effects.empty()) {
for (const auto &it : this->effects) { for (const auto &it : this->effects) {
ProtoSize::add_string_field_repeated(total_size, 1, it); ProtoSize::add_string_field_repeated(total_size, 1, it);
@ -503,18 +503,18 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(14, this->device_id); buffer.encode_uint32(14, this->device_id);
} }
void LightStateResponse::calculate_size(uint32_t &total_size) const { void LightStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->state);
ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f); ProtoSize::add_float_field(total_size, 1, this->brightness);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->color_mode)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->color_mode));
ProtoSize::add_fixed_field<4>(total_size, 1, this->color_brightness != 0.0f); ProtoSize::add_float_field(total_size, 1, this->color_brightness);
ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f); ProtoSize::add_float_field(total_size, 1, this->red);
ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f); ProtoSize::add_float_field(total_size, 1, this->green);
ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f); ProtoSize::add_float_field(total_size, 1, this->blue);
ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f); ProtoSize::add_float_field(total_size, 1, this->white);
ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f); ProtoSize::add_float_field(total_size, 1, this->color_temperature);
ProtoSize::add_fixed_field<4>(total_size, 1, this->cold_white != 0.0f); ProtoSize::add_float_field(total_size, 1, this->cold_white);
ProtoSize::add_fixed_field<4>(total_size, 1, this->warm_white != 0.0f); ProtoSize::add_float_field(total_size, 1, this->warm_white);
ProtoSize::add_string_field(total_size, 1, this->effect); ProtoSize::add_string_field(total_size, 1, this->effect);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -668,7 +668,7 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -689,8 +689,8 @@ void SensorStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void SensorStateResponse::calculate_size(uint32_t &total_size) const { void SensorStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f); ProtoSize::add_float_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -710,7 +710,7 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -726,7 +726,7 @@ void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(3, this->device_id); buffer.encode_uint32(3, this->device_id);
} }
void SwitchStateResponse::calculate_size(uint32_t &total_size) const { void SwitchStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -769,7 +769,7 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -785,7 +785,7 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void TextSensorStateResponse::calculate_size(uint32_t &total_size) const { void TextSensorStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->state); ProtoSize::add_string_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
@ -913,7 +913,7 @@ bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
} }
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); } void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
void GetTimeResponse::calculate_size(uint32_t &total_size) const { void GetTimeResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0); ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds);
} }
#ifdef USE_API_SERVICES #ifdef USE_API_SERVICES
bool ListEntitiesServicesArgument::decode_varint(uint32_t field_id, ProtoVarInt value) { bool ListEntitiesServicesArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
@ -953,7 +953,7 @@ void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_repeated_message(total_size, 1, this->args); ProtoSize::add_repeated_message(total_size, 1, this->args);
} }
bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) { bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
@ -1032,7 +1032,7 @@ void ExecuteServiceArgument::encode(ProtoWriteBuffer buffer) const {
void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const { void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const {
ProtoSize::add_bool_field(total_size, 1, this->bool_); ProtoSize::add_bool_field(total_size, 1, this->bool_);
ProtoSize::add_int32_field(total_size, 1, this->legacy_int); ProtoSize::add_int32_field(total_size, 1, this->legacy_int);
ProtoSize::add_fixed_field<4>(total_size, 1, this->float_ != 0.0f); ProtoSize::add_float_field(total_size, 1, this->float_);
ProtoSize::add_string_field(total_size, 1, this->string_); ProtoSize::add_string_field(total_size, 1, this->string_);
ProtoSize::add_sint32_field(total_size, 1, this->int_); ProtoSize::add_sint32_field(total_size, 1, this->int_);
if (!this->bool_array.empty()) { if (!this->bool_array.empty()) {
@ -1089,7 +1089,7 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
@ -1104,7 +1104,7 @@ void CameraImageResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void CameraImageResponse::calculate_size(uint32_t &total_size) const { void CameraImageResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->data); ProtoSize::add_string_field(total_size, 1, this->data);
ProtoSize::add_bool_field(total_size, 1, this->done); ProtoSize::add_bool_field(total_size, 1, this->done);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
@ -1167,7 +1167,7 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature); ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature);
@ -1177,9 +1177,9 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it)); ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
} }
} }
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_min_temperature != 0.0f); ProtoSize::add_float_field(total_size, 1, this->visual_min_temperature);
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_max_temperature != 0.0f); ProtoSize::add_float_field(total_size, 1, this->visual_max_temperature);
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_target_temperature_step != 0.0f); ProtoSize::add_float_field(total_size, 1, this->visual_target_temperature_step);
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away); ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away);
ProtoSize::add_bool_field(total_size, 1, this->supports_action); ProtoSize::add_bool_field(total_size, 1, this->supports_action);
if (!this->supported_fan_modes.empty()) { if (!this->supported_fan_modes.empty()) {
@ -1210,11 +1210,11 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_bool_field(total_size, 2, this->disabled_by_default); ProtoSize::add_bool_field(total_size, 2, this->disabled_by_default);
ProtoSize::add_string_field(total_size, 2, this->icon); ProtoSize::add_string_field(total_size, 2, this->icon);
ProtoSize::add_enum_field(total_size, 2, static_cast<uint32_t>(this->entity_category)); ProtoSize::add_enum_field(total_size, 2, static_cast<uint32_t>(this->entity_category));
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_current_temperature_step != 0.0f); ProtoSize::add_float_field(total_size, 2, this->visual_current_temperature_step);
ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity); ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity);
ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity); ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity);
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_min_humidity != 0.0f); ProtoSize::add_float_field(total_size, 2, this->visual_min_humidity);
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_max_humidity != 0.0f); ProtoSize::add_float_field(total_size, 2, this->visual_max_humidity);
ProtoSize::add_uint32_field(total_size, 2, this->device_id); ProtoSize::add_uint32_field(total_size, 2, this->device_id);
} }
void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const { void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
@ -1236,12 +1236,12 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(16, this->device_id); buffer.encode_uint32(16, this->device_id);
} }
void ClimateStateResponse::calculate_size(uint32_t &total_size) const { void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
ProtoSize::add_fixed_field<4>(total_size, 1, this->current_temperature != 0.0f); ProtoSize::add_float_field(total_size, 1, this->current_temperature);
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f); ProtoSize::add_float_field(total_size, 1, this->target_temperature);
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f); ProtoSize::add_float_field(total_size, 1, this->target_temperature_low);
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f); ProtoSize::add_float_field(total_size, 1, this->target_temperature_high);
ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away); ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->action)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->action));
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->fan_mode)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->fan_mode));
@ -1249,8 +1249,8 @@ void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode); ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->preset)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->preset));
ProtoSize::add_string_field(total_size, 1, this->custom_preset); ProtoSize::add_string_field(total_size, 1, this->custom_preset);
ProtoSize::add_fixed_field<4>(total_size, 1, this->current_humidity != 0.0f); ProtoSize::add_float_field(total_size, 1, this->current_humidity);
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_humidity != 0.0f); ProtoSize::add_float_field(total_size, 1, this->target_humidity);
ProtoSize::add_uint32_field(total_size, 2, this->device_id); ProtoSize::add_uint32_field(total_size, 2, this->device_id);
} }
bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
@ -1387,13 +1387,13 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
ProtoSize::add_fixed_field<4>(total_size, 1, this->min_value != 0.0f); ProtoSize::add_float_field(total_size, 1, this->min_value);
ProtoSize::add_fixed_field<4>(total_size, 1, this->max_value != 0.0f); ProtoSize::add_float_field(total_size, 1, this->max_value);
ProtoSize::add_fixed_field<4>(total_size, 1, this->step != 0.0f); ProtoSize::add_float_field(total_size, 1, this->step);
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default); ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement); ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
@ -1408,8 +1408,8 @@ void NumberStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void NumberStateResponse::calculate_size(uint32_t &total_size) const { void NumberStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f); ProtoSize::add_float_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -1454,7 +1454,7 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -1474,7 +1474,7 @@ void SelectStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void SelectStateResponse::calculate_size(uint32_t &total_size) const { void SelectStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->state); ProtoSize::add_string_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
@ -1528,7 +1528,7 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -1549,7 +1549,7 @@ void SirenStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(3, this->device_id); buffer.encode_uint32(3, this->device_id);
} }
void SirenStateResponse::calculate_size(uint32_t &total_size) const { void SirenStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state); ProtoSize::add_bool_field(total_size, 1, this->state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -1629,7 +1629,7 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -1647,7 +1647,7 @@ void LockStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(3, this->device_id); buffer.encode_uint32(3, this->device_id);
} }
void LockStateResponse::calculate_size(uint32_t &total_size) const { void LockStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -1704,7 +1704,7 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -1797,7 +1797,7 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -1815,9 +1815,9 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(5, this->device_id); buffer.encode_uint32(5, this->device_id);
} }
void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const { void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f); ProtoSize::add_float_field(total_size, 1, this->volume);
ProtoSize::add_bool_field(total_size, 1, this->muted); ProtoSize::add_bool_field(total_size, 1, this->muted);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -2443,7 +2443,7 @@ void VoiceAssistantAudioSettings::encode(ProtoWriteBuffer buffer) const {
void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const { void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const {
ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level); ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level);
ProtoSize::add_uint32_field(total_size, 1, this->auto_gain); ProtoSize::add_uint32_field(total_size, 1, this->auto_gain);
ProtoSize::add_fixed_field<4>(total_size, 1, this->volume_multiplier != 0.0f); ProtoSize::add_float_field(total_size, 1, this->volume_multiplier);
} }
void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const { void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const {
buffer.encode_bool(1, this->start); buffer.encode_bool(1, this->start);
@ -2691,7 +2691,7 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons
} }
void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -2708,7 +2708,7 @@ void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(3, this->device_id); buffer.encode_uint32(3, this->device_id);
} }
void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const { void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -2764,7 +2764,7 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -2783,7 +2783,7 @@ void TextStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void TextStateResponse::calculate_size(uint32_t &total_size) const { void TextStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->state); ProtoSize::add_string_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
@ -2832,7 +2832,7 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -2849,7 +2849,7 @@ void DateStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(6, this->device_id); buffer.encode_uint32(6, this->device_id);
} }
void DateStateResponse::calculate_size(uint32_t &total_size) const { void DateStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->year); ProtoSize::add_uint32_field(total_size, 1, this->year);
ProtoSize::add_uint32_field(total_size, 1, this->month); ProtoSize::add_uint32_field(total_size, 1, this->month);
@ -2902,7 +2902,7 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -2919,7 +2919,7 @@ void TimeStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(6, this->device_id); buffer.encode_uint32(6, this->device_id);
} }
void TimeStateResponse::calculate_size(uint32_t &total_size) const { void TimeStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_uint32_field(total_size, 1, this->hour); ProtoSize::add_uint32_field(total_size, 1, this->hour);
ProtoSize::add_uint32_field(total_size, 1, this->minute); ProtoSize::add_uint32_field(total_size, 1, this->minute);
@ -2976,7 +2976,7 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -2996,7 +2996,7 @@ void EventResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(3, this->device_id); buffer.encode_uint32(3, this->device_id);
} }
void EventResponse::calculate_size(uint32_t &total_size) const { void EventResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->event_type); ProtoSize::add_string_field(total_size, 1, this->event_type);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -3018,7 +3018,7 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -3037,8 +3037,8 @@ void ValveStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void ValveStateResponse::calculate_size(uint32_t &total_size) const { void ValveStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f); ProtoSize::add_float_field(total_size, 1, this->position);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation)); ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
@ -3088,7 +3088,7 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -3103,9 +3103,9 @@ void DateTimeStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(4, this->device_id); buffer.encode_uint32(4, this->device_id);
} }
void DateTimeStateResponse::calculate_size(uint32_t &total_size) const { void DateTimeStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0); ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds);
ProtoSize::add_uint32_field(total_size, 1, this->device_id); ProtoSize::add_uint32_field(total_size, 1, this->device_id);
} }
bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
@ -3147,7 +3147,7 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const {
} }
void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const { void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id); ProtoSize::add_string_field(total_size, 1, this->object_id);
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->name); ProtoSize::add_string_field(total_size, 1, this->name);
ProtoSize::add_string_field(total_size, 1, this->unique_id); ProtoSize::add_string_field(total_size, 1, this->unique_id);
ProtoSize::add_string_field(total_size, 1, this->icon); ProtoSize::add_string_field(total_size, 1, this->icon);
@ -3170,11 +3170,11 @@ void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(11, this->device_id); buffer.encode_uint32(11, this->device_id);
} }
void UpdateStateResponse::calculate_size(uint32_t &total_size) const { void UpdateStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->missing_state); ProtoSize::add_bool_field(total_size, 1, this->missing_state);
ProtoSize::add_bool_field(total_size, 1, this->in_progress); ProtoSize::add_bool_field(total_size, 1, this->in_progress);
ProtoSize::add_bool_field(total_size, 1, this->has_progress); ProtoSize::add_bool_field(total_size, 1, this->has_progress);
ProtoSize::add_fixed_field<4>(total_size, 1, this->progress != 0.0f); ProtoSize::add_float_field(total_size, 1, this->progress);
ProtoSize::add_string_field(total_size, 1, this->current_version); ProtoSize::add_string_field(total_size, 1, this->current_version);
ProtoSize::add_string_field(total_size, 1, this->latest_version); ProtoSize::add_string_field(total_size, 1, this->latest_version);
ProtoSize::add_string_field(total_size, 1, this->title); ProtoSize::add_string_field(total_size, 1, this->title);

View File

@ -566,6 +566,60 @@ class ProtoSize {
total_size += field_id_size + NumBytes; total_size += field_id_size + NumBytes;
} }
/**
* @brief Calculates and adds the size of a float field to the total message size
*/
static inline void add_float_field(uint32_t &total_size, uint32_t field_id_size, float value) {
if (value != 0.0f) {
total_size += field_id_size + 4;
}
}
/**
* @brief Calculates and adds the size of a double field to the total message size
*/
static inline void add_double_field(uint32_t &total_size, uint32_t field_id_size, double value) {
if (value != 0.0) {
total_size += field_id_size + 8;
}
}
/**
* @brief Calculates and adds the size of a fixed32 field to the total message size
*/
static inline void add_fixed32_field(uint32_t &total_size, uint32_t field_id_size, uint32_t value) {
if (value != 0) {
total_size += field_id_size + 4;
}
}
/**
* @brief Calculates and adds the size of a fixed64 field to the total message size
*/
static inline void add_fixed64_field(uint32_t &total_size, uint32_t field_id_size, uint64_t value) {
if (value != 0) {
total_size += field_id_size + 8;
}
}
/**
* @brief Calculates and adds the size of a sfixed32 field to the total message size
*/
static inline void add_sfixed32_field(uint32_t &total_size, uint32_t field_id_size, int32_t value) {
if (value != 0) {
total_size += field_id_size + 4;
}
}
/**
* @brief Calculates and adds the size of a sfixed64 field to the total message size
*/
static inline void add_sfixed64_field(uint32_t &total_size, uint32_t field_id_size, int64_t value) {
if (value != 0) {
total_size += field_id_size + 8;
}
}
/** /**
* @brief Calculates and adds the size of an enum field to the total message size * @brief Calculates and adds the size of an enum field to the total message size
* *

View File

@ -265,26 +265,6 @@ class TypeInfo(ABC):
value = value_expr if value_expr else name value = value_expr if value_expr else name
return f"ProtoSize::{method}(total_size, {field_id_size}, {value});" return f"ProtoSize::{method}(total_size, {field_id_size}, {value});"
def _get_fixed_size_calculation(
self, name: str, force: bool, num_bytes: int, zero_check: str
) -> str:
"""Helper for fixed-size field calculations.
Args:
name: Field name
force: Whether this is for a repeated field
num_bytes: Number of bytes (4 or 8)
zero_check: Expression to check for zero value (e.g., "!= 0.0f")
"""
field_id_size = self.calculate_field_id_size()
# Fixed-size repeated fields are handled differently in RepeatedTypeInfo
# so we should never get force=True here
assert not force, (
"Fixed-size repeated fields should be handled by RepeatedTypeInfo"
)
method = f"add_fixed_field<{num_bytes}>"
return f"ProtoSize::{method}(total_size, {field_id_size}, {name} {zero_check});"
@abstractmethod @abstractmethod
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
"""Calculate the size needed for encoding this field. """Calculate the size needed for encoding this field.
@ -339,7 +319,8 @@ class DoubleType(TypeInfo):
return o return o
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
return self._get_fixed_size_calculation(name, force, 8, "!= 0.0") field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_double_field(total_size, {field_id_size}, {name});"
def get_fixed_size_bytes(self) -> int: def get_fixed_size_bytes(self) -> int:
return 8 return 8
@ -362,7 +343,8 @@ class FloatType(TypeInfo):
return o return o
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
return self._get_fixed_size_calculation(name, force, 4, "!= 0.0f") field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_float_field(total_size, {field_id_size}, {name});"
def get_fixed_size_bytes(self) -> int: def get_fixed_size_bytes(self) -> int:
return 4 return 4
@ -445,7 +427,8 @@ class Fixed64Type(TypeInfo):
return o return o
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
return self._get_fixed_size_calculation(name, force, 8, "!= 0") field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_fixed64_field(total_size, {field_id_size}, {name});"
def get_fixed_size_bytes(self) -> int: def get_fixed_size_bytes(self) -> int:
return 8 return 8
@ -468,7 +451,8 @@ class Fixed32Type(TypeInfo):
return o return o
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
return self._get_fixed_size_calculation(name, force, 4, "!= 0") field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_fixed32_field(total_size, {field_id_size}, {name});"
def get_fixed_size_bytes(self) -> int: def get_fixed_size_bytes(self) -> int:
return 4 return 4
@ -663,7 +647,8 @@ class SFixed32Type(TypeInfo):
return o return o
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
return self._get_fixed_size_calculation(name, force, 4, "!= 0") field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_sfixed32_field(total_size, {field_id_size}, {name});"
def get_fixed_size_bytes(self) -> int: def get_fixed_size_bytes(self) -> int:
return 4 return 4
@ -686,7 +671,8 @@ class SFixed64Type(TypeInfo):
return o return o
def get_size_calculation(self, name: str, force: bool = False) -> str: def get_size_calculation(self, name: str, force: bool = False) -> str:
return self._get_fixed_size_calculation(name, force, 8, "!= 0") field_id_size = self.calculate_field_id_size()
return f"ProtoSize::add_sfixed64_field(total_size, {field_id_size}, {name});"
def get_fixed_size_bytes(self) -> int: def get_fixed_size_bytes(self) -> int:
return 8 return 8