diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 7d32a5123e7..2458c4b2a5c 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -7,13 +7,17 @@ namespace esphome::api { -bool HelloRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool HelloRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool HelloRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->api_version_major = value.as_uint32(); + this->api_version_major = value; break; case 3: - this->api_version_minor = value.as_uint32(); + this->api_version_minor = value; break; default: return false; @@ -316,20 +320,24 @@ uint32_t CoverStateResponse::calculate_size() const { #endif return size; } -bool CoverCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool CoverCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool CoverCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 4: - this->has_position = value.as_bool(); + this->has_position = value != 0; break; case 6: - this->has_tilt = value.as_bool(); + this->has_tilt = value != 0; break; case 8: - this->stop = value.as_bool(); + this->stop = value != 0; break; #ifdef USE_DEVICES case 9: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -423,38 +431,42 @@ uint32_t FanStateResponse::calculate_size() const { #endif return size; } -bool FanCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool FanCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool FanCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_state = value.as_bool(); + this->has_state = value != 0; break; case 3: - this->state = value.as_bool(); + this->state = value != 0; break; case 6: - this->has_oscillating = value.as_bool(); + this->has_oscillating = value != 0; break; case 7: - this->oscillating = value.as_bool(); + this->oscillating = value != 0; break; case 8: - this->has_direction = value.as_bool(); + this->has_direction = value != 0; break; case 9: - this->direction = static_cast(value.as_uint32()); + this->direction = static_cast(value); break; case 10: - this->has_speed_level = value.as_bool(); + this->has_speed_level = value != 0; break; case 11: - this->speed_level = value.as_int32(); + this->speed_level = static_cast(value); break; case 12: - this->has_preset_mode = value.as_bool(); + this->has_preset_mode = value != 0; break; #ifdef USE_DEVICES case 14: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -571,59 +583,63 @@ uint32_t LightStateResponse::calculate_size() const { #endif return size; } -bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool LightCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool LightCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_state = value.as_bool(); + this->has_state = value != 0; break; case 3: - this->state = value.as_bool(); + this->state = value != 0; break; case 4: - this->has_brightness = value.as_bool(); + this->has_brightness = value != 0; break; case 22: - this->has_color_mode = value.as_bool(); + this->has_color_mode = value != 0; break; case 23: - this->color_mode = static_cast(value.as_uint32()); + this->color_mode = static_cast(value); break; case 20: - this->has_color_brightness = value.as_bool(); + this->has_color_brightness = value != 0; break; case 6: - this->has_rgb = value.as_bool(); + this->has_rgb = value != 0; break; case 10: - this->has_white = value.as_bool(); + this->has_white = value != 0; break; case 12: - this->has_color_temperature = value.as_bool(); + this->has_color_temperature = value != 0; break; case 24: - this->has_cold_white = value.as_bool(); + this->has_cold_white = value != 0; break; case 26: - this->has_warm_white = value.as_bool(); + this->has_warm_white = value != 0; break; case 14: - this->has_transition_length = value.as_bool(); + this->has_transition_length = value != 0; break; case 15: - this->transition_length = value.as_uint32(); + this->transition_length = value; break; case 16: - this->has_flash_length = value.as_bool(); + this->has_flash_length = value != 0; break; case 17: - this->flash_length = value.as_uint32(); + this->flash_length = value; break; case 18: - this->has_effect = value.as_bool(); + this->has_effect = value != 0; break; #ifdef USE_DEVICES case 28: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -787,14 +803,18 @@ uint32_t SwitchStateResponse::calculate_size() const { #endif return size; } -bool SwitchCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SwitchCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SwitchCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->state = value.as_bool(); + this->state = value != 0; break; #ifdef USE_DEVICES case 3: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -863,13 +883,17 @@ uint32_t TextSensorStateResponse::calculate_size() const { return size; } #endif -bool SubscribeLogsRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SubscribeLogsRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SubscribeLogsRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->level = static_cast(value.as_uint32()); + this->level = static_cast(value); break; case 2: - this->dump_config = value.as_bool(); + this->dump_config = value != 0; break; default: return false; @@ -971,13 +995,17 @@ uint32_t HomeassistantActionRequest::calculate_size() const { } #endif #ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES -bool HomeassistantActionResponse::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool HomeassistantActionResponse::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool HomeassistantActionResponse::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->call_id = value.as_uint32(); + this->call_id = value; break; case 2: - this->success = value.as_bool(); + this->success = value != 0; break; default: return false; @@ -1036,38 +1064,46 @@ bool HomeAssistantStateResponse::decode_length(uint32_t field_id, ProtoLengthDel return true; } #endif -bool DSTRule::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool DSTRule::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool DSTRule::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->time_seconds = value.as_sint32(); + this->time_seconds = decode_zigzag32(value); break; case 2: - this->day = value.as_uint32(); + this->day = value; break; case 3: - this->type = static_cast(value.as_uint32()); + this->type = static_cast(value); break; case 4: - this->month = value.as_uint32(); + this->month = value; break; case 5: - this->week = value.as_uint32(); + this->week = value; break; case 6: - this->day_of_week = value.as_uint32(); + this->day_of_week = value; break; default: return false; } return true; } -bool ParsedTimezone::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ParsedTimezone::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ParsedTimezone::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->std_offset_seconds = value.as_sint32(); + this->std_offset_seconds = decode_zigzag32(value); break; case 2: - this->dst_offset_seconds = value.as_sint32(); + this->dst_offset_seconds = decode_zigzag32(value); break; default: return false; @@ -1142,22 +1178,26 @@ uint32_t ListEntitiesServicesResponse::calculate_size() const { size += ProtoSize::calc_uint32(1, static_cast(this->supports_response)); return size; } -bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ExecuteServiceArgument::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ExecuteServiceArgument::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->bool_ = value.as_bool(); + this->bool_ = value != 0; break; case 2: - this->legacy_int = value.as_int32(); + this->legacy_int = static_cast(value); break; case 5: - this->int_ = value.as_sint32(); + this->int_ = decode_zigzag32(value); break; case 6: - this->bool_array.push_back(value.as_bool()); + this->bool_array.push_back(value != 0); break; case 7: - this->int_array.push_back(value.as_sint32()); + this->int_array.push_back(decode_zigzag32(value)); break; default: return false; @@ -1202,16 +1242,20 @@ void ExecuteServiceArgument::decode(const uint8_t *buffer, size_t length) { this->string_array.init(count_string_array); ProtoDecodableMessage::decode(buffer, length); } -bool ExecuteServiceRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ExecuteServiceRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ExecuteServiceRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES case 3: - this->call_id = value.as_uint32(); + this->call_id = value; break; #endif #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES case 4: - this->return_response = value.as_bool(); + this->return_response = value != 0; break; #endif default: @@ -1313,13 +1357,17 @@ uint32_t CameraImageResponse::calculate_size() const { #endif return size; } -bool CameraImageRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool CameraImageRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool CameraImageRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->single = value.as_bool(); + this->single = value != 0; break; case 2: - this->stream = value.as_bool(); + this->stream = value != 0; break; default: return false; @@ -1468,53 +1516,57 @@ uint32_t ClimateStateResponse::calculate_size() const { #endif return size; } -bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ClimateCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ClimateCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_mode = value.as_bool(); + this->has_mode = value != 0; break; case 3: - this->mode = static_cast(value.as_uint32()); + this->mode = static_cast(value); break; case 4: - this->has_target_temperature = value.as_bool(); + this->has_target_temperature = value != 0; break; case 6: - this->has_target_temperature_low = value.as_bool(); + this->has_target_temperature_low = value != 0; break; case 8: - this->has_target_temperature_high = value.as_bool(); + this->has_target_temperature_high = value != 0; break; case 12: - this->has_fan_mode = value.as_bool(); + this->has_fan_mode = value != 0; break; case 13: - this->fan_mode = static_cast(value.as_uint32()); + this->fan_mode = static_cast(value); break; case 14: - this->has_swing_mode = value.as_bool(); + this->has_swing_mode = value != 0; break; case 15: - this->swing_mode = static_cast(value.as_uint32()); + this->swing_mode = static_cast(value); break; case 16: - this->has_custom_fan_mode = value.as_bool(); + this->has_custom_fan_mode = value != 0; break; case 18: - this->has_preset = value.as_bool(); + this->has_preset = value != 0; break; case 19: - this->preset = static_cast(value.as_uint32()); + this->preset = static_cast(value); break; case 20: - this->has_custom_preset = value.as_bool(); + this->has_custom_preset = value != 0; break; case 22: - this->has_target_humidity = value.as_bool(); + this->has_target_humidity = value != 0; break; #ifdef USE_DEVICES case 24: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -1631,21 +1683,25 @@ uint32_t WaterHeaterStateResponse::calculate_size() const { size += ProtoSize::calc_float(1, this->target_temperature_high); return size; } -bool WaterHeaterCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool WaterHeaterCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool WaterHeaterCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_fields = value.as_uint32(); + this->has_fields = value; break; case 3: - this->mode = static_cast(value.as_uint32()); + this->mode = static_cast(value); break; #ifdef USE_DEVICES case 5: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif case 6: - this->state = value.as_uint32(); + this->state = value; break; default: return false; @@ -1731,11 +1787,15 @@ uint32_t NumberStateResponse::calculate_size() const { #endif return size; } -bool NumberCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool NumberCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool NumberCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_DEVICES case 3: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -1812,11 +1872,15 @@ uint32_t SelectStateResponse::calculate_size() const { #endif return size; } -bool SelectCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SelectCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SelectCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_DEVICES case 3: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -1903,29 +1967,33 @@ uint32_t SirenStateResponse::calculate_size() const { #endif return size; } -bool SirenCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SirenCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SirenCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_state = value.as_bool(); + this->has_state = value != 0; break; case 3: - this->state = value.as_bool(); + this->state = value != 0; break; case 4: - this->has_tone = value.as_bool(); + this->has_tone = value != 0; break; case 6: - this->has_duration = value.as_bool(); + this->has_duration = value != 0; break; case 7: - this->duration = value.as_uint32(); + this->duration = value; break; case 8: - this->has_volume = value.as_bool(); + this->has_volume = value != 0; break; #ifdef USE_DEVICES case 10: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -2011,17 +2079,21 @@ uint32_t LockStateResponse::calculate_size() const { #endif return size; } -bool LockCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool LockCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool LockCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->command = static_cast(value.as_uint32()); + this->command = static_cast(value); break; case 3: - this->has_code = value.as_bool(); + this->has_code = value != 0; break; #ifdef USE_DEVICES case 5: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -2082,11 +2154,15 @@ uint32_t ListEntitiesButtonResponse::calculate_size() const { #endif return size; } -bool ButtonCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ButtonCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ButtonCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_DEVICES case 2: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -2182,29 +2258,33 @@ uint32_t MediaPlayerStateResponse::calculate_size() const { #endif return size; } -bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_command = value.as_bool(); + this->has_command = value != 0; break; case 3: - this->command = static_cast(value.as_uint32()); + this->command = static_cast(value); break; case 4: - this->has_volume = value.as_bool(); + this->has_volume = value != 0; break; case 6: - this->has_media_url = value.as_bool(); + this->has_media_url = value != 0; break; case 8: - this->has_announcement = value.as_bool(); + this->has_announcement = value != 0; break; case 9: - this->announcement = value.as_bool(); + this->announcement = value != 0; break; #ifdef USE_DEVICES case 10: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -2238,10 +2318,14 @@ bool MediaPlayerCommandRequest::decode_32bit(uint32_t field_id, Proto32Bit value } #endif #ifdef USE_BLUETOOTH_PROXY -bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SubscribeBluetoothLEAdvertisementsRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->flags = value.as_uint32(); + this->flags = value; break; default: return false; @@ -2274,19 +2358,23 @@ uint32_t BluetoothLERawAdvertisementsResponse::calculate_size() const { } return size; } -bool BluetoothDeviceRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothDeviceRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothDeviceRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->request_type = static_cast(value.as_uint32()); + this->request_type = static_cast(value); break; case 3: - this->has_address_type = value.as_bool(); + this->has_address_type = value != 0; break; case 4: - this->address_type = value.as_uint32(); + this->address_type = value; break; default: return false; @@ -2307,10 +2395,14 @@ uint32_t BluetoothDeviceConnectionResponse::calculate_size() const { size += ProtoSize::calc_int32(1, this->error); return size; } -bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothGATTGetServicesRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; default: return false; @@ -2413,13 +2505,17 @@ uint32_t BluetoothGATTGetServicesDoneResponse::calculate_size() const { size += ProtoSize::calc_uint64(1, this->address); return size; } -bool BluetoothGATTReadRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothGATTReadRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothGATTReadRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->handle = value.as_uint32(); + this->handle = value; break; default: return false; @@ -2438,16 +2534,20 @@ uint32_t BluetoothGATTReadResponse::calculate_size() const { size += ProtoSize::calc_length(1, this->data_len_); return size; } -bool BluetoothGATTWriteRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothGATTWriteRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothGATTWriteRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->handle = value.as_uint32(); + this->handle = value; break; case 3: - this->response = value.as_bool(); + this->response = value != 0; break; default: return false; @@ -2466,26 +2566,34 @@ bool BluetoothGATTWriteRequest::decode_length(uint32_t field_id, ProtoLengthDeli } return true; } -bool BluetoothGATTReadDescriptorRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothGATTReadDescriptorRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothGATTReadDescriptorRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->handle = value.as_uint32(); + this->handle = value; break; default: return false; } return true; } -bool BluetoothGATTWriteDescriptorRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothGATTWriteDescriptorRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothGATTWriteDescriptorRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->handle = value.as_uint32(); + this->handle = value; break; default: return false; @@ -2504,16 +2612,20 @@ bool BluetoothGATTWriteDescriptorRequest::decode_length(uint32_t field_id, Proto } return true; } -bool BluetoothGATTNotifyRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothGATTNotifyRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothGATTNotifyRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->handle = value.as_uint32(); + this->handle = value; break; case 3: - this->enable = value.as_bool(); + this->enable = value != 0; break; default: return false; @@ -2632,10 +2744,14 @@ uint32_t BluetoothScannerStateResponse::calculate_size() const { size += ProtoSize::calc_uint32(1, static_cast(this->configured_mode)); return size; } -bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->mode = static_cast(value.as_uint32()); + this->mode = static_cast(value); break; default: return false; @@ -2644,13 +2760,17 @@ bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, ProtoVarIn } #endif #ifdef USE_VOICE_ASSISTANT -bool SubscribeVoiceAssistantRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SubscribeVoiceAssistantRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SubscribeVoiceAssistantRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->subscribe = value.as_bool(); + this->subscribe = value != 0; break; case 2: - this->flags = value.as_uint32(); + this->flags = value; break; default: return false; @@ -2685,13 +2805,17 @@ uint32_t VoiceAssistantRequest::calculate_size() const { size += ProtoSize::calc_length(1, this->wake_word_phrase.size()); return size; } -bool VoiceAssistantResponse::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool VoiceAssistantResponse::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool VoiceAssistantResponse::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->port = value.as_uint32(); + this->port = value; break; case 2: - this->error = value.as_bool(); + this->error = value != 0; break; default: return false; @@ -2713,10 +2837,14 @@ bool VoiceAssistantEventData::decode_length(uint32_t field_id, ProtoLengthDelimi } return true; } -bool VoiceAssistantEventResponse::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool VoiceAssistantEventResponse::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool VoiceAssistantEventResponse::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->event_type = static_cast(value.as_uint32()); + this->event_type = static_cast(value); break; default: return false; @@ -2734,10 +2862,14 @@ bool VoiceAssistantEventResponse::decode_length(uint32_t field_id, ProtoLengthDe } return true; } -bool VoiceAssistantAudio::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool VoiceAssistantAudio::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool VoiceAssistantAudio::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->end = value.as_bool(); + this->end = value != 0; break; default: return false; @@ -2766,19 +2898,23 @@ uint32_t VoiceAssistantAudio::calculate_size() const { size += ProtoSize::calc_bool(1, this->end); return size; } -bool VoiceAssistantTimerEventResponse::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool VoiceAssistantTimerEventResponse::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool VoiceAssistantTimerEventResponse::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->event_type = static_cast(value.as_uint32()); + this->event_type = static_cast(value); break; case 4: - this->total_seconds = value.as_uint32(); + this->total_seconds = value; break; case 5: - this->seconds_left = value.as_uint32(); + this->seconds_left = value; break; case 6: - this->is_active = value.as_bool(); + this->is_active = value != 0; break; default: return false; @@ -2800,10 +2936,14 @@ bool VoiceAssistantTimerEventResponse::decode_length(uint32_t field_id, ProtoLen } return true; } -bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 4: - this->start_conversation = value.as_bool(); + this->start_conversation = value != 0; break; default: return false; @@ -2853,10 +2993,14 @@ uint32_t VoiceAssistantWakeWord::calculate_size() const { } return size; } -bool VoiceAssistantExternalWakeWord::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool VoiceAssistantExternalWakeWord::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool VoiceAssistantExternalWakeWord::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 5: - this->model_size = value.as_uint32(); + this->model_size = value; break; default: return false; @@ -2990,14 +3134,18 @@ uint32_t AlarmControlPanelStateResponse::calculate_size() const { #endif return size; } -bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->command = static_cast(value.as_uint32()); + this->command = static_cast(value); break; #ifdef USE_DEVICES case 4: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3082,11 +3230,15 @@ uint32_t TextStateResponse::calculate_size() const { #endif return size; } -bool TextCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool TextCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool TextCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_DEVICES case 3: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3167,20 +3319,24 @@ uint32_t DateStateResponse::calculate_size() const { #endif return size; } -bool DateCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool DateCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool DateCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->year = value.as_uint32(); + this->year = value; break; case 3: - this->month = value.as_uint32(); + this->month = value; break; case 4: - this->day = value.as_uint32(); + this->day = value; break; #ifdef USE_DEVICES case 5: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3250,20 +3406,24 @@ uint32_t TimeStateResponse::calculate_size() const { #endif return size; } -bool TimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool TimeCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool TimeCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->hour = value.as_uint32(); + this->hour = value; break; case 3: - this->minute = value.as_uint32(); + this->minute = value; break; case 4: - this->second = value.as_uint32(); + this->second = value; break; #ifdef USE_DEVICES case 5: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3393,17 +3553,21 @@ uint32_t ValveStateResponse::calculate_size() const { #endif return size; } -bool ValveCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ValveCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ValveCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->has_position = value.as_bool(); + this->has_position = value != 0; break; case 4: - this->stop = value.as_bool(); + this->stop = value != 0; break; #ifdef USE_DEVICES case 5: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3472,11 +3636,15 @@ uint32_t DateTimeStateResponse::calculate_size() const { #endif return size; } -bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool DateTimeCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool DateTimeCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_DEVICES case 3: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3561,14 +3729,18 @@ uint32_t UpdateStateResponse::calculate_size() const { #endif return size; } -bool UpdateCommandRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool UpdateCommandRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool UpdateCommandRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 2: - this->command = static_cast(value.as_uint32()); + this->command = static_cast(value); break; #ifdef USE_DEVICES case 3: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif default: @@ -3606,10 +3778,14 @@ uint32_t ZWaveProxyFrame::calculate_size() const { size += ProtoSize::calc_length(1, this->data_len); return size; } -bool ZWaveProxyRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool ZWaveProxyRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool ZWaveProxyRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->type = static_cast(value.as_uint32()); + this->type = static_cast(value); break; default: return false; @@ -3672,18 +3848,22 @@ uint32_t ListEntitiesInfraredResponse::calculate_size() const { } #endif #ifdef USE_IR_RF -bool InfraredRFTransmitRawTimingsRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool InfraredRFTransmitRawTimingsRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool InfraredRFTransmitRawTimingsRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { #ifdef USE_DEVICES case 1: - this->device_id = value.as_uint32(); + this->device_id = value; break; #endif case 3: - this->carrier_frequency = value.as_uint32(); + this->carrier_frequency = value; break; case 4: - this->repeat_count = value.as_uint32(); + this->repeat_count = value; break; default: return false; @@ -3737,25 +3917,29 @@ uint32_t InfraredRFReceiveEvent::calculate_size() const { } #endif #ifdef USE_SERIAL_PROXY -bool SerialProxyConfigureRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SerialProxyConfigureRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SerialProxyConfigureRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->instance = value.as_uint32(); + this->instance = value; break; case 2: - this->baudrate = value.as_uint32(); + this->baudrate = value; break; case 3: - this->flow_control = value.as_bool(); + this->flow_control = value != 0; break; case 4: - this->parity = static_cast(value.as_uint32()); + this->parity = static_cast(value); break; case 5: - this->stop_bits = value.as_uint32(); + this->stop_bits = value; break; case 6: - this->data_size = value.as_uint32(); + this->data_size = value; break; default: return false; @@ -3772,10 +3956,14 @@ uint32_t SerialProxyDataReceived::calculate_size() const { size += ProtoSize::calc_length(1, this->data_len_); return size; } -bool SerialProxyWriteRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SerialProxyWriteRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SerialProxyWriteRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->instance = value.as_uint32(); + this->instance = value; break; default: return false; @@ -3794,23 +3982,31 @@ bool SerialProxyWriteRequest::decode_length(uint32_t field_id, ProtoLengthDelimi } return true; } -bool SerialProxySetModemPinsRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SerialProxySetModemPinsRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SerialProxySetModemPinsRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->instance = value.as_uint32(); + this->instance = value; break; case 2: - this->line_states = value.as_uint32(); + this->line_states = value; break; default: return false; } return true; } -bool SerialProxyGetModemPinsRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SerialProxyGetModemPinsRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SerialProxyGetModemPinsRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->instance = value.as_uint32(); + this->instance = value; break; default: return false; @@ -3827,13 +4023,17 @@ uint32_t SerialProxyGetModemPinsResponse::calculate_size() const { size += ProtoSize::calc_uint32(1, this->line_states); return size; } -bool SerialProxyRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool SerialProxyRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool SerialProxyRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->instance = value.as_uint32(); + this->instance = value; break; case 2: - this->type = static_cast(value.as_uint32()); + this->type = static_cast(value); break; default: return false; @@ -3856,22 +4056,26 @@ uint32_t SerialProxyRequestResponse::calculate_size() const { } #endif #ifdef USE_BLUETOOTH_PROXY -bool BluetoothSetConnectionParamsRequest::decode_varint(uint32_t field_id, ProtoVarIntResult value) { +#ifdef USE_API_VARINT64 +bool BluetoothSetConnectionParamsRequest::decode_varint(uint32_t field_id, uint64_t value) { +#else +bool BluetoothSetConnectionParamsRequest::decode_varint(uint32_t field_id, uint32_t value) { +#endif switch (field_id) { case 1: - this->address = value.as_uint64(); + this->address = value; break; case 2: - this->min_interval = value.as_uint32(); + this->min_interval = value; break; case 3: - this->max_interval = value.as_uint32(); + this->max_interval = value; break; case 4: - this->latency = value.as_uint32(); + this->latency = value; break; case 5: - this->timeout = value.as_uint32(); + this->timeout = value; break; default: return false; diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index c777140bda9..de2c0002aef 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -399,7 +399,11 @@ class HelloRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class HelloResponse final : public ProtoMessage { public: @@ -688,7 +692,11 @@ class CoverCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_FAN @@ -756,7 +764,11 @@ class FanCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_LIGHT @@ -846,7 +858,11 @@ class LightCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_SENSOR @@ -936,7 +952,11 @@ class SwitchCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_TEXT_SENSOR @@ -988,7 +1008,11 @@ class SubscribeLogsRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class SubscribeLogsResponse final : public ProtoMessage { public: @@ -1110,7 +1134,11 @@ class HomeassistantActionResponse final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_API_HOMEASSISTANT_STATES @@ -1176,7 +1204,11 @@ class DSTRule final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class ParsedTimezone final : public ProtoDecodableMessage { public: @@ -1190,7 +1222,11 @@ class ParsedTimezone final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class GetTimeResponse final : public ProtoDecodableMessage { public: @@ -1261,7 +1297,11 @@ class ExecuteServiceArgument final : public ProtoDecodableMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class ExecuteServiceRequest final : public ProtoDecodableMessage { public: @@ -1286,7 +1326,11 @@ class ExecuteServiceRequest final : public ProtoDecodableMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_API_USER_DEFINED_ACTION_RESPONSES @@ -1365,7 +1409,11 @@ class CameraImageRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_CLIMATE @@ -1464,7 +1512,11 @@ class ClimateCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_WATER_HEATER @@ -1528,7 +1580,11 @@ class WaterHeaterCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_NUMBER @@ -1584,7 +1640,11 @@ class NumberCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_SELECT @@ -1636,7 +1696,11 @@ class SelectCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_SIREN @@ -1696,7 +1760,11 @@ class SirenCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_LOCK @@ -1752,7 +1820,11 @@ class LockCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_BUTTON @@ -1785,7 +1857,11 @@ class ButtonCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_MEDIA_PLAYER @@ -1862,7 +1938,11 @@ class MediaPlayerCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_BLUETOOTH_PROXY @@ -1879,7 +1959,11 @@ class SubscribeBluetoothLEAdvertisementsRequest final : public ProtoDecodableMes #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothLERawAdvertisement final : public ProtoMessage { public: @@ -1929,7 +2013,11 @@ class BluetoothDeviceRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothDeviceConnectionResponse final : public ProtoMessage { public: @@ -1963,7 +2051,11 @@ class BluetoothGATTGetServicesRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothGATTDescriptor final : public ProtoMessage { public: @@ -2054,7 +2146,11 @@ class BluetoothGATTReadRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothGATTReadResponse final : public ProtoMessage { public: @@ -2097,7 +2193,11 @@ class BluetoothGATTWriteRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage { public: @@ -2113,7 +2213,11 @@ class BluetoothGATTReadDescriptorRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage { public: @@ -2132,7 +2236,11 @@ class BluetoothGATTWriteDescriptorRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage { public: @@ -2149,7 +2257,11 @@ class BluetoothGATTNotifyRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothGATTNotifyDataResponse final : public ProtoMessage { public: @@ -2329,7 +2441,11 @@ class BluetoothScannerSetModeRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_VOICE_ASSISTANT @@ -2347,7 +2463,11 @@ class SubscribeVoiceAssistantRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantAudioSettings final : public ProtoMessage { public: @@ -2396,7 +2516,11 @@ class VoiceAssistantResponse final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantEventData final : public ProtoDecodableMessage { public: @@ -2424,7 +2548,11 @@ class VoiceAssistantEventResponse final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantAudio final : public ProtoDecodableMessage { public: @@ -2444,7 +2572,11 @@ class VoiceAssistantAudio final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantTimerEventResponse final : public ProtoDecodableMessage { public: @@ -2465,7 +2597,11 @@ class VoiceAssistantTimerEventResponse final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantAnnounceRequest final : public ProtoDecodableMessage { public: @@ -2484,7 +2620,11 @@ class VoiceAssistantAnnounceRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantAnnounceFinished final : public ProtoMessage { public: @@ -2530,7 +2670,11 @@ class VoiceAssistantExternalWakeWord final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class VoiceAssistantConfigurationRequest final : public ProtoDecodableMessage { public: @@ -2632,7 +2776,11 @@ class AlarmControlPanelCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_TEXT @@ -2687,7 +2835,11 @@ class TextCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_DATETIME_DATE @@ -2741,7 +2893,11 @@ class DateCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_DATETIME_TIME @@ -2795,7 +2951,11 @@ class TimeCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_EVENT @@ -2886,7 +3046,11 @@ class ValveCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_DATETIME_DATETIME @@ -2936,7 +3100,11 @@ class DateTimeCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_UPDATE @@ -2994,7 +3162,11 @@ class UpdateCommandRequest final : public CommandProtoMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_ZWAVE_PROXY @@ -3034,7 +3206,11 @@ class ZWaveProxyRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; #endif #ifdef USE_INFRARED @@ -3079,7 +3255,11 @@ class InfraredRFTransmitRawTimingsRequest final : public ProtoDecodableMessage { protected: bool decode_32bit(uint32_t field_id, Proto32Bit value) override; bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class InfraredRFReceiveEvent final : public ProtoMessage { public: @@ -3121,7 +3301,11 @@ class SerialProxyConfigureRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class SerialProxyDataReceived final : public ProtoMessage { public: @@ -3161,7 +3345,11 @@ class SerialProxyWriteRequest final : public ProtoDecodableMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class SerialProxySetModemPinsRequest final : public ProtoDecodableMessage { public: @@ -3177,7 +3365,11 @@ class SerialProxySetModemPinsRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class SerialProxyGetModemPinsRequest final : public ProtoDecodableMessage { public: @@ -3192,7 +3384,11 @@ class SerialProxyGetModemPinsRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class SerialProxyGetModemPinsResponse final : public ProtoMessage { public: @@ -3225,7 +3421,11 @@ class SerialProxyRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class SerialProxyRequestResponse final : public ProtoMessage { public: @@ -3265,7 +3465,11 @@ class BluetoothSetConnectionParamsRequest final : public ProtoDecodableMessage { #endif protected: - bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override; +#ifdef USE_API_VARINT64 + bool decode_varint(uint32_t field_id, uint64_t value) override; +#else + bool decode_varint(uint32_t field_id, uint32_t value) override; +#endif }; class BluetoothSetConnectionParamsResponse final : public ProtoMessage { public: diff --git a/esphome/components/api/proto.cpp b/esphome/components/api/proto.cpp index 5dbeae77589..e03cc693485 100644 --- a/esphome/components/api/proto.cpp +++ b/esphome/components/api/proto.cpp @@ -227,7 +227,11 @@ void ProtoDecodableMessage::decode(const uint8_t *buffer, size_t length) { ESP_LOGV(TAG, "Invalid VarInt at offset %ld", (long) (ptr - buffer)); return; } - if (!this->decode_varint(field_id, res)) { +#ifdef USE_API_VARINT64 + if (!this->decode_varint(field_id, res.as_uint64())) { +#else + if (!this->decode_varint(field_id, res.as_uint32())) { +#endif ESP_LOGV(TAG, "Cannot decode VarInt field %" PRIu32 " with value %" PRIu32 "!", field_id, res.as_uint32()); } ptr += res.consumed; diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index 86746c949fe..7da4dc9bdc0 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -506,7 +506,11 @@ class ProtoDecodableMessage : public ProtoMessage { protected: ~ProtoDecodableMessage() = default; - virtual bool decode_varint(uint32_t field_id, ProtoVarIntResult value) { return false; } +#ifdef USE_API_VARINT64 + virtual bool decode_varint(uint32_t field_id, uint64_t value) { return false; } +#else + virtual bool decode_varint(uint32_t field_id, uint32_t value) { return false; } +#endif virtual bool decode_length(uint32_t field_id, ProtoLengthDelimited value) { return false; } virtual bool decode_32bit(uint32_t field_id, Proto32Bit value) { return false; } // NOTE: decode_64bit removed - wire type 1 not supported diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index bf1d34d67fc..2febe2580e6 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -193,6 +193,7 @@ class TypeInfo(ABC): return f"case {self.number}: this->{self.field_name} = {content}; break;" decode_varint = None + is_varint64 = False @property def decode_length_content(self) -> str: @@ -461,7 +462,8 @@ class FloatType(TypeInfo): class Int64Type(TypeInfo): cpp_type = "int64_t" default_value = "0" - decode_varint = "value.as_int64()" + decode_varint = "static_cast(value)" + is_varint64 = True encode_func = "encode_int64" wire_type = WireType.VARINT # Uses wire type 0 @@ -481,7 +483,8 @@ class Int64Type(TypeInfo): class UInt64Type(TypeInfo): cpp_type = "uint64_t" default_value = "0" - decode_varint = "value.as_uint64()" + decode_varint = "value" + is_varint64 = True encode_func = "encode_uint64" wire_type = WireType.VARINT # Uses wire type 0 @@ -501,7 +504,7 @@ class UInt64Type(TypeInfo): class Int32Type(TypeInfo): cpp_type = "int32_t" default_value = "0" - decode_varint = "value.as_int32()" + decode_varint = "static_cast(value)" encode_func = "encode_int32" wire_type = WireType.VARINT # Uses wire type 0 @@ -573,7 +576,7 @@ class Fixed32Type(TypeInfo): class BoolType(TypeInfo): cpp_type = "bool" default_value = "false" - decode_varint = "value.as_bool()" + decode_varint = "value != 0" encode_func = "encode_bool" wire_type = WireType.VARINT # Uses wire type 0 @@ -1151,7 +1154,7 @@ class FixedArrayBytesType(TypeInfo): class UInt32Type(TypeInfo): cpp_type = "uint32_t" default_value = "0" - decode_varint = "value.as_uint32()" + decode_varint = "value" encode_func = "encode_uint32" wire_type = WireType.VARINT # Uses wire type 0 @@ -1175,7 +1178,7 @@ class EnumType(TypeInfo): @property def decode_varint(self) -> str: - return f"static_cast<{self.cpp_type}>(value.as_uint32())" + return f"static_cast<{self.cpp_type}>(value)" default_value = "" wire_type = WireType.VARINT # Uses wire type 0 @@ -1262,7 +1265,7 @@ class SFixed64Type(TypeInfo): class SInt32Type(TypeInfo): cpp_type = "int32_t" default_value = "0" - decode_varint = "value.as_sint32()" + decode_varint = "decode_zigzag32(value)" encode_func = "encode_sint32" wire_type = WireType.VARINT # Uses wire type 0 @@ -1282,7 +1285,8 @@ class SInt32Type(TypeInfo): class SInt64Type(TypeInfo): cpp_type = "int64_t" default_value = "0" - decode_varint = "value.as_sint64()" + decode_varint = "decode_zigzag64(value)" + is_varint64 = True encode_func = "encode_sint64" wire_type = WireType.VARINT # Uses wire type 0 @@ -1620,6 +1624,10 @@ class RepeatedTypeInfo(TypeInfo): """ return self._ti.wire_type + @property + def is_varint64(self): + return self._ti.is_varint64 + @property def decode_varint_content(self) -> str: # Pointer fields don't support decoding @@ -2205,7 +2213,12 @@ def build_message_type( cpp = "" if decode_varint: - o = f"bool {desc.name}::decode_varint(uint32_t field_id, ProtoVarIntResult value) {{\n" + # Use conditional parameter type to match base class + o = "#ifdef USE_API_VARINT64\n" + o += f"bool {desc.name}::decode_varint(uint32_t field_id, uint64_t value) {{\n" + o += "#else\n" + o += f"bool {desc.name}::decode_varint(uint32_t field_id, uint32_t value) {{\n" + o += "#endif\n" o += " switch (field_id) {\n" o += indent("\n".join(decode_varint), " ") + "\n" o += " default: return false;\n" @@ -2213,10 +2226,15 @@ def build_message_type( o += " return true;\n" o += "}\n" cpp += o - prot = ( - "bool decode_varint(uint32_t field_id, ProtoVarIntResult value) override;" - ) - protected_content.insert(0, prot) + prot_lines = [ + "#ifdef USE_API_VARINT64", + "bool decode_varint(uint32_t field_id, uint64_t value) override;", + "#else", + "bool decode_varint(uint32_t field_id, uint32_t value) override;", + "#endif", + ] + for i, line in enumerate(prot_lines): + protected_content.insert(i, line) if decode_length: o = f"bool {desc.name}::decode_length(uint32_t field_id, ProtoLengthDelimited value) {{\n" o += " switch (field_id) {\n"