diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 90e5bcb548..b5d8bb3d79 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1,6 +1,7 @@ // This file was automatically generated with a tool. -// See scripts/api_protobuf/api_protobuf.py +// See script/api_protobuf/api_protobuf.py #include "api_pb2.h" +#include "api_pb2_size.h" #include "esphome/core/log.h" #include @@ -654,6 +655,11 @@ void HelloRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, this->api_version_major); buffer.encode_uint32(3, this->api_version_minor); } +void HelloRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->client_info, false); + ProtoSize::add_uint32_field(total_size, 1, this->api_version_major, false); + ProtoSize::add_uint32_field(total_size, 1, this->api_version_minor, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void HelloRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -708,6 +714,12 @@ void HelloResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(3, this->server_info); buffer.encode_string(4, this->name); } +void HelloResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint32_field(total_size, 1, this->api_version_major, false); + ProtoSize::add_uint32_field(total_size, 1, this->api_version_minor, false); + ProtoSize::add_string_field(total_size, 1, this->server_info, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void HelloResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -743,6 +755,9 @@ bool ConnectRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value } } void ConnectRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->password); } +void ConnectRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->password, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ConnectRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -764,6 +779,9 @@ bool ConnectResponse::decode_varint(uint32_t field_id, ProtoVarInt value) { } } void ConnectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->invalid_password); } +void ConnectResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->invalid_password, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ConnectResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -775,22 +793,27 @@ void ConnectResponse::dump_to(std::string &out) const { } #endif void DisconnectRequest::encode(ProtoWriteBuffer buffer) const {} +void DisconnectRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void DisconnectRequest::dump_to(std::string &out) const { out.append("DisconnectRequest {}"); } #endif void DisconnectResponse::encode(ProtoWriteBuffer buffer) const {} +void DisconnectResponse::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void DisconnectResponse::dump_to(std::string &out) const { out.append("DisconnectResponse {}"); } #endif void PingRequest::encode(ProtoWriteBuffer buffer) const {} +void PingRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void PingRequest::dump_to(std::string &out) const { out.append("PingRequest {}"); } #endif void PingResponse::encode(ProtoWriteBuffer buffer) const {} +void PingResponse::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void PingResponse::dump_to(std::string &out) const { out.append("PingResponse {}"); } #endif void DeviceInfoRequest::encode(ProtoWriteBuffer buffer) const {} +void DeviceInfoRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void DeviceInfoRequest::dump_to(std::string &out) const { out.append("DeviceInfoRequest {}"); } #endif @@ -903,6 +926,27 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(18, this->bluetooth_mac_address); buffer.encode_bool(19, this->api_encryption_supported); } +void DeviceInfoResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->uses_password, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->mac_address, false); + ProtoSize::add_string_field(total_size, 1, this->esphome_version, false); + ProtoSize::add_string_field(total_size, 1, this->compilation_time, false); + ProtoSize::add_string_field(total_size, 1, this->model, false); + ProtoSize::add_bool_field(total_size, 1, this->has_deep_sleep, false); + ProtoSize::add_string_field(total_size, 1, this->project_name, false); + ProtoSize::add_string_field(total_size, 1, this->project_version, false); + ProtoSize::add_uint32_field(total_size, 1, this->webserver_port, false); + ProtoSize::add_uint32_field(total_size, 1, this->legacy_bluetooth_proxy_version, false); + ProtoSize::add_uint32_field(total_size, 1, this->bluetooth_proxy_feature_flags, false); + ProtoSize::add_string_field(total_size, 1, this->manufacturer, false); + ProtoSize::add_string_field(total_size, 1, this->friendly_name, false); + ProtoSize::add_uint32_field(total_size, 1, this->legacy_voice_assistant_version, false); + ProtoSize::add_uint32_field(total_size, 2, this->voice_assistant_feature_flags, false); + ProtoSize::add_string_field(total_size, 2, this->suggested_area, false); + ProtoSize::add_string_field(total_size, 2, this->bluetooth_mac_address, false); + ProtoSize::add_bool_field(total_size, 2, this->api_encryption_supported, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void DeviceInfoResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -991,14 +1035,17 @@ void DeviceInfoResponse::dump_to(std::string &out) const { } #endif void ListEntitiesRequest::encode(ProtoWriteBuffer buffer) const {} +void ListEntitiesRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesRequest::dump_to(std::string &out) const { out.append("ListEntitiesRequest {}"); } #endif void ListEntitiesDoneResponse::encode(ProtoWriteBuffer buffer) const {} +void ListEntitiesDoneResponse::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesDoneResponse::dump_to(std::string &out) const { out.append("ListEntitiesDoneResponse {}"); } #endif void SubscribeStatesRequest::encode(ProtoWriteBuffer buffer) const {} +void SubscribeStatesRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeStatesRequest::dump_to(std::string &out) const { out.append("SubscribeStatesRequest {}"); } #endif @@ -1067,6 +1114,17 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(8, this->icon); buffer.encode_enum(9, this->entity_category); } +void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); + ProtoSize::add_bool_field(total_size, 1, this->is_status_binary_sensor, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesBinarySensorResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1139,6 +1197,11 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(2, this->state); buffer.encode_bool(3, this->missing_state); } +void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BinarySensorStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1238,6 +1301,20 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(11, this->entity_category); buffer.encode_bool(12, this->supports_stop); } +void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_bool_field(total_size, 1, this->assumed_state, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_position, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_tilt, false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_bool_field(total_size, 1, this->supports_stop, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesCoverResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1332,6 +1409,13 @@ void CoverStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(4, this->tilt); buffer.encode_enum(5, this->current_operation); } +void CoverStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->legacy_state), false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->current_operation), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void CoverStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1415,6 +1499,16 @@ void CoverCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(7, this->tilt); buffer.encode_bool(8, this->stop); } +void CoverCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->has_legacy_command, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->legacy_command), false); + ProtoSize::add_bool_field(total_size, 1, this->has_position, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_tilt, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->stop, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void CoverCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1538,6 +1632,24 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(12, it, true); } } +void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_speed, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_direction, false); + ProtoSize::add_int32_field(total_size, 1, this->supported_speed_count, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + if (!this->supported_preset_modes.empty()) { + for (const auto &it : this->supported_preset_modes) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesFanResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1651,6 +1763,15 @@ void FanStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_int32(6, this->speed_level); buffer.encode_string(7, this->preset_mode); } +void FanStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->oscillating, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->speed), false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->direction), false); + ProtoSize::add_int32_field(total_size, 1, this->speed_level, false); + ProtoSize::add_string_field(total_size, 1, this->preset_mode, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void FanStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1772,6 +1893,21 @@ void FanCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(12, this->has_preset_mode); buffer.encode_string(13, this->preset_mode); } +void FanCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->has_state, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->has_speed, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->speed), false); + ProtoSize::add_bool_field(total_size, 1, this->has_oscillating, false); + ProtoSize::add_bool_field(total_size, 1, this->oscillating, false); + ProtoSize::add_bool_field(total_size, 1, this->has_direction, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->direction), false); + ProtoSize::add_bool_field(total_size, 1, this->has_speed_level, false); + ProtoSize::add_int32_field(total_size, 1, this->speed_level, false); + ProtoSize::add_bool_field(total_size, 1, this->has_preset_mode, false); + ProtoSize::add_string_field(total_size, 1, this->preset_mode, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void FanCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -1931,6 +2067,31 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(14, this->icon); buffer.encode_enum(15, this->entity_category); } +void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + if (!this->supported_color_modes.empty()) { + for (const auto &it : this->supported_color_modes) { + ProtoSize::add_enum_field(total_size, 1, static_cast(it), true); + } + } + ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_brightness, false); + ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb, false); + ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value, false); + ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->min_mireds != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->max_mireds != 0.0f, false); + if (!this->effects.empty()) { + for (const auto &it : this->effects) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesLightResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2089,6 +2250,21 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(13, this->warm_white); buffer.encode_string(9, this->effect); } +void LightStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->color_mode), false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->color_brightness != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->cold_white != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->warm_white != 0.0f, false); + ProtoSize::add_string_field(total_size, 1, this->effect, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void LightStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2312,6 +2488,35 @@ void LightCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(18, this->has_effect); buffer.encode_string(19, this->effect); } +void LightCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->has_state, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->has_brightness, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f, false); + ProtoSize::add_bool_field(total_size, 2, this->has_color_mode, false); + ProtoSize::add_enum_field(total_size, 2, static_cast(this->color_mode), false); + ProtoSize::add_bool_field(total_size, 2, this->has_color_brightness, false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->color_brightness != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_rgb, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_white, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_color_temperature, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f, false); + ProtoSize::add_bool_field(total_size, 2, this->has_cold_white, false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->cold_white != 0.0f, false); + ProtoSize::add_bool_field(total_size, 2, this->has_warm_white, false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->warm_white != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_transition_length, false); + ProtoSize::add_uint32_field(total_size, 1, this->transition_length, false); + ProtoSize::add_bool_field(total_size, 2, this->has_flash_length, false); + ProtoSize::add_uint32_field(total_size, 2, this->flash_length, false); + ProtoSize::add_bool_field(total_size, 2, this->has_effect, false); + ProtoSize::add_string_field(total_size, 2, this->effect, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void LightCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2523,6 +2728,21 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(12, this->disabled_by_default); buffer.encode_enum(13, this->entity_category); } +void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement, false); + ProtoSize::add_int32_field(total_size, 1, this->accuracy_decimals, false); + ProtoSize::add_bool_field(total_size, 1, this->force_update, false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->state_class), false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->legacy_last_reset_type), false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesSensorResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2612,6 +2832,11 @@ void SensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(2, this->state); buffer.encode_bool(3, this->missing_state); } +void SensorStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SensorStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2697,6 +2922,17 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(8, this->entity_category); buffer.encode_string(9, this->device_class); } +void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->assumed_state, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesSwitchResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2764,6 +3000,10 @@ void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bool(2, this->state); } +void SwitchStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SwitchStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2803,6 +3043,10 @@ void SwitchCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_bool(2, this->state); } +void SwitchCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SwitchCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2878,6 +3122,16 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(7, this->entity_category); buffer.encode_string(8, this->device_class); } +void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesTextSensorResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2952,6 +3206,11 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); } +void TextSensorStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void TextSensorStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -2989,6 +3248,10 @@ void SubscribeLogsRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(1, this->level); buffer.encode_bool(2, this->dump_config); } +void SubscribeLogsRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_enum_field(total_size, 1, static_cast(this->level), false); + ProtoSize::add_bool_field(total_size, 1, this->dump_config, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeLogsRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3032,6 +3295,11 @@ void SubscribeLogsResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(3, this->message); buffer.encode_bool(4, this->send_failed); } +void SubscribeLogsResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_enum_field(total_size, 1, static_cast(this->level), false); + ProtoSize::add_string_field(total_size, 1, this->message, false); + ProtoSize::add_bool_field(total_size, 1, this->send_failed, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeLogsResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3061,6 +3329,9 @@ bool NoiseEncryptionSetKeyRequest::decode_length(uint32_t field_id, ProtoLengthD } } void NoiseEncryptionSetKeyRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->key); } +void NoiseEncryptionSetKeyRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->key, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void NoiseEncryptionSetKeyRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3082,6 +3353,9 @@ bool NoiseEncryptionSetKeyResponse::decode_varint(uint32_t field_id, ProtoVarInt } } void NoiseEncryptionSetKeyResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); } +void NoiseEncryptionSetKeyResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->success, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void NoiseEncryptionSetKeyResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3093,6 +3367,7 @@ void NoiseEncryptionSetKeyResponse::dump_to(std::string &out) const { } #endif void SubscribeHomeassistantServicesRequest::encode(ProtoWriteBuffer buffer) const {} +void SubscribeHomeassistantServicesRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeHomeassistantServicesRequest::dump_to(std::string &out) const { out.append("SubscribeHomeassistantServicesRequest {}"); @@ -3116,6 +3391,10 @@ void HomeassistantServiceMap::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->key); buffer.encode_string(2, this->value); } +void HomeassistantServiceMap::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->key, false); + ProtoSize::add_string_field(total_size, 1, this->value, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void HomeassistantServiceMap::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3175,6 +3454,13 @@ void HomeassistantServiceResponse::encode(ProtoWriteBuffer buffer) const { } buffer.encode_bool(5, this->is_event); } +void HomeassistantServiceResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->service, false); + ProtoSize::add_repeated_message(total_size, 1, this->data); + ProtoSize::add_repeated_message(total_size, 1, this->data_template); + ProtoSize::add_repeated_message(total_size, 1, this->variables); + ProtoSize::add_bool_field(total_size, 1, this->is_event, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void HomeassistantServiceResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3208,6 +3494,7 @@ void HomeassistantServiceResponse::dump_to(std::string &out) const { } #endif void SubscribeHomeAssistantStatesRequest::encode(ProtoWriteBuffer buffer) const {} +void SubscribeHomeAssistantStatesRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeHomeAssistantStatesRequest::dump_to(std::string &out) const { out.append("SubscribeHomeAssistantStatesRequest {}"); @@ -3242,6 +3529,11 @@ void SubscribeHomeAssistantStateResponse::encode(ProtoWriteBuffer buffer) const buffer.encode_string(2, this->attribute); buffer.encode_bool(3, this->once); } +void SubscribeHomeAssistantStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->entity_id, false); + ProtoSize::add_string_field(total_size, 1, this->attribute, false); + ProtoSize::add_bool_field(total_size, 1, this->once, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeHomeAssistantStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3283,6 +3575,11 @@ void HomeAssistantStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(2, this->state); buffer.encode_string(3, this->attribute); } +void HomeAssistantStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->entity_id, false); + ProtoSize::add_string_field(total_size, 1, this->state, false); + ProtoSize::add_string_field(total_size, 1, this->attribute, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void HomeAssistantStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3302,6 +3599,7 @@ void HomeAssistantStateResponse::dump_to(std::string &out) const { } #endif void GetTimeRequest::encode(ProtoWriteBuffer buffer) const {} +void GetTimeRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void GetTimeRequest::dump_to(std::string &out) const { out.append("GetTimeRequest {}"); } #endif @@ -3316,6 +3614,9 @@ 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::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void GetTimeResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3351,6 +3652,10 @@ void ListEntitiesServicesArgument::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->name); buffer.encode_enum(2, this->type); } +void ListEntitiesServicesArgument::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->type), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesServicesArgument::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3396,6 +3701,11 @@ void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(3, it, true); } } +void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_repeated_message(total_size, 1, this->args); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesServicesResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3490,6 +3800,33 @@ void ExecuteServiceArgument::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(9, it, true); } } +void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->bool_, false); + ProtoSize::add_int32_field(total_size, 1, this->legacy_int, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->float_ != 0.0f, false); + ProtoSize::add_string_field(total_size, 1, this->string_, false); + ProtoSize::add_sint32_field(total_size, 1, this->int_, false); + if (!this->bool_array.empty()) { + for (const auto it : this->bool_array) { + ProtoSize::add_bool_field(total_size, 1, it, true); + } + } + if (!this->int_array.empty()) { + for (const auto &it : this->int_array) { + ProtoSize::add_sint32_field(total_size, 1, it, true); + } + } + if (!this->float_array.empty()) { + for (const auto &it : this->float_array) { + ProtoSize::add_fixed_field<4>(total_size, 1, it != 0.0f, true); + } + } + if (!this->string_array.empty()) { + for (const auto &it : this->string_array) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } +} #ifdef HAS_PROTO_MESSAGE_DUMP void ExecuteServiceArgument::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3571,6 +3908,10 @@ void ExecuteServiceRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(2, it, true); } } +void ExecuteServiceRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_repeated_message(total_size, 1, this->args); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ExecuteServiceRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3643,6 +3984,15 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(6, this->icon); buffer.encode_enum(7, this->entity_category); } +void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesCameraResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3713,6 +4063,11 @@ void CameraImageResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(2, this->data); buffer.encode_bool(3, this->done); } +void CameraImageResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->data, false); + ProtoSize::add_bool_field(total_size, 1, this->done, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void CameraImageResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3750,6 +4105,10 @@ void CameraImageRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->single); buffer.encode_bool(2, this->stream); } +void CameraImageRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->single, false); + ProtoSize::add_bool_field(total_size, 1, this->stream, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void CameraImageRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -3921,6 +4280,57 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(24, this->visual_min_humidity); buffer.encode_float(25, this->visual_max_humidity); } +void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_two_point_target_temperature, false); + if (!this->supported_modes.empty()) { + for (const auto &it : this->supported_modes) { + ProtoSize::add_enum_field(total_size, 1, static_cast(it), true); + } + } + ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_min_temperature != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_max_temperature != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_target_temperature_step != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_action, false); + if (!this->supported_fan_modes.empty()) { + for (const auto &it : this->supported_fan_modes) { + ProtoSize::add_enum_field(total_size, 1, static_cast(it), true); + } + } + if (!this->supported_swing_modes.empty()) { + for (const auto &it : this->supported_swing_modes) { + ProtoSize::add_enum_field(total_size, 1, static_cast(it), true); + } + } + if (!this->supported_custom_fan_modes.empty()) { + for (const auto &it : this->supported_custom_fan_modes) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } + if (!this->supported_presets.empty()) { + for (const auto &it : this->supported_presets) { + ProtoSize::add_enum_field(total_size, 2, static_cast(it), true); + } + } + if (!this->supported_custom_presets.empty()) { + for (const auto &it : this->supported_custom_presets) { + ProtoSize::add_string_field(total_size, 2, it, true); + } + } + ProtoSize::add_bool_field(total_size, 2, this->disabled_by_default, false); + ProtoSize::add_string_field(total_size, 2, this->icon, false); + ProtoSize::add_enum_field(total_size, 2, static_cast(this->entity_category), false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_current_temperature_step != 0.0f, false); + ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity, false); + ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity, false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_min_humidity != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_max_humidity != 0.0f, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesClimateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4141,6 +4551,23 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(14, this->current_humidity); buffer.encode_float(15, this->target_humidity); } +void ClimateStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode), false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->current_temperature != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->action), false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->fan_mode), false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->swing_mode), false); + ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->preset), false); + ProtoSize::add_string_field(total_size, 1, this->custom_preset, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->current_humidity != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_humidity != 0.0f, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ClimateStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4349,6 +4776,31 @@ void ClimateCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(22, this->has_target_humidity); buffer.encode_float(23, this->target_humidity); } +void ClimateCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->has_mode, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode), false); + ProtoSize::add_bool_field(total_size, 1, this->has_target_temperature, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_target_temperature_low, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_target_temperature_high, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->unused_has_legacy_away, false); + ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away, false); + ProtoSize::add_bool_field(total_size, 1, this->has_fan_mode, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->fan_mode), false); + ProtoSize::add_bool_field(total_size, 1, this->has_swing_mode, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->swing_mode), false); + ProtoSize::add_bool_field(total_size, 2, this->has_custom_fan_mode, false); + ProtoSize::add_string_field(total_size, 2, this->custom_fan_mode, false); + ProtoSize::add_bool_field(total_size, 2, this->has_preset, false); + ProtoSize::add_enum_field(total_size, 2, static_cast(this->preset), false); + ProtoSize::add_bool_field(total_size, 2, this->has_custom_preset, false); + ProtoSize::add_string_field(total_size, 2, this->custom_preset, false); + ProtoSize::add_bool_field(total_size, 2, this->has_target_humidity, false); + ProtoSize::add_fixed_field<4>(total_size, 2, this->target_humidity != 0.0f, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ClimateCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4537,6 +4989,21 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(12, this->mode); buffer.encode_string(13, this->device_class); } +void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->min_value != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->max_value != 0.0f, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->step != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesNumberResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4628,6 +5095,11 @@ void NumberStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(2, this->state); buffer.encode_bool(3, this->missing_state); } +void NumberStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void NumberStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4666,6 +5138,10 @@ void NumberCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_float(2, this->state); } +void NumberCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void NumberCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4744,6 +5220,20 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(7, this->disabled_by_default); buffer.encode_enum(8, this->entity_category); } +void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + if (!this->options.empty()) { + for (const auto &it : this->options) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesSelectResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4820,6 +5310,11 @@ void SelectStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); } +void SelectStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SelectStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4863,6 +5358,10 @@ void SelectCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->state); } +void SelectCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SelectCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -4953,6 +5452,19 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(10, this->requires_code); buffer.encode_string(11, this->code_format); } +void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_bool_field(total_size, 1, this->assumed_state, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_open, false); + ProtoSize::add_bool_field(total_size, 1, this->requires_code, false); + ProtoSize::add_string_field(total_size, 1, this->code_format, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesLockResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5028,6 +5540,10 @@ void LockStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_enum(2, this->state); } +void LockStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->state), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void LockStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5083,6 +5599,12 @@ void LockCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(3, this->has_code); buffer.encode_string(4, this->code); } +void LockCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->command), false); + ProtoSize::add_bool_field(total_size, 1, this->has_code, false); + ProtoSize::add_string_field(total_size, 1, this->code, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void LockCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5166,6 +5688,16 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(7, this->entity_category); buffer.encode_string(8, this->device_class); } +void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesButtonResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5216,6 +5748,9 @@ bool ButtonCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { } } void ButtonCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); } +void ButtonCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ButtonCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5266,6 +5801,13 @@ void MediaPlayerSupportedFormat::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(4, this->purpose); buffer.encode_uint32(5, this->sample_bytes); } +void MediaPlayerSupportedFormat::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->format, false); + ProtoSize::add_uint32_field(total_size, 1, this->sample_rate, false); + ProtoSize::add_uint32_field(total_size, 1, this->num_channels, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->purpose), false); + ProtoSize::add_uint32_field(total_size, 1, this->sample_bytes, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void MediaPlayerSupportedFormat::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5362,6 +5904,17 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(9, it, true); } } +void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_bool_field(total_size, 1, this->supports_pause, false); + ProtoSize::add_repeated_message(total_size, 1, this->supported_formats); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5441,6 +5994,12 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(3, this->volume); buffer.encode_bool(4, this->muted); } +void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->state), false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->muted, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void MediaPlayerStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5530,6 +6089,17 @@ void MediaPlayerCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(8, this->has_announcement); buffer.encode_bool(9, this->announcement); } +void MediaPlayerCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->has_command, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->command), false); + ProtoSize::add_bool_field(total_size, 1, this->has_volume, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->has_media_url, false); + ProtoSize::add_string_field(total_size, 1, this->media_url, false); + ProtoSize::add_bool_field(total_size, 1, this->has_announcement, false); + ProtoSize::add_bool_field(total_size, 1, this->announcement, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void MediaPlayerCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5587,6 +6157,9 @@ bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, void SubscribeBluetoothLEAdvertisementsRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->flags); } +void SubscribeBluetoothLEAdvertisementsRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint32_field(total_size, 1, this->flags, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeBluetoothLEAdvertisementsRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5629,6 +6202,15 @@ void BluetoothServiceData::encode(ProtoWriteBuffer buffer) const { } buffer.encode_string(3, this->data); } +void BluetoothServiceData::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->uuid, false); + if (!this->legacy_data.empty()) { + for (const auto &it : this->legacy_data) { + ProtoSize::add_uint32_field(total_size, 1, it, true); + } + } + ProtoSize::add_string_field(total_size, 1, this->data, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothServiceData::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5705,6 +6287,19 @@ void BluetoothLEAdvertisementResponse::encode(ProtoWriteBuffer buffer) const { } buffer.encode_uint32(7, this->address_type); } +void BluetoothLEAdvertisementResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_sint32_field(total_size, 1, this->rssi, false); + if (!this->service_uuids.empty()) { + for (const auto &it : this->service_uuids) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } + ProtoSize::add_repeated_message(total_size, 1, this->service_data); + ProtoSize::add_repeated_message(total_size, 1, this->manufacturer_data); + ProtoSize::add_uint32_field(total_size, 1, this->address_type, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothLEAdvertisementResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5782,6 +6377,12 @@ void BluetoothLERawAdvertisement::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(3, this->address_type); buffer.encode_string(4, this->data); } +void BluetoothLERawAdvertisement::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_sint32_field(total_size, 1, this->rssi, false); + ProtoSize::add_uint32_field(total_size, 1, this->address_type, false); + ProtoSize::add_string_field(total_size, 1, this->data, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothLERawAdvertisement::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5822,6 +6423,9 @@ void BluetoothLERawAdvertisementsResponse::encode(ProtoWriteBuffer buffer) const buffer.encode_message(1, it, true); } } +void BluetoothLERawAdvertisementsResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_repeated_message(total_size, 1, this->advertisements); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothLERawAdvertisementsResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5862,6 +6466,12 @@ void BluetoothDeviceRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(3, this->has_address_type); buffer.encode_uint32(4, this->address_type); } +void BluetoothDeviceRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->request_type), false); + ProtoSize::add_bool_field(total_size, 1, this->has_address_type, false); + ProtoSize::add_uint32_field(total_size, 1, this->address_type, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothDeviceRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5914,6 +6524,12 @@ void BluetoothDeviceConnectionResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(3, this->mtu); buffer.encode_int32(4, this->error); } +void BluetoothDeviceConnectionResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_bool_field(total_size, 1, this->connected, false); + ProtoSize::add_uint32_field(total_size, 1, this->mtu, false); + ProtoSize::add_int32_field(total_size, 1, this->error, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothDeviceConnectionResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5950,6 +6566,9 @@ bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, ProtoVarI } } void BluetoothGATTGetServicesRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); } +void BluetoothGATTGetServicesRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTGetServicesRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -5981,6 +6600,14 @@ void BluetoothGATTDescriptor::encode(ProtoWriteBuffer buffer) const { } buffer.encode_uint32(2, this->handle); } +void BluetoothGATTDescriptor::calculate_size(uint32_t &total_size) const { + if (!this->uuid.empty()) { + for (const auto &it : this->uuid) { + ProtoSize::add_uint64_field(total_size, 1, it, true); + } + } + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTDescriptor::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6037,6 +6664,16 @@ void BluetoothGATTCharacteristic::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(4, it, true); } } +void BluetoothGATTCharacteristic::calculate_size(uint32_t &total_size) const { + if (!this->uuid.empty()) { + for (const auto &it : this->uuid) { + ProtoSize::add_uint64_field(total_size, 1, it, true); + } + } + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_uint32_field(total_size, 1, this->properties, false); + ProtoSize::add_repeated_message(total_size, 1, this->descriptors); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTCharacteristic::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6099,6 +6736,15 @@ void BluetoothGATTService::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(3, it, true); } } +void BluetoothGATTService::calculate_size(uint32_t &total_size) const { + if (!this->uuid.empty()) { + for (const auto &it : this->uuid) { + ProtoSize::add_uint64_field(total_size, 1, it, true); + } + } + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_repeated_message(total_size, 1, this->characteristics); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTService::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6149,6 +6795,10 @@ void BluetoothGATTGetServicesResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(2, it, true); } } +void BluetoothGATTGetServicesResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_repeated_message(total_size, 1, this->services); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTGetServicesResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6179,6 +6829,9 @@ bool BluetoothGATTGetServicesDoneResponse::decode_varint(uint32_t field_id, Prot void BluetoothGATTGetServicesDoneResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); } +void BluetoothGATTGetServicesDoneResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTGetServicesDoneResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6208,6 +6861,10 @@ void BluetoothGATTReadRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_uint32(2, this->handle); } +void BluetoothGATTReadRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTReadRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6253,6 +6910,11 @@ void BluetoothGATTReadResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, this->handle); buffer.encode_string(3, this->data); } +void BluetoothGATTReadResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_string_field(total_size, 1, this->data, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTReadResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6307,6 +6969,12 @@ void BluetoothGATTWriteRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(3, this->response); buffer.encode_string(4, this->data); } +void BluetoothGATTWriteRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_bool_field(total_size, 1, this->response, false); + ProtoSize::add_string_field(total_size, 1, this->data, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTWriteRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6349,6 +7017,10 @@ void BluetoothGATTReadDescriptorRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_uint32(2, this->handle); } +void BluetoothGATTReadDescriptorRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTReadDescriptorRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6394,6 +7066,11 @@ void BluetoothGATTWriteDescriptorRequest::encode(ProtoWriteBuffer buffer) const buffer.encode_uint32(2, this->handle); buffer.encode_string(3, this->data); } +void BluetoothGATTWriteDescriptorRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_string_field(total_size, 1, this->data, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTWriteDescriptorRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6437,6 +7114,11 @@ void BluetoothGATTNotifyRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, this->handle); buffer.encode_bool(3, this->enable); } +void BluetoothGATTNotifyRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_bool_field(total_size, 1, this->enable, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTNotifyRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6486,6 +7168,11 @@ void BluetoothGATTNotifyDataResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, this->handle); buffer.encode_string(3, this->data); } +void BluetoothGATTNotifyDataResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_string_field(total_size, 1, this->data, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTNotifyDataResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6507,6 +7194,7 @@ void BluetoothGATTNotifyDataResponse::dump_to(std::string &out) const { } #endif void SubscribeBluetoothConnectionsFreeRequest::encode(ProtoWriteBuffer buffer) const {} +void SubscribeBluetoothConnectionsFreeRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeBluetoothConnectionsFreeRequest::dump_to(std::string &out) const { out.append("SubscribeBluetoothConnectionsFreeRequest {}"); @@ -6537,6 +7225,15 @@ void BluetoothConnectionsFreeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(3, it, true); } } +void BluetoothConnectionsFreeResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint32_field(total_size, 1, this->free, false); + ProtoSize::add_uint32_field(total_size, 1, this->limit, false); + if (!this->allocated.empty()) { + for (const auto &it : this->allocated) { + ProtoSize::add_uint64_field(total_size, 1, it, true); + } + } +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothConnectionsFreeResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6583,6 +7280,11 @@ void BluetoothGATTErrorResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, this->handle); buffer.encode_int32(3, this->error); } +void BluetoothGATTErrorResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); + ProtoSize::add_int32_field(total_size, 1, this->error, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTErrorResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6622,6 +7324,10 @@ void BluetoothGATTWriteResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_uint32(2, this->handle); } +void BluetoothGATTWriteResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTWriteResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6656,6 +7362,10 @@ void BluetoothGATTNotifyResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_uint32(2, this->handle); } +void BluetoothGATTNotifyResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_uint32_field(total_size, 1, this->handle, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothGATTNotifyResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6695,6 +7405,11 @@ void BluetoothDevicePairingResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(2, this->paired); buffer.encode_int32(3, this->error); } +void BluetoothDevicePairingResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_bool_field(total_size, 1, this->paired, false); + ProtoSize::add_int32_field(total_size, 1, this->error, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothDevicePairingResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6738,6 +7453,11 @@ void BluetoothDeviceUnpairingResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(2, this->success); buffer.encode_int32(3, this->error); } +void BluetoothDeviceUnpairingResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_bool_field(total_size, 1, this->success, false); + ProtoSize::add_int32_field(total_size, 1, this->error, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothDeviceUnpairingResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6759,6 +7479,7 @@ void BluetoothDeviceUnpairingResponse::dump_to(std::string &out) const { } #endif void UnsubscribeBluetoothLEAdvertisementsRequest::encode(ProtoWriteBuffer buffer) const {} +void UnsubscribeBluetoothLEAdvertisementsRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void UnsubscribeBluetoothLEAdvertisementsRequest::dump_to(std::string &out) const { out.append("UnsubscribeBluetoothLEAdvertisementsRequest {}"); @@ -6787,6 +7508,11 @@ void BluetoothDeviceClearCacheResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(2, this->success); buffer.encode_int32(3, this->error); } +void BluetoothDeviceClearCacheResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint64_field(total_size, 1, this->address, false); + ProtoSize::add_bool_field(total_size, 1, this->success, false); + ProtoSize::add_int32_field(total_size, 1, this->error, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothDeviceClearCacheResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6825,6 +7551,10 @@ void BluetoothScannerStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(1, this->state); buffer.encode_enum(2, this->mode); } +void BluetoothScannerStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_enum_field(total_size, 1, static_cast(this->state), false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothScannerStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6852,6 +7582,9 @@ bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, ProtoVarIn void BluetoothScannerSetModeRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(1, this->mode); } +void BluetoothScannerSetModeRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothScannerSetModeRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6880,6 +7613,10 @@ void SubscribeVoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->subscribe); buffer.encode_uint32(2, this->flags); } +void SubscribeVoiceAssistantRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->subscribe, false); + ProtoSize::add_uint32_field(total_size, 1, this->flags, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void SubscribeVoiceAssistantRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6924,6 +7661,11 @@ void VoiceAssistantAudioSettings::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, this->auto_gain); buffer.encode_float(3, this->volume_multiplier); } +void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level, false); + ProtoSize::add_uint32_field(total_size, 1, this->auto_gain, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->volume_multiplier != 0.0f, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantAudioSettings::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -6984,6 +7726,13 @@ void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(4, this->audio_settings); buffer.encode_string(5, this->wake_word_phrase); } +void VoiceAssistantRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->start, false); + ProtoSize::add_string_field(total_size, 1, this->conversation_id, false); + ProtoSize::add_uint32_field(total_size, 1, this->flags, false); + ProtoSize::add_message_object(total_size, 1, this->audio_settings, false); + ProtoSize::add_string_field(total_size, 1, this->wake_word_phrase, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7029,6 +7778,10 @@ void VoiceAssistantResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->port); buffer.encode_bool(2, this->error); } +void VoiceAssistantResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_uint32_field(total_size, 1, this->port, false); + ProtoSize::add_bool_field(total_size, 1, this->error, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7062,6 +7815,10 @@ void VoiceAssistantEventData::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->name); buffer.encode_string(2, this->value); } +void VoiceAssistantEventData::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->value, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantEventData::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7102,6 +7859,10 @@ void VoiceAssistantEventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_message(2, it, true); } } +void VoiceAssistantEventResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_enum_field(total_size, 1, static_cast(this->event_type), false); + ProtoSize::add_repeated_message(total_size, 1, this->data); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantEventResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7142,6 +7903,10 @@ void VoiceAssistantAudio::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->data); buffer.encode_bool(2, this->end); } +void VoiceAssistantAudio::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->data, false); + ProtoSize::add_bool_field(total_size, 1, this->end, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantAudio::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7200,6 +7965,14 @@ void VoiceAssistantTimerEventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(5, this->seconds_left); buffer.encode_bool(6, this->is_active); } +void VoiceAssistantTimerEventResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_enum_field(total_size, 1, static_cast(this->event_type), false); + ProtoSize::add_string_field(total_size, 1, this->timer_id, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_uint32_field(total_size, 1, this->total_seconds, false); + ProtoSize::add_uint32_field(total_size, 1, this->seconds_left, false); + ProtoSize::add_bool_field(total_size, 1, this->is_active, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantTimerEventResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7266,6 +8039,12 @@ void VoiceAssistantAnnounceRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(3, this->preannounce_media_id); buffer.encode_bool(4, this->start_conversation); } +void VoiceAssistantAnnounceRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->media_id, false); + ProtoSize::add_string_field(total_size, 1, this->text, false); + ProtoSize::add_string_field(total_size, 1, this->preannounce_media_id, false); + ProtoSize::add_bool_field(total_size, 1, this->start_conversation, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantAnnounceRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7299,6 +8078,9 @@ bool VoiceAssistantAnnounceFinished::decode_varint(uint32_t field_id, ProtoVarIn } } void VoiceAssistantAnnounceFinished::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(1, this->success); } +void VoiceAssistantAnnounceFinished::calculate_size(uint32_t &total_size) const { + ProtoSize::add_bool_field(total_size, 1, this->success, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantAnnounceFinished::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7334,6 +8116,15 @@ void VoiceAssistantWakeWord::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(3, it, true); } } +void VoiceAssistantWakeWord::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->id, false); + ProtoSize::add_string_field(total_size, 1, this->wake_word, false); + if (!this->trained_languages.empty()) { + for (const auto &it : this->trained_languages) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantWakeWord::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7355,6 +8146,7 @@ void VoiceAssistantWakeWord::dump_to(std::string &out) const { } #endif void VoiceAssistantConfigurationRequest::encode(ProtoWriteBuffer buffer) const {} +void VoiceAssistantConfigurationRequest::calculate_size(uint32_t &total_size) const {} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantConfigurationRequest::dump_to(std::string &out) const { out.append("VoiceAssistantConfigurationRequest {}"); @@ -7393,6 +8185,15 @@ void VoiceAssistantConfigurationResponse::encode(ProtoWriteBuffer buffer) const } buffer.encode_uint32(3, this->max_active_wake_words); } +void VoiceAssistantConfigurationResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_repeated_message(total_size, 1, this->available_wake_words); + if (!this->active_wake_words.empty()) { + for (const auto &it : this->active_wake_words) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } + ProtoSize::add_uint32_field(total_size, 1, this->max_active_wake_words, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantConfigurationResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7431,6 +8232,13 @@ void VoiceAssistantSetConfiguration::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, it, true); } } +void VoiceAssistantSetConfiguration::calculate_size(uint32_t &total_size) const { + if (!this->active_wake_words.empty()) { + for (const auto &it : this->active_wake_words) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } +} #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantSetConfiguration::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7513,6 +8321,18 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons buffer.encode_bool(9, this->requires_code); buffer.encode_bool(10, this->requires_code_to_arm); } +void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_uint32_field(total_size, 1, this->supported_features, false); + ProtoSize::add_bool_field(total_size, 1, this->requires_code, false); + ProtoSize::add_bool_field(total_size, 1, this->requires_code_to_arm, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesAlarmControlPanelResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7585,6 +8405,10 @@ void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_enum(2, this->state); } +void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->state), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void AlarmControlPanelStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7635,6 +8459,11 @@ void AlarmControlPanelCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(2, this->command); buffer.encode_string(3, this->code); } +void AlarmControlPanelCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->command), false); + ProtoSize::add_string_field(total_size, 1, this->code, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void AlarmControlPanelCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7729,6 +8558,19 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(10, this->pattern); buffer.encode_enum(11, this->mode); } +void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_uint32_field(total_size, 1, this->min_length, false); + ProtoSize::add_uint32_field(total_size, 1, this->max_length, false); + ProtoSize::add_string_field(total_size, 1, this->pattern, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesTextResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7817,6 +8659,11 @@ void TextStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(2, this->state); buffer.encode_bool(3, this->missing_state); } +void TextStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->state, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void TextStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7860,6 +8707,10 @@ void TextCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->state); } +void TextCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->state, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void TextCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -7930,6 +8781,15 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(6, this->disabled_by_default); buffer.encode_enum(7, this->entity_category); } +void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesDateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8004,6 +8864,13 @@ void DateStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(4, this->month); buffer.encode_uint32(5, this->day); } +void DateStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); + ProtoSize::add_uint32_field(total_size, 1, this->year, false); + ProtoSize::add_uint32_field(total_size, 1, this->month, false); + ProtoSize::add_uint32_field(total_size, 1, this->day, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void DateStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8068,6 +8935,12 @@ void DateCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(3, this->month); buffer.encode_uint32(4, this->day); } +void DateCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_uint32_field(total_size, 1, this->year, false); + ProtoSize::add_uint32_field(total_size, 1, this->month, false); + ProtoSize::add_uint32_field(total_size, 1, this->day, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void DateCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8149,6 +9022,15 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(6, this->disabled_by_default); buffer.encode_enum(7, this->entity_category); } +void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesTimeResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8223,6 +9105,13 @@ void TimeStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(4, this->minute); buffer.encode_uint32(5, this->second); } +void TimeStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); + ProtoSize::add_uint32_field(total_size, 1, this->hour, false); + ProtoSize::add_uint32_field(total_size, 1, this->minute, false); + ProtoSize::add_uint32_field(total_size, 1, this->second, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void TimeStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8287,6 +9176,12 @@ void TimeCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(3, this->minute); buffer.encode_uint32(4, this->second); } +void TimeCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_uint32_field(total_size, 1, this->hour, false); + ProtoSize::add_uint32_field(total_size, 1, this->minute, false); + ProtoSize::add_uint32_field(total_size, 1, this->second, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void TimeCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8380,6 +9275,21 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(9, it, true); } } +void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); + if (!this->event_types.empty()) { + for (const auto &it : this->event_types) { + ProtoSize::add_string_field(total_size, 1, it, true); + } + } +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesEventResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8449,6 +9359,10 @@ void EventResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_string(2, this->event_type); } +void EventResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->event_type, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void EventResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8539,6 +9453,19 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(10, this->supports_position); buffer.encode_bool(11, this->supports_stop); } +void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); + ProtoSize::add_bool_field(total_size, 1, this->assumed_state, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_position, false); + ProtoSize::add_bool_field(total_size, 1, this->supports_stop, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesValveResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8619,6 +9546,11 @@ void ValveStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(2, this->position); buffer.encode_enum(3, this->current_operation); } +void ValveStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->current_operation), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ValveStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8673,6 +9605,12 @@ void ValveCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_float(3, this->position); buffer.encode_bool(4, this->stop); } +void ValveCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->has_position, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f, false); + ProtoSize::add_bool_field(total_size, 1, this->stop, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ValveCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8752,6 +9690,15 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(6, this->disabled_by_default); buffer.encode_enum(7, this->entity_category); } +void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesDateTimeResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8816,6 +9763,11 @@ void DateTimeStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_bool(2, this->missing_state); buffer.encode_fixed32(3, this->epoch_seconds); } +void DateTimeStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void DateTimeStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8854,6 +9806,10 @@ void DateTimeCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_fixed32(2, this->epoch_seconds); } +void DateTimeCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void DateTimeCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -8930,6 +9886,16 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_enum(7, this->entity_category); buffer.encode_string(8, this->device_class); } +void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_string_field(total_size, 1, this->object_id, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_string_field(total_size, 1, this->name, false); + ProtoSize::add_string_field(total_size, 1, this->unique_id, false); + ProtoSize::add_string_field(total_size, 1, this->icon, false); + ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->entity_category), false); + ProtoSize::add_string_field(total_size, 1, this->device_class, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void ListEntitiesUpdateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -9039,6 +10005,18 @@ void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(9, this->release_summary); buffer.encode_string(10, this->release_url); } +void UpdateStateResponse::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_bool_field(total_size, 1, this->missing_state, false); + ProtoSize::add_bool_field(total_size, 1, this->in_progress, false); + ProtoSize::add_bool_field(total_size, 1, this->has_progress, false); + ProtoSize::add_fixed_field<4>(total_size, 1, this->progress != 0.0f, false); + ProtoSize::add_string_field(total_size, 1, this->current_version, false); + ProtoSize::add_string_field(total_size, 1, this->latest_version, false); + ProtoSize::add_string_field(total_size, 1, this->title, false); + ProtoSize::add_string_field(total_size, 1, this->release_summary, false); + ProtoSize::add_string_field(total_size, 1, this->release_url, false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void UpdateStateResponse::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; @@ -9111,6 +10089,10 @@ void UpdateCommandRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_enum(2, this->command); } +void UpdateCommandRequest::calculate_size(uint32_t &total_size) const { + ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0, false); + ProtoSize::add_enum_field(total_size, 1, static_cast(this->command), false); +} #ifdef HAS_PROTO_MESSAGE_DUMP void UpdateCommandRequest::dump_to(std::string &out) const { __attribute__((unused)) char buffer[64]; diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 18e4002107..457797f1a7 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -1,8 +1,9 @@ // This file was automatically generated with a tool. -// See scripts/api_protobuf/api_protobuf.py +// See script/api_protobuf/api_protobuf.py #pragma once #include "proto.h" +#include "api_pb2_size.h" namespace esphome { namespace api { @@ -257,6 +258,7 @@ class HelloRequest : public ProtoMessage { uint32_t api_version_major{0}; uint32_t api_version_minor{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -272,6 +274,7 @@ class HelloResponse : public ProtoMessage { std::string server_info{}; std::string name{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -284,6 +287,7 @@ class ConnectRequest : public ProtoMessage { public: std::string password{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -295,6 +299,7 @@ class ConnectResponse : public ProtoMessage { public: bool invalid_password{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -305,6 +310,7 @@ class ConnectResponse : public ProtoMessage { class DisconnectRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -314,6 +320,7 @@ class DisconnectRequest : public ProtoMessage { class DisconnectResponse : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -323,6 +330,7 @@ class DisconnectResponse : public ProtoMessage { class PingRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -332,6 +340,7 @@ class PingRequest : public ProtoMessage { class PingResponse : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -341,6 +350,7 @@ class PingResponse : public ProtoMessage { class DeviceInfoRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -369,6 +379,7 @@ class DeviceInfoResponse : public ProtoMessage { std::string bluetooth_mac_address{}; bool api_encryption_supported{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -380,6 +391,7 @@ class DeviceInfoResponse : public ProtoMessage { class ListEntitiesRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -389,6 +401,7 @@ class ListEntitiesRequest : public ProtoMessage { class ListEntitiesDoneResponse : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -398,6 +411,7 @@ class ListEntitiesDoneResponse : public ProtoMessage { class SubscribeStatesRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -416,6 +430,7 @@ class ListEntitiesBinarySensorResponse : public ProtoMessage { std::string icon{}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -431,6 +446,7 @@ class BinarySensorStateResponse : public ProtoMessage { bool state{false}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -454,6 +470,7 @@ class ListEntitiesCoverResponse : public ProtoMessage { enums::EntityCategory entity_category{}; bool supports_stop{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -471,6 +488,7 @@ class CoverStateResponse : public ProtoMessage { float tilt{0.0f}; enums::CoverOperation current_operation{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -490,6 +508,7 @@ class CoverCommandRequest : public ProtoMessage { float tilt{0.0f}; bool stop{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -513,6 +532,7 @@ class ListEntitiesFanResponse : public ProtoMessage { enums::EntityCategory entity_category{}; std::vector supported_preset_modes{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -532,6 +552,7 @@ class FanStateResponse : public ProtoMessage { int32_t speed_level{0}; std::string preset_mode{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -557,6 +578,7 @@ class FanCommandRequest : public ProtoMessage { bool has_preset_mode{false}; std::string preset_mode{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -584,6 +606,7 @@ class ListEntitiesLightResponse : public ProtoMessage { std::string icon{}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -609,6 +632,7 @@ class LightStateResponse : public ProtoMessage { float warm_white{0.0f}; std::string effect{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -648,6 +672,7 @@ class LightCommandRequest : public ProtoMessage { bool has_effect{false}; std::string effect{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -673,6 +698,7 @@ class ListEntitiesSensorResponse : public ProtoMessage { bool disabled_by_default{false}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -688,6 +714,7 @@ class SensorStateResponse : public ProtoMessage { float state{0.0f}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -708,6 +735,7 @@ class ListEntitiesSwitchResponse : public ProtoMessage { enums::EntityCategory entity_category{}; std::string device_class{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -722,6 +750,7 @@ class SwitchStateResponse : public ProtoMessage { uint32_t key{0}; bool state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -735,6 +764,7 @@ class SwitchCommandRequest : public ProtoMessage { uint32_t key{0}; bool state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -754,6 +784,7 @@ class ListEntitiesTextSensorResponse : public ProtoMessage { enums::EntityCategory entity_category{}; std::string device_class{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -769,6 +800,7 @@ class TextSensorStateResponse : public ProtoMessage { std::string state{}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -783,6 +815,7 @@ class SubscribeLogsRequest : public ProtoMessage { enums::LogLevel level{}; bool dump_config{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -796,6 +829,7 @@ class SubscribeLogsResponse : public ProtoMessage { std::string message{}; bool send_failed{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -808,6 +842,7 @@ class NoiseEncryptionSetKeyRequest : public ProtoMessage { public: std::string key{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -819,6 +854,7 @@ class NoiseEncryptionSetKeyResponse : public ProtoMessage { public: bool success{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -829,6 +865,7 @@ class NoiseEncryptionSetKeyResponse : public ProtoMessage { class SubscribeHomeassistantServicesRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -840,6 +877,7 @@ class HomeassistantServiceMap : public ProtoMessage { std::string key{}; std::string value{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -855,6 +893,7 @@ class HomeassistantServiceResponse : public ProtoMessage { std::vector variables{}; bool is_event{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -866,6 +905,7 @@ class HomeassistantServiceResponse : public ProtoMessage { class SubscribeHomeAssistantStatesRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -878,6 +918,7 @@ class SubscribeHomeAssistantStateResponse : public ProtoMessage { std::string attribute{}; bool once{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -892,6 +933,7 @@ class HomeAssistantStateResponse : public ProtoMessage { std::string state{}; std::string attribute{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -902,6 +944,7 @@ class HomeAssistantStateResponse : public ProtoMessage { class GetTimeRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -912,6 +955,7 @@ class GetTimeResponse : public ProtoMessage { public: uint32_t epoch_seconds{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -924,6 +968,7 @@ class ListEntitiesServicesArgument : public ProtoMessage { std::string name{}; enums::ServiceArgType type{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -938,6 +983,7 @@ class ListEntitiesServicesResponse : public ProtoMessage { uint32_t key{0}; std::vector args{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -958,6 +1004,7 @@ class ExecuteServiceArgument : public ProtoMessage { std::vector float_array{}; std::vector string_array{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -972,6 +1019,7 @@ class ExecuteServiceRequest : public ProtoMessage { uint32_t key{0}; std::vector args{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -990,6 +1038,7 @@ class ListEntitiesCameraResponse : public ProtoMessage { std::string icon{}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1005,6 +1054,7 @@ class CameraImageResponse : public ProtoMessage { std::string data{}; bool done{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1019,6 +1069,7 @@ class CameraImageRequest : public ProtoMessage { bool single{false}; bool stream{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1054,6 +1105,7 @@ class ListEntitiesClimateResponse : public ProtoMessage { float visual_min_humidity{0.0f}; float visual_max_humidity{0.0f}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1081,6 +1133,7 @@ class ClimateStateResponse : public ProtoMessage { float current_humidity{0.0f}; float target_humidity{0.0f}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1116,6 +1169,7 @@ class ClimateCommandRequest : public ProtoMessage { bool has_target_humidity{false}; float target_humidity{0.0f}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1141,6 +1195,7 @@ class ListEntitiesNumberResponse : public ProtoMessage { enums::NumberMode mode{}; std::string device_class{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1156,6 +1211,7 @@ class NumberStateResponse : public ProtoMessage { float state{0.0f}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1169,6 +1225,7 @@ class NumberCommandRequest : public ProtoMessage { uint32_t key{0}; float state{0.0f}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1187,6 +1244,7 @@ class ListEntitiesSelectResponse : public ProtoMessage { bool disabled_by_default{false}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1202,6 +1260,7 @@ class SelectStateResponse : public ProtoMessage { std::string state{}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1216,6 +1275,7 @@ class SelectCommandRequest : public ProtoMessage { uint32_t key{0}; std::string state{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1238,6 +1298,7 @@ class ListEntitiesLockResponse : public ProtoMessage { bool requires_code{false}; std::string code_format{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1252,6 +1313,7 @@ class LockStateResponse : public ProtoMessage { uint32_t key{0}; enums::LockState state{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1267,6 +1329,7 @@ class LockCommandRequest : public ProtoMessage { bool has_code{false}; std::string code{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1287,6 +1350,7 @@ class ListEntitiesButtonResponse : public ProtoMessage { enums::EntityCategory entity_category{}; std::string device_class{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1300,6 +1364,7 @@ class ButtonCommandRequest : public ProtoMessage { public: uint32_t key{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1315,6 +1380,7 @@ class MediaPlayerSupportedFormat : public ProtoMessage { enums::MediaPlayerFormatPurpose purpose{}; uint32_t sample_bytes{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1335,6 +1401,7 @@ class ListEntitiesMediaPlayerResponse : public ProtoMessage { bool supports_pause{false}; std::vector supported_formats{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1351,6 +1418,7 @@ class MediaPlayerStateResponse : public ProtoMessage { float volume{0.0f}; bool muted{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1371,6 +1439,7 @@ class MediaPlayerCommandRequest : public ProtoMessage { bool has_announcement{false}; bool announcement{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1384,6 +1453,7 @@ class SubscribeBluetoothLEAdvertisementsRequest : public ProtoMessage { public: uint32_t flags{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1397,6 +1467,7 @@ class BluetoothServiceData : public ProtoMessage { std::vector legacy_data{}; std::string data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1415,6 +1486,7 @@ class BluetoothLEAdvertisementResponse : public ProtoMessage { std::vector manufacturer_data{}; uint32_t address_type{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1430,6 +1502,7 @@ class BluetoothLERawAdvertisement : public ProtoMessage { uint32_t address_type{0}; std::string data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1442,6 +1515,7 @@ class BluetoothLERawAdvertisementsResponse : public ProtoMessage { public: std::vector advertisements{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1456,6 +1530,7 @@ class BluetoothDeviceRequest : public ProtoMessage { bool has_address_type{false}; uint32_t address_type{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1470,6 +1545,7 @@ class BluetoothDeviceConnectionResponse : public ProtoMessage { uint32_t mtu{0}; int32_t error{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1481,6 +1557,7 @@ class BluetoothGATTGetServicesRequest : public ProtoMessage { public: uint64_t address{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1493,6 +1570,7 @@ class BluetoothGATTDescriptor : public ProtoMessage { std::vector uuid{}; uint32_t handle{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1507,6 +1585,7 @@ class BluetoothGATTCharacteristic : public ProtoMessage { uint32_t properties{0}; std::vector descriptors{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1521,6 +1600,7 @@ class BluetoothGATTService : public ProtoMessage { uint32_t handle{0}; std::vector characteristics{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1534,6 +1614,7 @@ class BluetoothGATTGetServicesResponse : public ProtoMessage { uint64_t address{0}; std::vector services{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1546,6 +1627,7 @@ class BluetoothGATTGetServicesDoneResponse : public ProtoMessage { public: uint64_t address{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1558,6 +1640,7 @@ class BluetoothGATTReadRequest : public ProtoMessage { uint64_t address{0}; uint32_t handle{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1571,6 +1654,7 @@ class BluetoothGATTReadResponse : public ProtoMessage { uint32_t handle{0}; std::string data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1586,6 +1670,7 @@ class BluetoothGATTWriteRequest : public ProtoMessage { bool response{false}; std::string data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1599,6 +1684,7 @@ class BluetoothGATTReadDescriptorRequest : public ProtoMessage { uint64_t address{0}; uint32_t handle{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1612,6 +1698,7 @@ class BluetoothGATTWriteDescriptorRequest : public ProtoMessage { uint32_t handle{0}; std::string data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1626,6 +1713,7 @@ class BluetoothGATTNotifyRequest : public ProtoMessage { uint32_t handle{0}; bool enable{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1639,6 +1727,7 @@ class BluetoothGATTNotifyDataResponse : public ProtoMessage { uint32_t handle{0}; std::string data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1650,6 +1739,7 @@ class BluetoothGATTNotifyDataResponse : public ProtoMessage { class SubscribeBluetoothConnectionsFreeRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1662,6 +1752,7 @@ class BluetoothConnectionsFreeResponse : public ProtoMessage { uint32_t limit{0}; std::vector allocated{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1675,6 +1766,7 @@ class BluetoothGATTErrorResponse : public ProtoMessage { uint32_t handle{0}; int32_t error{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1687,6 +1779,7 @@ class BluetoothGATTWriteResponse : public ProtoMessage { uint64_t address{0}; uint32_t handle{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1699,6 +1792,7 @@ class BluetoothGATTNotifyResponse : public ProtoMessage { uint64_t address{0}; uint32_t handle{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1712,6 +1806,7 @@ class BluetoothDevicePairingResponse : public ProtoMessage { bool paired{false}; int32_t error{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1725,6 +1820,7 @@ class BluetoothDeviceUnpairingResponse : public ProtoMessage { bool success{false}; int32_t error{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1735,6 +1831,7 @@ class BluetoothDeviceUnpairingResponse : public ProtoMessage { class UnsubscribeBluetoothLEAdvertisementsRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1747,6 +1844,7 @@ class BluetoothDeviceClearCacheResponse : public ProtoMessage { bool success{false}; int32_t error{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1759,6 +1857,7 @@ class BluetoothScannerStateResponse : public ProtoMessage { enums::BluetoothScannerState state{}; enums::BluetoothScannerMode mode{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1770,6 +1869,7 @@ class BluetoothScannerSetModeRequest : public ProtoMessage { public: enums::BluetoothScannerMode mode{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1782,6 +1882,7 @@ class SubscribeVoiceAssistantRequest : public ProtoMessage { bool subscribe{false}; uint32_t flags{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1795,6 +1896,7 @@ class VoiceAssistantAudioSettings : public ProtoMessage { uint32_t auto_gain{0}; float volume_multiplier{0.0f}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1811,6 +1913,7 @@ class VoiceAssistantRequest : public ProtoMessage { VoiceAssistantAudioSettings audio_settings{}; std::string wake_word_phrase{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1824,6 +1927,7 @@ class VoiceAssistantResponse : public ProtoMessage { uint32_t port{0}; bool error{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1836,6 +1940,7 @@ class VoiceAssistantEventData : public ProtoMessage { std::string name{}; std::string value{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1848,6 +1953,7 @@ class VoiceAssistantEventResponse : public ProtoMessage { enums::VoiceAssistantEvent event_type{}; std::vector data{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1861,6 +1967,7 @@ class VoiceAssistantAudio : public ProtoMessage { std::string data{}; bool end{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1878,6 +1985,7 @@ class VoiceAssistantTimerEventResponse : public ProtoMessage { uint32_t seconds_left{0}; bool is_active{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1893,6 +2001,7 @@ class VoiceAssistantAnnounceRequest : public ProtoMessage { std::string preannounce_media_id{}; bool start_conversation{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1905,6 +2014,7 @@ class VoiceAssistantAnnounceFinished : public ProtoMessage { public: bool success{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1918,6 +2028,7 @@ class VoiceAssistantWakeWord : public ProtoMessage { std::string wake_word{}; std::vector trained_languages{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1928,6 +2039,7 @@ class VoiceAssistantWakeWord : public ProtoMessage { class VoiceAssistantConfigurationRequest : public ProtoMessage { public: void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1940,6 +2052,7 @@ class VoiceAssistantConfigurationResponse : public ProtoMessage { std::vector active_wake_words{}; uint32_t max_active_wake_words{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1952,6 +2065,7 @@ class VoiceAssistantSetConfiguration : public ProtoMessage { public: std::vector active_wake_words{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1972,6 +2086,7 @@ class ListEntitiesAlarmControlPanelResponse : public ProtoMessage { bool requires_code{false}; bool requires_code_to_arm{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -1986,6 +2101,7 @@ class AlarmControlPanelStateResponse : public ProtoMessage { uint32_t key{0}; enums::AlarmControlPanelState state{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2000,6 +2116,7 @@ class AlarmControlPanelCommandRequest : public ProtoMessage { enums::AlarmControlPanelStateCommand command{}; std::string code{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2023,6 +2140,7 @@ class ListEntitiesTextResponse : public ProtoMessage { std::string pattern{}; enums::TextMode mode{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2038,6 +2156,7 @@ class TextStateResponse : public ProtoMessage { std::string state{}; bool missing_state{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2052,6 +2171,7 @@ class TextCommandRequest : public ProtoMessage { uint32_t key{0}; std::string state{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2070,6 +2190,7 @@ class ListEntitiesDateResponse : public ProtoMessage { bool disabled_by_default{false}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2087,6 +2208,7 @@ class DateStateResponse : public ProtoMessage { uint32_t month{0}; uint32_t day{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2102,6 +2224,7 @@ class DateCommandRequest : public ProtoMessage { uint32_t month{0}; uint32_t day{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2120,6 +2243,7 @@ class ListEntitiesTimeResponse : public ProtoMessage { bool disabled_by_default{false}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2137,6 +2261,7 @@ class TimeStateResponse : public ProtoMessage { uint32_t minute{0}; uint32_t second{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2152,6 +2277,7 @@ class TimeCommandRequest : public ProtoMessage { uint32_t minute{0}; uint32_t second{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2172,6 +2298,7 @@ class ListEntitiesEventResponse : public ProtoMessage { std::string device_class{}; std::vector event_types{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2186,6 +2313,7 @@ class EventResponse : public ProtoMessage { uint32_t key{0}; std::string event_type{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2208,6 +2336,7 @@ class ListEntitiesValveResponse : public ProtoMessage { bool supports_position{false}; bool supports_stop{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2223,6 +2352,7 @@ class ValveStateResponse : public ProtoMessage { float position{0.0f}; enums::ValveOperation current_operation{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2238,6 +2368,7 @@ class ValveCommandRequest : public ProtoMessage { float position{0.0f}; bool stop{false}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2256,6 +2387,7 @@ class ListEntitiesDateTimeResponse : public ProtoMessage { bool disabled_by_default{false}; enums::EntityCategory entity_category{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2271,6 +2403,7 @@ class DateTimeStateResponse : public ProtoMessage { bool missing_state{false}; uint32_t epoch_seconds{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2284,6 +2417,7 @@ class DateTimeCommandRequest : public ProtoMessage { uint32_t key{0}; uint32_t epoch_seconds{0}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2302,6 +2436,7 @@ class ListEntitiesUpdateResponse : public ProtoMessage { enums::EntityCategory entity_category{}; std::string device_class{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2324,6 +2459,7 @@ class UpdateStateResponse : public ProtoMessage { std::string release_summary{}; std::string release_url{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif @@ -2338,6 +2474,7 @@ class UpdateCommandRequest : public ProtoMessage { uint32_t key{0}; enums::UpdateCommand command{}; void encode(ProtoWriteBuffer buffer) const override; + void calculate_size(uint32_t &total_size) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; #endif diff --git a/esphome/components/api/api_pb2_service.cpp b/esphome/components/api/api_pb2_service.cpp index dd86c9538a..cde4492000 100644 --- a/esphome/components/api/api_pb2_service.cpp +++ b/esphome/components/api/api_pb2_service.cpp @@ -1,5 +1,5 @@ // This file was automatically generated with a tool. -// See scripts/api_protobuf/api_protobuf.py +// See script/api_protobuf/api_protobuf.py #include "api_pb2_service.h" #include "esphome/core/log.h" diff --git a/esphome/components/api/api_pb2_service.h b/esphome/components/api/api_pb2_service.h index 1012d8a65b..4964f41420 100644 --- a/esphome/components/api/api_pb2_service.h +++ b/esphome/components/api/api_pb2_service.h @@ -1,5 +1,5 @@ // This file was automatically generated with a tool. -// See scripts/api_protobuf/api_protobuf.py +// See script/api_protobuf/api_protobuf.py #pragma once #include "api_pb2.h" diff --git a/esphome/components/api/api_pb2_size.h b/esphome/components/api/api_pb2_size.h new file mode 100644 index 0000000000..e591a7350f --- /dev/null +++ b/esphome/components/api/api_pb2_size.h @@ -0,0 +1,361 @@ +#pragma once + +#include "proto.h" +#include +#include + +namespace esphome { +namespace api { + +class ProtoSize { + public: + /** + * @brief ProtoSize class for Protocol Buffer serialization size calculation + * + * This class provides static methods to calculate the exact byte counts needed + * for encoding various Protocol Buffer field types. All methods are designed to be + * efficient for the common case where many fields have default values. + * + * Implements Protocol Buffer encoding size calculation according to: + * https://protobuf.dev/programming-guides/encoding/ + * + * Key features: + * - Early-return optimization for zero/default values + * - Direct total_size updates to avoid unnecessary additions + * - Specialized handling for different field types according to protobuf spec + * - Templated helpers for repeated fields and messages + */ + + /** + * @brief Calculates the size in bytes needed to encode a uint32_t value as a varint + * + * @param value The uint32_t value to calculate size for + * @return The number of bytes needed to encode the value + */ + static inline uint32_t varint(uint32_t value) { + // Optimized varint size calculation using leading zeros + // Each 7 bits requires one byte in the varint encoding + if (value < 128) + return 1; // 7 bits, common case for small values + + // For larger values, count bytes needed based on the position of the highest bit set + if (value < 16384) { + return 2; // 14 bits + } else if (value < 2097152) { + return 3; // 21 bits + } else if (value < 268435456) { + return 4; // 28 bits + } else { + return 5; // 32 bits (maximum for uint32_t) + } + } + + /** + * @brief Calculates the size in bytes needed to encode a uint64_t value as a varint + * + * @param value The uint64_t value to calculate size for + * @return The number of bytes needed to encode the value + */ + static inline uint32_t varint(uint64_t value) { + // Handle common case of values fitting in uint32_t (vast majority of use cases) + if (value <= UINT32_MAX) { + return varint(static_cast(value)); + } + + // For larger values, determine size based on highest bit position + if (value < (1ULL << 35)) { + return 5; // 35 bits + } else if (value < (1ULL << 42)) { + return 6; // 42 bits + } else if (value < (1ULL << 49)) { + return 7; // 49 bits + } else if (value < (1ULL << 56)) { + return 8; // 56 bits + } else if (value < (1ULL << 63)) { + return 9; // 63 bits + } else { + return 10; // 64 bits (maximum for uint64_t) + } + } + + /** + * @brief Calculates the size in bytes needed to encode an int32_t value as a varint + * + * Special handling is needed for negative values, which are sign-extended to 64 bits + * in Protocol Buffers, resulting in a 10-byte varint. + * + * @param value The int32_t value to calculate size for + * @return The number of bytes needed to encode the value + */ + static inline uint32_t varint(int32_t value) { + // Negative values are sign-extended to 64 bits in protocol buffers, + // which always results in a 10-byte varint for negative int32 + if (value < 0) { + return 10; // Negative int32 is always 10 bytes long + } + // For non-negative values, use the uint32_t implementation + return varint(static_cast(value)); + } + + /** + * @brief Calculates the size in bytes needed to encode an int64_t value as a varint + * + * @param value The int64_t value to calculate size for + * @return The number of bytes needed to encode the value + */ + static inline uint32_t varint(int64_t value) { + // For int64_t, we convert to uint64_t and calculate the size + // This works because the bit pattern determines the encoding size, + // and we've handled negative int32 values as a special case above + return varint(static_cast(value)); + } + + /** + * @brief Calculates the size in bytes needed to encode a field ID and wire type + * + * @param field_id The field identifier + * @param type The wire type value (from the WireType enum in the protobuf spec) + * @return The number of bytes needed to encode the field ID and wire type + */ + static inline uint32_t field(uint32_t field_id, uint32_t type) { + uint32_t tag = (field_id << 3) | (type & 0b111); + return varint(tag); + } + + /** + * @brief Common parameters for all add_*_field methods + * + * All add_*_field methods follow these common patterns: + * + * @param total_size Reference to the total message size to update + * @param field_id_size Pre-calculated size of the field ID in bytes + * @param value The value to calculate size for (type varies) + * @param force Whether to calculate size even if the value is default/zero/empty + * + * Each method follows this implementation pattern: + * 1. Skip calculation if value is default (0, false, empty) and not forced + * 2. Calculate the size based on the field's encoding rules + * 3. Add the field_id_size + calculated value size to total_size + */ + + /** + * @brief Calculates and adds the size of an int32 field to the total message size + */ + static inline void add_int32_field(uint32_t &total_size, uint32_t field_id_size, int32_t value, bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // Calculate and directly add to total_size + if (value < 0) { + // Negative values are encoded as 10-byte varints in protobuf + total_size += field_id_size + 10; + } else { + // For non-negative values, use the standard varint size + total_size += field_id_size + varint(static_cast(value)); + } + } + + /** + * @brief Calculates and adds the size of a uint32 field to the total message size + */ + static inline void add_uint32_field(uint32_t &total_size, uint32_t field_id_size, uint32_t value, + bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // Calculate and directly add to total_size + total_size += field_id_size + varint(value); + } + + /** + * @brief Calculates and adds the size of a boolean field to the total message size + */ + static inline void add_bool_field(uint32_t &total_size, uint32_t field_id_size, bool value, bool force = false) { + // Skip calculation if value is false and not forced + if (!value && !force) { + return; // No need to update total_size + } + + // Boolean fields always use 1 byte when true + total_size += field_id_size + 1; + } + + /** + * @brief Calculates and adds the size of a fixed field to the total message size + * + * Fixed fields always take exactly N bytes (4 for fixed32/float, 8 for fixed64/double). + * + * @tparam NumBytes The number of bytes for this fixed field (4 or 8) + * @param is_nonzero Whether the value is non-zero + */ + template + static inline void add_fixed_field(uint32_t &total_size, uint32_t field_id_size, bool is_nonzero, + bool force = false) { + // Skip calculation if value is zero and not forced + if (!is_nonzero && !force) { + return; // No need to update total_size + } + + // Fixed fields always take exactly NumBytes + total_size += field_id_size + NumBytes; + } + + /** + * @brief Calculates and adds the size of an enum field to the total message size + * + * Enum fields are encoded as uint32 varints. + */ + static inline void add_enum_field(uint32_t &total_size, uint32_t field_id_size, uint32_t value, bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // Enums are encoded as uint32 + total_size += field_id_size + varint(value); + } + + /** + * @brief Calculates and adds the size of a sint32 field to the total message size + * + * Sint32 fields use ZigZag encoding, which is more efficient for negative values. + */ + static inline void add_sint32_field(uint32_t &total_size, uint32_t field_id_size, int32_t value, bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // ZigZag encoding for sint32: (n << 1) ^ (n >> 31) + uint32_t zigzag = (static_cast(value) << 1) ^ (static_cast(value >> 31)); + total_size += field_id_size + varint(zigzag); + } + + /** + * @brief Calculates and adds the size of an int64 field to the total message size + */ + static inline void add_int64_field(uint32_t &total_size, uint32_t field_id_size, int64_t value, bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // Calculate and directly add to total_size + total_size += field_id_size + varint(value); + } + + /** + * @brief Calculates and adds the size of a uint64 field to the total message size + */ + static inline void add_uint64_field(uint32_t &total_size, uint32_t field_id_size, uint64_t value, + bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // Calculate and directly add to total_size + total_size += field_id_size + varint(value); + } + + /** + * @brief Calculates and adds the size of a sint64 field to the total message size + * + * Sint64 fields use ZigZag encoding, which is more efficient for negative values. + */ + static inline void add_sint64_field(uint32_t &total_size, uint32_t field_id_size, int64_t value, bool force = false) { + // Skip calculation if value is zero and not forced + if (value == 0 && !force) { + return; // No need to update total_size + } + + // ZigZag encoding for sint64: (n << 1) ^ (n >> 63) + uint64_t zigzag = (static_cast(value) << 1) ^ (static_cast(value >> 63)); + total_size += field_id_size + varint(zigzag); + } + + /** + * @brief Calculates and adds the size of a string/bytes field to the total message size + */ + static inline void add_string_field(uint32_t &total_size, uint32_t field_id_size, const std::string &str, + bool force = false) { + // Skip calculation if string is empty and not forced + if (str.empty() && !force) { + return; // No need to update total_size + } + + // Calculate and directly add to total_size + const uint32_t str_size = static_cast(str.size()); + total_size += field_id_size + varint(str_size) + str_size; + } + + /** + * @brief Calculates and adds the size of a nested message field to the total message size + * + * This helper function directly updates the total_size reference if the nested size + * is greater than zero or force is true. + * + * @param nested_size The pre-calculated size of the nested message + */ + static inline void add_message_field(uint32_t &total_size, uint32_t field_id_size, uint32_t nested_size, + bool force = false) { + // Skip calculation if nested message is empty and not forced + if (nested_size == 0 && !force) { + return; // No need to update total_size + } + + // Calculate and directly add to total_size + // Field ID + length varint + nested message content + total_size += field_id_size + varint(nested_size) + nested_size; + } + + /** + * @brief Calculates and adds the size of a nested message field to the total message size + * + * This templated version directly takes a message object, calculates its size internally, + * and updates the total_size reference. This eliminates the need for a temporary variable + * at the call site. + * + * @tparam MessageType The type of the nested message (inferred from parameter) + * @param message The nested message object + */ + template + static inline void add_message_object(uint32_t &total_size, uint32_t field_id_size, const MessageType &message, + bool force = false) { + uint32_t nested_size = 0; + message.calculate_size(nested_size); + + // Use the base implementation with the calculated nested_size + add_message_field(total_size, field_id_size, nested_size, force); + } + + /** + * @brief Calculates and adds the sizes of all messages in a repeated field to the total message size + * + * This helper processes a vector of message objects, calculating the size for each message + * and adding it to the total size. + * + * @tparam MessageType The type of the nested messages in the vector + * @param messages Vector of message objects + */ + template + static inline void add_repeated_message(uint32_t &total_size, uint32_t field_id_size, + const std::vector &messages) { + // Skip if the vector is empty + if (messages.empty()) { + return; + } + + // For repeated fields, always use force=true + for (const auto &message : messages) { + add_message_object(total_size, field_id_size, message, true); + } + } +}; + +} // namespace api +} // namespace esphome diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index ccc6c0d52c..81e20d47be 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -276,6 +276,7 @@ class ProtoMessage { virtual ~ProtoMessage() = default; virtual void encode(ProtoWriteBuffer buffer) const = 0; void decode(const uint8_t *buffer, size_t length); + virtual void calculate_size(uint32_t &total_size) const = 0; #ifdef HAS_PROTO_MESSAGE_DUMP std::string dump() const; virtual void dump_to(std::string &out) const = 0; @@ -302,9 +303,19 @@ class ProtoService { virtual bool send_buffer(ProtoWriteBuffer buffer, uint32_t message_type) = 0; virtual bool read_message(uint32_t msg_size, uint32_t msg_type, uint8_t *msg_data) = 0; + // Optimized method that pre-allocates buffer based on message size template bool send_message_(const C &msg, uint32_t message_type) { + uint32_t msg_size = 0; + msg.calculate_size(msg_size); + + // Create a pre-sized buffer auto buffer = this->create_buffer(); + buffer.get_buffer()->reserve(msg_size); + + // Encode message into the buffer msg.encode(buffer); + + // Send the buffer return this->send_buffer(buffer, message_type); } }; diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index 291a03523e..63c1efa1ee 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -2,6 +2,7 @@ from __future__ import annotations from abc import ABC, abstractmethod +from enum import IntEnum import os from pathlib import Path import re @@ -10,11 +11,29 @@ import sys from textwrap import dedent from typing import Any -# Generate with -# protoc --python_out=script/api_protobuf -I esphome/components/api/ api_options.proto import aioesphomeapi.api_options_pb2 as pb import google.protobuf.descriptor_pb2 as descriptor + +class WireType(IntEnum): + """Protocol Buffer wire types as defined in the protobuf spec. + + As specified in the Protocol Buffers encoding guide: + https://protobuf.dev/programming-guides/encoding/#structure + """ + + VARINT = 0 # int32, int64, uint32, uint64, sint32, sint64, bool, enum + FIXED64 = 1 # fixed64, sfixed64, double + LENGTH_DELIMITED = 2 # string, bytes, embedded messages, packed repeated fields + START_GROUP = 3 # groups (deprecated) + END_GROUP = 4 # groups (deprecated) + FIXED32 = 5 # fixed32, sfixed32, float + + +# Generate with +# protoc --python_out=script/api_protobuf -I esphome/components/api/ api_options.proto + + """Python 3 script to automatically generate C++ classes for ESPHome's native API. It's pretty crappy spaghetti code, but it works. @@ -35,7 +54,7 @@ will be generated, they still need to be formatted FILE_HEADER = """// This file was automatically generated with a tool. -// See scripts/api_protobuf/api_protobuf.py +// See script/api_protobuf/api_protobuf.py """ @@ -63,6 +82,11 @@ def camel_to_snake(name: str) -> str: return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() +def force_str(force: bool) -> str: + """Convert a boolean force value to string format for C++ code.""" + return str(force).lower() + + class TypeInfo(ABC): """Base class for all type information.""" @@ -99,6 +123,11 @@ class TypeInfo(ABC): """Check if the field is repeated.""" return self._field.label == 3 + @property + def wire_type(self) -> WireType: + """Get the wire type for the field.""" + raise NotImplementedError + @property def cpp_type(self) -> str: raise NotImplementedError @@ -200,6 +229,35 @@ class TypeInfo(ABC): def dump(self, name: str) -> str: """Dump the value to the output.""" + def calculate_field_id_size(self) -> int: + """Calculates the size of a field ID in bytes. + + Returns: + The number of bytes needed to encode the field ID + """ + # Calculate the tag by combining field_id and wire_type + tag = (self.number << 3) | (self.wire_type & 0b111) + + # Calculate the varint size + if tag < 128: + return 1 # 7 bits + if tag < 16384: + return 2 # 14 bits + if tag < 2097152: + return 3 # 21 bits + if tag < 268435456: + return 4 # 28 bits + return 5 # 32 bits (maximum for uint32_t) + + @abstractmethod + def get_size_calculation(self, name: str, force: bool = False) -> str: + """Calculate the size needed for encoding this field. + + Args: + name: The name of the field + force: Whether to force encoding the field even if it has a default value + """ + TYPE_INFO: dict[int, TypeInfo] = {} @@ -221,12 +279,18 @@ class DoubleType(TypeInfo): default_value = "0.0" decode_64bit = "value.as_double()" encode_func = "encode_double" + wire_type = WireType.FIXED64 # Uses wire type 1 according to protobuf spec def dump(self, name: str) -> str: o = f'sprintf(buffer, "%g", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_fixed_field<8>(total_size, {field_id_size}, {name} != 0.0, {force_str(force)});" + return o + @register_type(2) class FloatType(TypeInfo): @@ -234,12 +298,18 @@ class FloatType(TypeInfo): default_value = "0.0f" decode_32bit = "value.as_float()" encode_func = "encode_float" + wire_type = WireType.FIXED32 # Uses wire type 5 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%g", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_fixed_field<4>(total_size, {field_id_size}, {name} != 0.0f, {force_str(force)});" + return o + @register_type(3) class Int64Type(TypeInfo): @@ -247,12 +317,18 @@ class Int64Type(TypeInfo): default_value = "0" decode_varint = "value.as_int64()" encode_func = "encode_int64" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%lld", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_int64_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(4) class UInt64Type(TypeInfo): @@ -260,12 +336,18 @@ class UInt64Type(TypeInfo): default_value = "0" decode_varint = "value.as_uint64()" encode_func = "encode_uint64" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%llu", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_uint64_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(5) class Int32Type(TypeInfo): @@ -273,12 +355,18 @@ class Int32Type(TypeInfo): default_value = "0" decode_varint = "value.as_int32()" encode_func = "encode_int32" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%" PRId32, {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_int32_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(6) class Fixed64Type(TypeInfo): @@ -286,12 +374,18 @@ class Fixed64Type(TypeInfo): default_value = "0" decode_64bit = "value.as_fixed64()" encode_func = "encode_fixed64" + wire_type = WireType.FIXED64 # Uses wire type 1 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%llu", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_fixed_field<8>(total_size, {field_id_size}, {name} != 0, {force_str(force)});" + return o + @register_type(7) class Fixed32Type(TypeInfo): @@ -299,12 +393,18 @@ class Fixed32Type(TypeInfo): default_value = "0" decode_32bit = "value.as_fixed32()" encode_func = "encode_fixed32" + wire_type = WireType.FIXED32 # Uses wire type 5 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%" PRIu32, {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_fixed_field<4>(total_size, {field_id_size}, {name} != 0, {force_str(force)});" + return o + @register_type(8) class BoolType(TypeInfo): @@ -312,11 +412,17 @@ class BoolType(TypeInfo): default_value = "false" decode_varint = "value.as_bool()" encode_func = "encode_bool" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f"out.append(YESNO({name}));" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_bool_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(9) class StringType(TypeInfo): @@ -326,11 +432,17 @@ class StringType(TypeInfo): const_reference_type = "const std::string &" decode_length = "value.as_string()" encode_func = "encode_string" + wire_type = WireType.LENGTH_DELIMITED # Uses wire type 2 def dump(self, name): o = f'out.append("\'").append({name}).append("\'");' return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_string_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(11) class MessageType(TypeInfo): @@ -339,6 +451,7 @@ class MessageType(TypeInfo): return self._field.type_name[1:] default_value = "" + wire_type = WireType.LENGTH_DELIMITED # Uses wire type 2 @property def reference_type(self) -> str: @@ -360,6 +473,11 @@ class MessageType(TypeInfo): o = f"{name}.dump_to(out);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_message_object(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(12) class BytesType(TypeInfo): @@ -369,11 +487,17 @@ class BytesType(TypeInfo): const_reference_type = "const std::string &" decode_length = "value.as_string()" encode_func = "encode_string" + wire_type = WireType.LENGTH_DELIMITED # Uses wire type 2 def dump(self, name: str) -> str: o = f'out.append("\'").append({name}).append("\'");' return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_string_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(13) class UInt32Type(TypeInfo): @@ -381,12 +505,18 @@ class UInt32Type(TypeInfo): default_value = "0" decode_varint = "value.as_uint32()" encode_func = "encode_uint32" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%" PRIu32, {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_uint32_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(14) class EnumType(TypeInfo): @@ -399,6 +529,7 @@ class EnumType(TypeInfo): return f"value.as_enum<{self.cpp_type}>()" default_value = "" + wire_type = WireType.VARINT # Uses wire type 0 @property def encode_func(self) -> str: @@ -408,6 +539,11 @@ class EnumType(TypeInfo): o = f"out.append(proto_enum_to_string<{self.cpp_type}>({name}));" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_enum_field(total_size, {field_id_size}, static_cast({name}), {force_str(force)});" + return o + @register_type(15) class SFixed32Type(TypeInfo): @@ -415,12 +551,18 @@ class SFixed32Type(TypeInfo): default_value = "0" decode_32bit = "value.as_sfixed32()" encode_func = "encode_sfixed32" + wire_type = WireType.FIXED32 # Uses wire type 5 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%" PRId32, {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_fixed_field<4>(total_size, {field_id_size}, {name} != 0, {force_str(force)});" + return o + @register_type(16) class SFixed64Type(TypeInfo): @@ -428,12 +570,18 @@ class SFixed64Type(TypeInfo): default_value = "0" decode_64bit = "value.as_sfixed64()" encode_func = "encode_sfixed64" + wire_type = WireType.FIXED64 # Uses wire type 1 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%lld", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_fixed_field<8>(total_size, {field_id_size}, {name} != 0, {force_str(force)});" + return o + @register_type(17) class SInt32Type(TypeInfo): @@ -441,12 +589,18 @@ class SInt32Type(TypeInfo): default_value = "0" decode_varint = "value.as_sint32()" encode_func = "encode_sint32" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%" PRId32, {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_sint32_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + @register_type(18) class SInt64Type(TypeInfo): @@ -454,12 +608,18 @@ class SInt64Type(TypeInfo): default_value = "0" decode_varint = "value.as_sint64()" encode_func = "encode_sint64" + wire_type = WireType.VARINT # Uses wire type 0 def dump(self, name: str) -> str: o = f'sprintf(buffer, "%lld", {name});\n' o += "out.append(buffer);" return o + def get_size_calculation(self, name: str, force: bool = False) -> str: + field_id_size = self.calculate_field_id_size() + o = f"ProtoSize::add_sint64_field(total_size, {field_id_size}, {name}, {force_str(force)});" + return o + class RepeatedTypeInfo(TypeInfo): def __init__(self, field: descriptor.FieldDescriptorProto) -> None: @@ -478,6 +638,14 @@ class RepeatedTypeInfo(TypeInfo): def const_reference_type(self) -> str: return f"const {self.cpp_type} &" + @property + def wire_type(self) -> WireType: + """Get the wire type for this repeated field. + + For repeated fields, we use the same wire type as the underlying field. + """ + return self._ti.wire_type + @property def decode_varint_content(self) -> str: content = self._ti.decode_varint @@ -554,6 +722,22 @@ class RepeatedTypeInfo(TypeInfo): def dump(self, _: str): pass + def get_size_calculation(self, name: str, force: bool = False) -> str: + # For repeated fields, we always need to pass force=True to the underlying type's calculation + # This is because the encode method always sets force=true for repeated fields + if isinstance(self._ti, MessageType): + # For repeated messages, use the dedicated helper that handles iteration internally + field_id_size = self._ti.calculate_field_id_size() + o = f"ProtoSize::add_repeated_message(total_size, {field_id_size}, {name});" + return o + # For other repeated types, use the underlying type's size calculation with force=True + o = f"if (!{name}.empty()) {{\n" + o += f" for (const auto {'' if self._ti_is_bool else '&'}it : {name}) {{\n" + o += f" {self._ti.get_size_calculation('it', True)}\n" + o += " }\n" + o += "}" + return o + def build_enum_type(desc) -> tuple[str, str]: """Builds the enum type.""" @@ -587,6 +771,7 @@ def build_message_type(desc: descriptor.DescriptorProto) -> tuple[str, str]: decode_64bit: list[str] = [] encode: list[str] = [] dump: list[str] = [] + size_calc: list[str] = [] for field in desc.field: if field.label == 3: @@ -596,6 +781,7 @@ def build_message_type(desc: descriptor.DescriptorProto) -> tuple[str, str]: protected_content.extend(ti.protected_content) public_content.extend(ti.public_content) encode.append(ti.encode_content) + size_calc.append(ti.get_size_calculation(f"this->{ti.field_name}")) if ti.decode_varint_content: decode_varint.append(ti.decode_varint_content) @@ -662,6 +848,25 @@ def build_message_type(desc: descriptor.DescriptorProto) -> tuple[str, str]: prot = "void encode(ProtoWriteBuffer buffer) const override;" public_content.append(prot) + # Add calculate_size method + o = f"void {desc.name}::calculate_size(uint32_t &total_size) const {{" + + # Add a check for empty/default objects to short-circuit the calculation + # Only add this optimization if we have fields to check + if size_calc: + # For a single field, just inline it for simplicity + if len(size_calc) == 1 and len(size_calc[0]) + len(o) + 3 < 120: + o += f" {size_calc[0]} " + else: + # For multiple fields, add a short-circuit check + o += "\n" + # Performance optimization: add all the size calculations + o += indent("\n".join(size_calc)) + "\n" + o += "}\n" + cpp += o + prot = "void calculate_size(uint32_t &total_size) const override;" + public_content.append(prot) + o = f"void {desc.name}::dump_to(std::string &out) const {{" if dump: if len(dump) == 1 and len(dump[0]) + len(o) + 3 < 120: @@ -796,6 +1001,7 @@ def main() -> None: #pragma once #include "proto.h" + #include "api_pb2_size.h" namespace esphome { namespace api { @@ -805,6 +1011,7 @@ def main() -> None: cpp = FILE_HEADER cpp += """\ #include "api_pb2.h" + #include "api_pb2_size.h" #include "esphome/core/log.h" #include