diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 54c54cf80f..4c0e20e0f0 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -31,16 +31,6 @@ bool HelloRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) return false; } } -void HelloRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->client_info); - 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); - ProtoSize::add_uint32_field(total_size, 1, this->api_version_major); - ProtoSize::add_uint32_field(total_size, 1, this->api_version_minor); -} void HelloResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->api_version_major); buffer.encode_uint32(2, this->api_version_minor); @@ -63,10 +53,6 @@ bool ConnectRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value return false; } } -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); -} 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); @@ -318,28 +304,6 @@ bool CoverCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void CoverCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_legacy_command); - buffer.encode_uint32(3, static_cast(this->legacy_command)); - buffer.encode_bool(4, this->has_position); - buffer.encode_float(5, this->position); - buffer.encode_bool(6, this->has_tilt); - buffer.encode_float(7, this->tilt); - buffer.encode_bool(8, this->stop); - buffer.encode_uint32(9, this->device_id); -} -void CoverCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_legacy_command); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->legacy_command)); - ProtoSize::add_bool_field(total_size, 1, this->has_position); - ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_tilt); - ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->stop); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_FAN void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const { @@ -472,38 +436,6 @@ bool FanCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void FanCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_state); - buffer.encode_bool(3, this->state); - buffer.encode_bool(4, this->has_speed); - buffer.encode_uint32(5, static_cast(this->speed)); - buffer.encode_bool(6, this->has_oscillating); - buffer.encode_bool(7, this->oscillating); - buffer.encode_bool(8, this->has_direction); - buffer.encode_uint32(9, static_cast(this->direction)); - buffer.encode_bool(10, this->has_speed_level); - buffer.encode_int32(11, this->speed_level); - buffer.encode_bool(12, this->has_preset_mode); - buffer.encode_string(13, this->preset_mode); - buffer.encode_uint32(14, this->device_id); -} -void FanCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_state); - ProtoSize::add_bool_field(total_size, 1, this->state); - ProtoSize::add_bool_field(total_size, 1, this->has_speed); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->speed)); - ProtoSize::add_bool_field(total_size, 1, this->has_oscillating); - ProtoSize::add_bool_field(total_size, 1, this->oscillating); - ProtoSize::add_bool_field(total_size, 1, this->has_direction); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->direction)); - ProtoSize::add_bool_field(total_size, 1, this->has_speed_level); - ProtoSize::add_int32_field(total_size, 1, this->speed_level); - ProtoSize::add_bool_field(total_size, 1, this->has_preset_mode); - ProtoSize::add_string_field(total_size, 1, this->preset_mode); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_LIGHT void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const { @@ -716,66 +648,6 @@ bool LightCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void LightCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_state); - buffer.encode_bool(3, this->state); - buffer.encode_bool(4, this->has_brightness); - buffer.encode_float(5, this->brightness); - buffer.encode_bool(22, this->has_color_mode); - buffer.encode_uint32(23, static_cast(this->color_mode)); - buffer.encode_bool(20, this->has_color_brightness); - buffer.encode_float(21, this->color_brightness); - buffer.encode_bool(6, this->has_rgb); - buffer.encode_float(7, this->red); - buffer.encode_float(8, this->green); - buffer.encode_float(9, this->blue); - buffer.encode_bool(10, this->has_white); - buffer.encode_float(11, this->white); - buffer.encode_bool(12, this->has_color_temperature); - buffer.encode_float(13, this->color_temperature); - buffer.encode_bool(24, this->has_cold_white); - buffer.encode_float(25, this->cold_white); - buffer.encode_bool(26, this->has_warm_white); - buffer.encode_float(27, this->warm_white); - buffer.encode_bool(14, this->has_transition_length); - buffer.encode_uint32(15, this->transition_length); - buffer.encode_bool(16, this->has_flash_length); - buffer.encode_uint32(17, this->flash_length); - buffer.encode_bool(18, this->has_effect); - buffer.encode_string(19, this->effect); - buffer.encode_uint32(28, this->device_id); -} -void LightCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_state); - ProtoSize::add_bool_field(total_size, 1, this->state); - ProtoSize::add_bool_field(total_size, 1, this->has_brightness); - ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f); - ProtoSize::add_bool_field(total_size, 2, this->has_color_mode); - ProtoSize::add_enum_field(total_size, 2, static_cast(this->color_mode)); - ProtoSize::add_bool_field(total_size, 2, this->has_color_brightness); - ProtoSize::add_fixed_field<4>(total_size, 2, this->color_brightness != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_rgb); - ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f); - ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f); - ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_white); - ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_color_temperature); - ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f); - ProtoSize::add_bool_field(total_size, 2, this->has_cold_white); - ProtoSize::add_fixed_field<4>(total_size, 2, this->cold_white != 0.0f); - ProtoSize::add_bool_field(total_size, 2, this->has_warm_white); - ProtoSize::add_fixed_field<4>(total_size, 2, this->warm_white != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_transition_length); - ProtoSize::add_uint32_field(total_size, 1, this->transition_length); - ProtoSize::add_bool_field(total_size, 2, this->has_flash_length); - ProtoSize::add_uint32_field(total_size, 2, this->flash_length); - ProtoSize::add_bool_field(total_size, 2, this->has_effect); - ProtoSize::add_string_field(total_size, 2, this->effect); - ProtoSize::add_uint32_field(total_size, 2, this->device_id); -} #endif #ifdef USE_SENSOR void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const { @@ -882,16 +754,6 @@ bool SwitchCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void SwitchCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->state); - buffer.encode_uint32(3, this->device_id); -} -void SwitchCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->state); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_TEXT_SENSOR void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const { @@ -943,14 +805,6 @@ bool SubscribeLogsRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { return false; } } -void SubscribeLogsRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint32(1, static_cast(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)); - ProtoSize::add_bool_field(total_size, 1, this->dump_config); -} void SubscribeLogsResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, static_cast(this->level)); buffer.encode_bytes(3, reinterpret_cast(this->message.data()), this->message.size()); @@ -972,12 +826,6 @@ bool NoiseEncryptionSetKeyRequest::decode_length(uint32_t field_id, ProtoLengthD return false; } } -void NoiseEncryptionSetKeyRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_bytes(1, reinterpret_cast(this->key.data()), this->key.size()); -} -void NoiseEncryptionSetKeyRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_string_field(total_size, 1, this->key); -} 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); @@ -1053,16 +901,6 @@ bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDel return false; } } -void HomeAssistantStateResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->entity_id); - 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); - ProtoSize::add_string_field(total_size, 1, this->state); - ProtoSize::add_string_field(total_size, 1, this->attribute); -} bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) { switch (field_id) { case 1: { @@ -1237,16 +1075,6 @@ bool ExecuteServiceRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void ExecuteServiceRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - for (auto &it : this->args) { - 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); - ProtoSize::add_repeated_message(total_size, 1, this->args); -} #endif #ifdef USE_CAMERA void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const { @@ -1295,14 +1123,6 @@ bool CameraImageRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { return false; } } -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); - ProtoSize::add_bool_field(total_size, 1, this->stream); -} #endif #ifdef USE_CLIMATE void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const { @@ -1547,58 +1367,6 @@ bool ClimateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void ClimateCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_mode); - buffer.encode_uint32(3, static_cast(this->mode)); - buffer.encode_bool(4, this->has_target_temperature); - buffer.encode_float(5, this->target_temperature); - buffer.encode_bool(6, this->has_target_temperature_low); - buffer.encode_float(7, this->target_temperature_low); - buffer.encode_bool(8, this->has_target_temperature_high); - buffer.encode_float(9, this->target_temperature_high); - buffer.encode_bool(10, this->unused_has_legacy_away); - buffer.encode_bool(11, this->unused_legacy_away); - buffer.encode_bool(12, this->has_fan_mode); - buffer.encode_uint32(13, static_cast(this->fan_mode)); - buffer.encode_bool(14, this->has_swing_mode); - buffer.encode_uint32(15, static_cast(this->swing_mode)); - buffer.encode_bool(16, this->has_custom_fan_mode); - buffer.encode_string(17, this->custom_fan_mode); - buffer.encode_bool(18, this->has_preset); - buffer.encode_uint32(19, static_cast(this->preset)); - buffer.encode_bool(20, this->has_custom_preset); - buffer.encode_string(21, this->custom_preset); - buffer.encode_bool(22, this->has_target_humidity); - buffer.encode_float(23, this->target_humidity); - buffer.encode_uint32(24, this->device_id); -} -void ClimateCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_mode); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode)); - ProtoSize::add_bool_field(total_size, 1, this->has_target_temperature); - ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_target_temperature_low); - ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_target_temperature_high); - ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->unused_has_legacy_away); - ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away); - ProtoSize::add_bool_field(total_size, 1, this->has_fan_mode); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->fan_mode)); - ProtoSize::add_bool_field(total_size, 1, this->has_swing_mode); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->swing_mode)); - ProtoSize::add_bool_field(total_size, 2, this->has_custom_fan_mode); - ProtoSize::add_string_field(total_size, 2, this->custom_fan_mode); - ProtoSize::add_bool_field(total_size, 2, this->has_preset); - ProtoSize::add_enum_field(total_size, 2, static_cast(this->preset)); - ProtoSize::add_bool_field(total_size, 2, this->has_custom_preset); - ProtoSize::add_string_field(total_size, 2, this->custom_preset); - ProtoSize::add_bool_field(total_size, 2, this->has_target_humidity); - ProtoSize::add_fixed_field<4>(total_size, 2, this->target_humidity != 0.0f); - ProtoSize::add_uint32_field(total_size, 2, this->device_id); -} #endif #ifdef USE_NUMBER void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const { @@ -1669,16 +1437,6 @@ bool NumberCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void NumberCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_float(2, this->state); - buffer.encode_uint32(3, this->device_id); -} -void NumberCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_SELECT void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const { @@ -1751,16 +1509,6 @@ bool SelectCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void SelectCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_string(2, this->state); - buffer.encode_uint32(3, this->device_id); -} -void SelectCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_string_field(total_size, 1, this->state); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_SIREN void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const { @@ -1863,30 +1611,6 @@ bool SirenCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void SirenCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_state); - buffer.encode_bool(3, this->state); - buffer.encode_bool(4, this->has_tone); - buffer.encode_string(5, this->tone); - buffer.encode_bool(6, this->has_duration); - buffer.encode_uint32(7, this->duration); - buffer.encode_bool(8, this->has_volume); - buffer.encode_float(9, this->volume); - buffer.encode_uint32(10, this->device_id); -} -void SirenCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_state); - ProtoSize::add_bool_field(total_size, 1, this->state); - ProtoSize::add_bool_field(total_size, 1, this->has_tone); - ProtoSize::add_string_field(total_size, 1, this->tone); - ProtoSize::add_bool_field(total_size, 1, this->has_duration); - ProtoSize::add_uint32_field(total_size, 1, this->duration); - ProtoSize::add_bool_field(total_size, 1, this->has_volume); - ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_LOCK void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const { @@ -1965,20 +1689,6 @@ bool LockCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void LockCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_uint32(2, static_cast(this->command)); - buffer.encode_bool(3, this->has_code); - buffer.encode_string(4, this->code); - buffer.encode_uint32(5, this->device_id); -} -void LockCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->command)); - ProtoSize::add_bool_field(total_size, 1, this->has_code); - ProtoSize::add_string_field(total_size, 1, this->code); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_BUTTON void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const { @@ -2023,14 +1733,6 @@ bool ButtonCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void ButtonCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_uint32(2, this->device_id); -} -void ButtonCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_MEDIA_PLAYER bool MediaPlayerSupportedFormat::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2177,30 +1879,6 @@ bool MediaPlayerCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value return false; } } -void MediaPlayerCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_command); - buffer.encode_uint32(3, static_cast(this->command)); - buffer.encode_bool(4, this->has_volume); - buffer.encode_float(5, this->volume); - buffer.encode_bool(6, this->has_media_url); - buffer.encode_string(7, this->media_url); - buffer.encode_bool(8, this->has_announcement); - buffer.encode_bool(9, this->announcement); - buffer.encode_uint32(10, this->device_id); -} -void MediaPlayerCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_command); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->command)); - ProtoSize::add_bool_field(total_size, 1, this->has_volume); - ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->has_media_url); - ProtoSize::add_string_field(total_size, 1, this->media_url); - ProtoSize::add_bool_field(total_size, 1, this->has_announcement); - ProtoSize::add_bool_field(total_size, 1, this->announcement); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_BLUETOOTH_PROXY bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2213,12 +1891,6 @@ bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, return false; } } -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); -} bool BluetoothServiceData::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 2: { @@ -2357,18 +2029,6 @@ bool BluetoothDeviceRequest::decode_varint(uint32_t field_id, ProtoVarInt value) return false; } } -void BluetoothDeviceRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint64(1, this->address); - buffer.encode_uint32(2, static_cast(this->request_type)); - 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); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->request_type)); - ProtoSize::add_bool_field(total_size, 1, this->has_address_type); - ProtoSize::add_uint32_field(total_size, 1, this->address_type); -} void BluetoothDeviceConnectionResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_bool(2, this->connected); @@ -2391,10 +2051,6 @@ bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, ProtoVarI return false; } } -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); -} bool BluetoothGATTDescriptor::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 1: { @@ -2545,14 +2201,6 @@ bool BluetoothGATTReadRequest::decode_varint(uint32_t field_id, ProtoVarInt valu return false; } } -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); - ProtoSize::add_uint32_field(total_size, 1, this->handle); -} void BluetoothGATTReadResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_uint32(2, this->handle); @@ -2591,18 +2239,6 @@ bool BluetoothGATTWriteRequest::decode_length(uint32_t field_id, ProtoLengthDeli return false; } } -void BluetoothGATTWriteRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint64(1, this->address); - buffer.encode_uint32(2, this->handle); - buffer.encode_bool(3, this->response); - buffer.encode_bytes(4, reinterpret_cast(this->data.data()), this->data.size()); -} -void BluetoothGATTWriteRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_uint64_field(total_size, 1, this->address); - ProtoSize::add_uint32_field(total_size, 1, this->handle); - ProtoSize::add_bool_field(total_size, 1, this->response); - ProtoSize::add_string_field(total_size, 1, this->data); -} bool BluetoothGATTReadDescriptorRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 1: { @@ -2617,14 +2253,6 @@ bool BluetoothGATTReadDescriptorRequest::decode_varint(uint32_t field_id, ProtoV return false; } } -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); - ProtoSize::add_uint32_field(total_size, 1, this->handle); -} bool BluetoothGATTWriteDescriptorRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 1: { @@ -2649,16 +2277,6 @@ bool BluetoothGATTWriteDescriptorRequest::decode_length(uint32_t field_id, Proto return false; } } -void BluetoothGATTWriteDescriptorRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint64(1, this->address); - buffer.encode_uint32(2, this->handle); - buffer.encode_bytes(3, reinterpret_cast(this->data.data()), this->data.size()); -} -void BluetoothGATTWriteDescriptorRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_uint64_field(total_size, 1, this->address); - ProtoSize::add_uint32_field(total_size, 1, this->handle); - ProtoSize::add_string_field(total_size, 1, this->data); -} bool BluetoothGATTNotifyRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 1: { @@ -2677,16 +2295,6 @@ bool BluetoothGATTNotifyRequest::decode_varint(uint32_t field_id, ProtoVarInt va return false; } } -void BluetoothGATTNotifyRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint64(1, this->address); - 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); - ProtoSize::add_uint32_field(total_size, 1, this->handle); - ProtoSize::add_bool_field(total_size, 1, this->enable); -} void BluetoothGATTNotifyDataResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint64(1, this->address); buffer.encode_uint32(2, this->handle); @@ -2787,12 +2395,6 @@ bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, ProtoVarIn return false; } } -void BluetoothScannerSetModeRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint32(1, static_cast(this->mode)); -} -void BluetoothScannerSetModeRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_enum_field(total_size, 1, static_cast(this->mode)); -} #endif #ifdef USE_VOICE_ASSISTANT bool SubscribeVoiceAssistantRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { @@ -2809,14 +2411,6 @@ bool SubscribeVoiceAssistantRequest::decode_varint(uint32_t field_id, ProtoVarIn return false; } } -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); - ProtoSize::add_uint32_field(total_size, 1, this->flags); -} bool VoiceAssistantAudioSettings::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 1: { @@ -2879,14 +2473,6 @@ bool VoiceAssistantResponse::decode_varint(uint32_t field_id, ProtoVarInt value) return false; } } -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); - ProtoSize::add_bool_field(total_size, 1, this->error); -} bool VoiceAssistantEventData::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { @@ -2930,16 +2516,6 @@ bool VoiceAssistantEventResponse::decode_length(uint32_t field_id, ProtoLengthDe return false; } } -void VoiceAssistantEventResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint32(1, static_cast(this->event_type)); - for (auto &it : this->data) { - 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)); - ProtoSize::add_repeated_message(total_size, 1, this->data); -} bool VoiceAssistantAudio::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 2: { @@ -3004,22 +2580,6 @@ bool VoiceAssistantTimerEventResponse::decode_length(uint32_t field_id, ProtoLen return false; } } -void VoiceAssistantTimerEventResponse::encode(ProtoWriteBuffer buffer) const { - buffer.encode_uint32(1, static_cast(this->event_type)); - buffer.encode_string(2, this->timer_id); - buffer.encode_string(3, this->name); - buffer.encode_uint32(4, this->total_seconds); - 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)); - ProtoSize::add_string_field(total_size, 1, this->timer_id); - ProtoSize::add_string_field(total_size, 1, this->name); - ProtoSize::add_uint32_field(total_size, 1, this->total_seconds); - ProtoSize::add_uint32_field(total_size, 1, this->seconds_left); - ProtoSize::add_bool_field(total_size, 1, this->is_active); -} bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 4: { @@ -3048,18 +2608,6 @@ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLength return false; } } -void VoiceAssistantAnnounceRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_string(1, this->media_id); - buffer.encode_string(2, this->text); - 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); - ProtoSize::add_string_field(total_size, 1, this->text); - ProtoSize::add_string_field(total_size, 1, this->preannounce_media_id); - ProtoSize::add_bool_field(total_size, 1, this->start_conversation); -} 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); @@ -3126,18 +2674,6 @@ bool VoiceAssistantSetConfiguration::decode_length(uint32_t field_id, ProtoLengt return false; } } -void VoiceAssistantSetConfiguration::encode(ProtoWriteBuffer buffer) const { - for (auto &it : this->active_wake_words) { - 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_repeated(total_size, 1, it); - } - } -} #endif #ifdef USE_ALARM_CONTROL_PANEL void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) const { @@ -3210,18 +2746,6 @@ bool AlarmControlPanelCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit return false; } } -void AlarmControlPanelCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_uint32(2, static_cast(this->command)); - buffer.encode_string(3, this->code); - buffer.encode_uint32(4, this->device_id); -} -void AlarmControlPanelCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->command)); - ProtoSize::add_string_field(total_size, 1, this->code); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_TEXT void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const { @@ -3294,16 +2818,6 @@ bool TextCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void TextCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_string(2, this->state); - buffer.encode_uint32(3, this->device_id); -} -void TextCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_string_field(total_size, 1, this->state); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_DATETIME_DATE void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const { @@ -3374,20 +2888,6 @@ bool DateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void DateCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_uint32(2, this->year); - buffer.encode_uint32(3, this->month); - buffer.encode_uint32(4, this->day); - buffer.encode_uint32(5, this->device_id); -} -void DateCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_uint32_field(total_size, 1, this->year); - ProtoSize::add_uint32_field(total_size, 1, this->month); - ProtoSize::add_uint32_field(total_size, 1, this->day); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_DATETIME_TIME void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const { @@ -3458,20 +2958,6 @@ bool TimeCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void TimeCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_uint32(2, this->hour); - buffer.encode_uint32(3, this->minute); - buffer.encode_uint32(4, this->second); - buffer.encode_uint32(5, this->device_id); -} -void TimeCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_uint32_field(total_size, 1, this->hour); - ProtoSize::add_uint32_field(total_size, 1, this->minute); - ProtoSize::add_uint32_field(total_size, 1, this->second); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_EVENT void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const { @@ -3588,20 +3074,6 @@ bool ValveCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void ValveCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_bool(2, this->has_position); - buffer.encode_float(3, this->position); - buffer.encode_bool(4, this->stop); - buffer.encode_uint32(5, this->device_id); -} -void ValveCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_bool_field(total_size, 1, this->has_position); - ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f); - ProtoSize::add_bool_field(total_size, 1, this->stop); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_DATETIME_DATETIME void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const { @@ -3660,16 +3132,6 @@ bool DateTimeCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void DateTimeCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_fixed32(2, this->epoch_seconds); - buffer.encode_uint32(3, this->device_id); -} -void DateTimeCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif #ifdef USE_UPDATE void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const { @@ -3744,16 +3206,6 @@ bool UpdateCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } } -void UpdateCommandRequest::encode(ProtoWriteBuffer buffer) const { - buffer.encode_fixed32(1, this->key); - buffer.encode_uint32(2, static_cast(this->command)); - buffer.encode_uint32(3, this->device_id); -} -void UpdateCommandRequest::calculate_size(uint32_t &total_size) const { - ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0); - ProtoSize::add_enum_field(total_size, 1, static_cast(this->command)); - ProtoSize::add_uint32_field(total_size, 1, this->device_id); -} #endif } // namespace api diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 4f5b09fd82..3f2d4afad3 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -327,8 +327,6 @@ class HelloRequest : public ProtoMessage { std::string client_info{}; 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 @@ -364,8 +362,6 @@ class ConnectRequest : public ProtoMessage { const char *message_name() const override { return "connect_request"; } #endif 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 @@ -649,8 +645,6 @@ class CoverCommandRequest : public CommandProtoMessage { bool has_tilt{false}; 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 @@ -721,8 +715,6 @@ class FanCommandRequest : public CommandProtoMessage { int32_t speed_level{0}; 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 @@ -817,8 +809,6 @@ class LightCommandRequest : public CommandProtoMessage { uint32_t flash_length{0}; 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 @@ -911,8 +901,6 @@ class SwitchCommandRequest : public CommandProtoMessage { const char *message_name() const override { return "switch_command_request"; } #endif 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 @@ -966,8 +954,6 @@ class SubscribeLogsRequest : public ProtoMessage { #endif 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 @@ -1002,8 +988,6 @@ class NoiseEncryptionSetKeyRequest : public ProtoMessage { const char *message_name() const override { return "noise_encryption_set_key_request"; } #endif 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 @@ -1115,8 +1099,6 @@ class HomeAssistantStateResponse : public ProtoMessage { std::string entity_id{}; 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 @@ -1218,8 +1200,6 @@ class ExecuteServiceRequest : public ProtoMessage { #endif 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 @@ -1271,8 +1251,6 @@ class CameraImageRequest : public ProtoMessage { #endif 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 @@ -1373,8 +1351,6 @@ class ClimateCommandRequest : public CommandProtoMessage { std::string custom_preset{}; 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 @@ -1432,8 +1408,6 @@ class NumberCommandRequest : public CommandProtoMessage { const char *message_name() const override { return "number_command_request"; } #endif 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 @@ -1485,8 +1459,6 @@ class SelectCommandRequest : public CommandProtoMessage { const char *message_name() const override { return "select_command_request"; } #endif 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 @@ -1547,8 +1519,6 @@ class SirenCommandRequest : public CommandProtoMessage { uint32_t duration{0}; bool has_volume{false}; float volume{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 @@ -1605,8 +1575,6 @@ class LockCommandRequest : public CommandProtoMessage { enums::LockCommand command{}; 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 @@ -1641,8 +1609,6 @@ class ButtonCommandRequest : public CommandProtoMessage { #ifdef HAS_PROTO_MESSAGE_DUMP const char *message_name() const override { return "button_command_request"; } #endif - 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 @@ -1720,8 +1686,6 @@ class MediaPlayerCommandRequest : public CommandProtoMessage { std::string media_url{}; 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 @@ -1741,8 +1705,6 @@ class SubscribeBluetoothLEAdvertisementsRequest : public ProtoMessage { const char *message_name() const override { return "subscribe_bluetooth_le_advertisements_request"; } #endif 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 @@ -1830,8 +1792,6 @@ class BluetoothDeviceRequest : public ProtoMessage { enums::BluetoothDeviceRequestType request_type{}; 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 @@ -1866,8 +1826,6 @@ class BluetoothGATTGetServicesRequest : public ProtoMessage { const char *message_name() const override { return "bluetooth_gatt_get_services_request"; } #endif 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 @@ -1961,8 +1919,6 @@ class BluetoothGATTReadRequest : public ProtoMessage { #endif 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 @@ -1999,8 +1955,6 @@ class BluetoothGATTWriteRequest : public ProtoMessage { uint32_t handle{0}; 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 @@ -2018,8 +1972,6 @@ class BluetoothGATTReadDescriptorRequest : public ProtoMessage { #endif 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 @@ -2037,8 +1989,6 @@ class BluetoothGATTWriteDescriptorRequest : public ProtoMessage { uint64_t address{0}; 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 @@ -2057,8 +2007,6 @@ class BluetoothGATTNotifyRequest : public ProtoMessage { uint64_t address{0}; 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 @@ -2259,8 +2207,6 @@ class BluetoothScannerSetModeRequest : public ProtoMessage { const char *message_name() const override { return "bluetooth_scanner_set_mode_request"; } #endif 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 @@ -2279,8 +2225,6 @@ class SubscribeVoiceAssistantRequest : public ProtoMessage { #endif 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 @@ -2332,8 +2276,6 @@ class VoiceAssistantResponse : public ProtoMessage { #endif 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 @@ -2363,8 +2305,6 @@ class VoiceAssistantEventResponse : public ProtoMessage { #endif 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 @@ -2405,8 +2345,6 @@ class VoiceAssistantTimerEventResponse : public ProtoMessage { uint32_t total_seconds{0}; 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 @@ -2426,8 +2364,6 @@ class VoiceAssistantAnnounceRequest : public ProtoMessage { std::string text{}; 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 @@ -2505,8 +2441,6 @@ class VoiceAssistantSetConfiguration : public ProtoMessage { const char *message_name() const override { return "voice_assistant_set_configuration"; } #endif 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 @@ -2559,8 +2493,6 @@ class AlarmControlPanelCommandRequest : public CommandProtoMessage { #endif 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 @@ -2616,8 +2548,6 @@ class TextCommandRequest : public CommandProtoMessage { const char *message_name() const override { return "text_command_request"; } #endif 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 @@ -2673,8 +2603,6 @@ class DateCommandRequest : public CommandProtoMessage { uint32_t year{0}; 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 @@ -2729,8 +2657,6 @@ class TimeCommandRequest : public CommandProtoMessage { uint32_t hour{0}; 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 @@ -2822,8 +2748,6 @@ class ValveCommandRequest : public CommandProtoMessage { bool has_position{false}; 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 @@ -2874,8 +2798,6 @@ class DateTimeCommandRequest : public CommandProtoMessage { const char *message_name() const override { return "date_time_command_request"; } #endif 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 @@ -2934,8 +2856,6 @@ class UpdateCommandRequest : public CommandProtoMessage { const char *message_name() const override { return "update_command_request"; } #endif 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/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index efc06c1fad..3ae1b195e4 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -1059,9 +1059,10 @@ def build_message_type( # Get message ID if it's a service message message_id: int | None = get_opt(desc, pb.id) - # Get source direction to determine if we need decode methods + # Get source direction to determine if we need decode/encode methods source: int = get_opt(desc, pb.source, SOURCE_BOTH) needs_decode = source in (SOURCE_BOTH, SOURCE_CLIENT) + needs_encode = source in (SOURCE_BOTH, SOURCE_SERVER) # Add MESSAGE_TYPE method if this is a service message if message_id is not None: @@ -1105,9 +1106,10 @@ def build_message_type( protected_content.extend(ti.protected_content) public_content.extend(ti.public_content) - # Always include encode/decode logic for all fields - encode.append(ti.encode_content) - size_calc.append(ti.get_size_calculation(f"this->{ti.field_name}")) + # Only collect encode logic if this message needs it + if needs_encode: + encode.append(ti.encode_content) + size_calc.append(ti.get_size_calculation(f"this->{ti.field_name}")) # Only collect decode methods if this message needs them if needs_decode: @@ -1164,8 +1166,8 @@ def build_message_type( prot = "bool decode_64bit(uint32_t field_id, Proto64Bit value) override;" protected_content.insert(0, prot) - # Only generate encode method if there are fields to encode - if encode: + # Only generate encode method if this message needs encoding and has fields + if needs_encode and encode: o = f"void {desc.name}::encode(ProtoWriteBuffer buffer) const {{" if len(encode) == 1 and len(encode[0]) + len(o) + 3 < 120: o += f" {encode[0]} " @@ -1176,10 +1178,10 @@ def build_message_type( cpp += o prot = "void encode(ProtoWriteBuffer buffer) const override;" public_content.append(prot) - # If no fields to encode, the default implementation in ProtoMessage will be used + # If no fields to encode or message doesn't need encoding, the default implementation in ProtoMessage will be used - # Add calculate_size method only if there are fields - if size_calc: + # Add calculate_size method only if this message needs encoding and has fields + if needs_encode and size_calc: o = f"void {desc.name}::calculate_size(uint32_t &total_size) const {{" # For a single field, just inline it for simplicity if len(size_calc) == 1 and len(size_calc[0]) + len(o) + 3 < 120: @@ -1192,7 +1194,7 @@ def build_message_type( cpp += o prot = "void calculate_size(uint32_t &total_size) const override;" public_content.append(prot) - # If no fields to calculate size for, the default implementation in ProtoMessage will be used + # If no fields to calculate size for or message doesn't need encoding, the default implementation in ProtoMessage will be used # dump_to method declaration in header prot = "#ifdef HAS_PROTO_MESSAGE_DUMP\n"