[api] Auto-derive max_value for enum fields in protobuf codegen (#15469)

This commit is contained in:
J. Nick Koston
2026-04-06 14:39:55 -10:00
committed by GitHub
parent 4fa3e48d33
commit d15fa84f4f
2 changed files with 98 additions and 94 deletions
+59 -71
View File
@@ -87,7 +87,7 @@ uint8_t *SerialProxyInfo::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PAR
uint32_t SerialProxyInfo::calculate_size() const {
uint32_t size = 0;
size += ProtoSize::calc_length(1, this->name.size());
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->port_type));
size += this->port_type ? 2 : 0;
return size;
}
#endif
@@ -244,7 +244,7 @@ uint32_t ListEntitiesBinarySensorResponse::calculate_size() const {
#ifdef USE_ENTITY_ICON
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -305,7 +305,7 @@ uint32_t ListEntitiesCoverResponse::calculate_size() const {
#ifdef USE_ENTITY_ICON
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_bool(1, this->supports_stop);
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
@@ -328,7 +328,7 @@ uint32_t CoverStateResponse::calculate_size() const {
size += 5;
size += ProtoSize::calc_float(1, this->position);
size += ProtoSize::calc_float(1, this->tilt);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->current_operation));
size += this->current_operation ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -408,7 +408,7 @@ uint32_t ListEntitiesFanResponse::calculate_size() const {
#ifdef USE_ENTITY_ICON
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
if (!this->supported_preset_modes->empty()) {
for (const char *it : *this->supported_preset_modes) {
size += ProtoSize::calc_length_force(1, strlen(it));
@@ -437,7 +437,7 @@ uint32_t FanStateResponse::calculate_size() const {
size += 5;
size += ProtoSize::calc_bool(1, this->state);
size += ProtoSize::calc_bool(1, this->oscillating);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->direction));
size += this->direction ? 2 : 0;
size += ProtoSize::calc_int32(1, this->speed_level);
size += ProtoSize::calc_length(1, this->preset_mode.size());
#ifdef USE_DEVICES
@@ -536,9 +536,7 @@ uint32_t ListEntitiesLightResponse::calculate_size() const {
size += 5;
size += ProtoSize::calc_length(1, this->name.size());
if (!this->supported_color_modes->empty()) {
for (const auto &it : *this->supported_color_modes) {
size += ProtoSize::calc_uint32_force(1, static_cast<uint32_t>(it));
}
size += this->supported_color_modes->size() * 2;
}
size += ProtoSize::calc_float(1, this->min_mireds);
size += ProtoSize::calc_float(1, this->max_mireds);
@@ -551,7 +549,7 @@ uint32_t ListEntitiesLightResponse::calculate_size() const {
#ifdef USE_ENTITY_ICON
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(2, this->device_id);
#endif
@@ -582,7 +580,7 @@ uint32_t LightStateResponse::calculate_size() const {
size += 5;
size += ProtoSize::calc_bool(1, this->state);
size += ProtoSize::calc_float(1, this->brightness);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->color_mode));
size += this->color_mode ? 2 : 0;
size += ProtoSize::calc_float(1, this->color_brightness);
size += ProtoSize::calc_float(1, this->red);
size += ProtoSize::calc_float(1, this->green);
@@ -739,9 +737,9 @@ uint32_t ListEntitiesSensorResponse::calculate_size() const {
size += ProtoSize::calc_int32(1, this->accuracy_decimals);
size += ProtoSize::calc_bool(1, this->force_update);
size += ProtoSize::calc_length(1, this->device_class.size());
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->state_class));
size += this->state_class ? 2 : 0;
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -796,7 +794,7 @@ uint32_t ListEntitiesSwitchResponse::calculate_size() const {
#endif
size += ProtoSize::calc_bool(1, this->assumed_state);
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
@@ -873,7 +871,7 @@ uint32_t ListEntitiesTextSensorResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
@@ -922,7 +920,7 @@ uint8_t *SubscribeLogsResponse::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEB
}
uint32_t SubscribeLogsResponse::calculate_size() const {
uint32_t size = 0;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->level));
size += this->level ? 2 : 0;
size += ProtoSize::calc_length(1, this->message_len_);
return size;
}
@@ -1171,7 +1169,7 @@ uint8_t *ListEntitiesServicesArgument::encode(ProtoWriteBuffer &buffer PROTO_ENC
uint32_t ListEntitiesServicesArgument::calculate_size() const {
uint32_t size = 0;
size += ProtoSize::calc_length(1, this->name.size());
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->type));
size += this->type ? 2 : 0;
return size;
}
uint8_t *ListEntitiesServicesResponse::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_PARAM) const {
@@ -1193,7 +1191,7 @@ uint32_t ListEntitiesServicesResponse::calculate_size() const {
size += ProtoSize::calc_message_force(1, it.calculate_size());
}
}
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->supports_response));
size += this->supports_response ? 2 : 0;
return size;
}
bool ExecuteServiceArgument::decode_varint(uint32_t field_id, proto_varint_value_t value) {
@@ -1347,7 +1345,7 @@ uint32_t ListEntitiesCameraResponse::calculate_size() const {
#ifdef USE_ENTITY_ICON
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -1441,23 +1439,17 @@ uint32_t ListEntitiesClimateResponse::calculate_size() const {
size += ProtoSize::calc_bool(1, this->supports_current_temperature);
size += ProtoSize::calc_bool(1, this->supports_two_point_target_temperature);
if (!this->supported_modes->empty()) {
for (const auto &it : *this->supported_modes) {
size += ProtoSize::calc_uint32_force(1, static_cast<uint32_t>(it));
}
size += this->supported_modes->size() * 2;
}
size += ProtoSize::calc_float(1, this->visual_min_temperature);
size += ProtoSize::calc_float(1, this->visual_max_temperature);
size += ProtoSize::calc_float(1, this->visual_target_temperature_step);
size += ProtoSize::calc_bool(1, this->supports_action);
if (!this->supported_fan_modes->empty()) {
for (const auto &it : *this->supported_fan_modes) {
size += ProtoSize::calc_uint32_force(1, static_cast<uint32_t>(it));
}
size += this->supported_fan_modes->size() * 2;
}
if (!this->supported_swing_modes->empty()) {
for (const auto &it : *this->supported_swing_modes) {
size += ProtoSize::calc_uint32_force(1, static_cast<uint32_t>(it));
}
size += this->supported_swing_modes->size() * 2;
}
if (!this->supported_custom_fan_modes->empty()) {
for (const char *it : *this->supported_custom_fan_modes) {
@@ -1465,9 +1457,7 @@ uint32_t ListEntitiesClimateResponse::calculate_size() const {
}
}
if (!this->supported_presets->empty()) {
for (const auto &it : *this->supported_presets) {
size += ProtoSize::calc_uint32_force(2, static_cast<uint32_t>(it));
}
size += this->supported_presets->size() * 3;
}
if (!this->supported_custom_presets->empty()) {
for (const char *it : *this->supported_custom_presets) {
@@ -1478,7 +1468,7 @@ uint32_t ListEntitiesClimateResponse::calculate_size() const {
#ifdef USE_ENTITY_ICON
size += ProtoSize::calc_length(2, this->icon.size());
#endif
size += ProtoSize::calc_uint32(2, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 3 : 0;
size += ProtoSize::calc_float(2, this->visual_current_temperature_step);
size += ProtoSize::calc_bool(2, this->supports_current_humidity);
size += ProtoSize::calc_bool(2, this->supports_target_humidity);
@@ -1514,16 +1504,16 @@ uint8_t *ClimateStateResponse::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBU
uint32_t ClimateStateResponse::calculate_size() const {
uint32_t size = 0;
size += 5;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->mode));
size += this->mode ? 2 : 0;
size += ProtoSize::calc_float(1, this->current_temperature);
size += ProtoSize::calc_float(1, this->target_temperature);
size += ProtoSize::calc_float(1, this->target_temperature_low);
size += ProtoSize::calc_float(1, this->target_temperature_high);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->action));
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->fan_mode));
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->swing_mode));
size += this->action ? 2 : 0;
size += this->fan_mode ? 2 : 0;
size += this->swing_mode ? 2 : 0;
size += ProtoSize::calc_length(1, this->custom_fan_mode.size());
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->preset));
size += this->preset ? 2 : 0;
size += ProtoSize::calc_length(1, this->custom_preset.size());
size += ProtoSize::calc_float(1, this->current_humidity);
size += ProtoSize::calc_float(1, this->target_humidity);
@@ -1656,7 +1646,7 @@ uint32_t ListEntitiesWaterHeaterResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -1664,9 +1654,7 @@ uint32_t ListEntitiesWaterHeaterResponse::calculate_size() const {
size += ProtoSize::calc_float(1, this->max_temperature);
size += ProtoSize::calc_float(1, this->target_temperature_step);
if (!this->supported_modes->empty()) {
for (const auto &it : *this->supported_modes) {
size += ProtoSize::calc_uint32_force(1, static_cast<uint32_t>(it));
}
size += this->supported_modes->size() * 2;
}
size += ProtoSize::calc_uint32(1, this->supported_features);
return size;
@@ -1690,7 +1678,7 @@ uint32_t WaterHeaterStateResponse::calculate_size() const {
size += 5;
size += ProtoSize::calc_float(1, this->current_temperature);
size += ProtoSize::calc_float(1, this->target_temperature);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->mode));
size += this->mode ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -1774,9 +1762,9 @@ uint32_t ListEntitiesNumberResponse::calculate_size() const {
size += ProtoSize::calc_float(1, this->max_value);
size += ProtoSize::calc_float(1, this->step);
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->unit_of_measurement.size());
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->mode));
size += this->mode ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
@@ -1862,7 +1850,7 @@ uint32_t ListEntitiesSelectResponse::calculate_size() const {
}
}
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -1959,7 +1947,7 @@ uint32_t ListEntitiesSirenResponse::calculate_size() const {
}
size += ProtoSize::calc_bool(1, this->supports_duration);
size += ProtoSize::calc_bool(1, this->supports_volume);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -2067,7 +2055,7 @@ uint32_t ListEntitiesLockResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_bool(1, this->assumed_state);
size += ProtoSize::calc_bool(1, this->supports_open);
size += ProtoSize::calc_bool(1, this->requires_code);
@@ -2089,7 +2077,7 @@ uint8_t *LockStateResponse::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_P
uint32_t LockStateResponse::calculate_size() const {
uint32_t size = 0;
size += 5;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->state));
size += this->state ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -2161,7 +2149,7 @@ uint32_t ListEntitiesButtonResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
@@ -2206,7 +2194,7 @@ uint32_t MediaPlayerSupportedFormat::calculate_size() const {
size += ProtoSize::calc_length(1, this->format.size());
size += ProtoSize::calc_uint32(1, this->sample_rate);
size += ProtoSize::calc_uint32(1, this->num_channels);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->purpose));
size += this->purpose ? 2 : 0;
size += ProtoSize::calc_uint32(1, this->sample_bytes);
return size;
}
@@ -2239,7 +2227,7 @@ uint32_t ListEntitiesMediaPlayerResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_bool(1, this->supports_pause);
if (!this->supported_formats.empty()) {
for (const auto &it : this->supported_formats) {
@@ -2266,7 +2254,7 @@ uint8_t *MediaPlayerStateResponse::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_
uint32_t MediaPlayerStateResponse::calculate_size() const {
uint32_t size = 0;
size += 5;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->state));
size += this->state ? 2 : 0;
size += ProtoSize::calc_float(1, this->volume);
size += ProtoSize::calc_bool(1, this->muted);
#ifdef USE_DEVICES
@@ -2348,7 +2336,7 @@ uint8_t *BluetoothLERawAdvertisement::encode(ProtoWriteBuffer &buffer PROTO_ENCO
ProtoEncode::encode_varint_raw_short(pos PROTO_ENCODE_DEBUG_ARG, encode_zigzag32(this->rssi));
if (this->address_type) {
ProtoEncode::write_raw_byte(pos PROTO_ENCODE_DEBUG_ARG, 24);
ProtoEncode::write_raw_byte(pos PROTO_ENCODE_DEBUG_ARG, static_cast<uint8_t>(this->address_type));
ProtoEncode::encode_varint_raw(pos PROTO_ENCODE_DEBUG_ARG, this->address_type);
}
ProtoEncode::write_raw_byte(pos PROTO_ENCODE_DEBUG_ARG, 34);
ProtoEncode::write_raw_byte(pos PROTO_ENCODE_DEBUG_ARG, static_cast<uint8_t>(this->data_len));
@@ -2762,9 +2750,9 @@ uint8_t *BluetoothScannerStateResponse::encode(ProtoWriteBuffer &buffer PROTO_EN
}
uint32_t BluetoothScannerStateResponse::calculate_size() const {
uint32_t size = 0;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->state));
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->mode));
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->configured_mode));
size += this->state ? 2 : 0;
size += this->mode ? 2 : 0;
size += this->configured_mode ? 2 : 0;
return size;
}
bool BluetoothScannerSetModeRequest::decode_varint(uint32_t field_id, proto_varint_value_t value) {
@@ -3116,7 +3104,7 @@ uint32_t ListEntitiesAlarmControlPanelResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_uint32(1, this->supported_features);
size += ProtoSize::calc_bool(1, this->requires_code);
size += ProtoSize::calc_bool(1, this->requires_code_to_arm);
@@ -3137,7 +3125,7 @@ uint8_t *AlarmControlPanelStateResponse::encode(ProtoWriteBuffer &buffer PROTO_E
uint32_t AlarmControlPanelStateResponse::calculate_size() const {
uint32_t size = 0;
size += 5;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->state));
size += this->state ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -3209,11 +3197,11 @@ uint32_t ListEntitiesTextResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_uint32(1, this->min_length);
size += ProtoSize::calc_uint32(1, this->max_length);
size += ProtoSize::calc_length(1, this->pattern.size());
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->mode));
size += this->mode ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -3298,7 +3286,7 @@ uint32_t ListEntitiesDateResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -3385,7 +3373,7 @@ uint32_t ListEntitiesTimeResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -3476,7 +3464,7 @@ uint32_t ListEntitiesEventResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
if (!this->event_types->empty()) {
for (const char *it : *this->event_types) {
@@ -3536,7 +3524,7 @@ uint32_t ListEntitiesValveResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
size += ProtoSize::calc_bool(1, this->assumed_state);
size += ProtoSize::calc_bool(1, this->supports_position);
@@ -3560,7 +3548,7 @@ uint32_t ValveStateResponse::calculate_size() const {
uint32_t size = 0;
size += 5;
size += ProtoSize::calc_float(1, this->position);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->current_operation));
size += this->current_operation ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -3623,7 +3611,7 @@ uint32_t ListEntitiesDateTimeResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -3701,7 +3689,7 @@ uint32_t ListEntitiesUpdateResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
size += ProtoSize::calc_length(1, this->device_class.size());
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
@@ -3821,7 +3809,7 @@ uint8_t *ZWaveProxyRequest::encode(ProtoWriteBuffer &buffer PROTO_ENCODE_DEBUG_P
}
uint32_t ZWaveProxyRequest::calculate_size() const {
uint32_t size = 0;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->type));
size += this->type ? 2 : 0;
size += ProtoSize::calc_length(1, this->data_len);
return size;
}
@@ -3853,7 +3841,7 @@ uint32_t ListEntitiesInfraredResponse::calculate_size() const {
size += ProtoSize::calc_length(1, this->icon.size());
#endif
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += this->entity_category ? 2 : 0;
#ifdef USE_DEVICES
size += ProtoSize::calc_uint32(1, this->device_id);
#endif
@@ -4048,8 +4036,8 @@ uint8_t *SerialProxyRequestResponse::encode(ProtoWriteBuffer &buffer PROTO_ENCOD
uint32_t SerialProxyRequestResponse::calculate_size() const {
uint32_t size = 0;
size += ProtoSize::calc_uint32(1, this->instance);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->type));
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->status));
size += this->type ? 2 : 0;
size += this->status ? 2 : 0;
size += ProtoSize::calc_length(1, this->error_message.size());
return size;
}