fix a few more that are missing

This commit is contained in:
J. Nick Koston 2025-07-15 19:56:40 -10:00
parent 2abccce297
commit 1ce5a994d8
No known key found for this signature in database
3 changed files with 88 additions and 12 deletions

View File

@ -311,7 +311,7 @@ message BinarySensorStateResponse {
// If the binary sensor does not have a valid state yet.
// Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller
bool missing_state = 3;
uint32 device_id = 4;
uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== COVER ====================
@ -361,7 +361,7 @@ message CoverStateResponse {
float position = 3;
float tilt = 4;
CoverOperation current_operation = 5;
uint32 device_id = 6;
uint32 device_id = 6 [(field_ifdef) = "USE_DEVICES"];
}
enum LegacyCoverCommand {
@ -458,7 +458,7 @@ message FanCommandRequest {
int32 speed_level = 11;
bool has_preset_mode = 12;
string preset_mode = 13;
uint32 device_id = 14;
uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== LIGHT ====================
@ -520,7 +520,7 @@ message LightStateResponse {
float cold_white = 12;
float warm_white = 13;
string effect = 9;
uint32 device_id = 14;
uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"];
}
message LightCommandRequest {
option (id) = 32;
@ -556,7 +556,7 @@ message LightCommandRequest {
uint32 flash_length = 17;
bool has_effect = 18;
string effect = 19;
uint32 device_id = 28;
uint32 device_id = 28 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== SENSOR ====================
@ -594,7 +594,7 @@ message ListEntitiesSensorResponse {
SensorLastResetType legacy_last_reset_type = 11;
bool disabled_by_default = 12;
EntityCategory entity_category = 13;
uint32 device_id = 14;
uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"];
}
message SensorStateResponse {
option (id) = 25;
@ -608,7 +608,7 @@ message SensorStateResponse {
// If the sensor does not have a valid state yet.
// Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller
bool missing_state = 3;
uint32 device_id = 4;
uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== SWITCH ====================
@ -639,7 +639,7 @@ message SwitchStateResponse {
fixed32 key = 1;
bool state = 2;
uint32 device_id = 3;
uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"];
}
message SwitchCommandRequest {
option (id) = 33;
@ -650,7 +650,7 @@ message SwitchCommandRequest {
fixed32 key = 1;
bool state = 2;
uint32 device_id = 3;
uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== TEXT SENSOR ====================
@ -683,7 +683,7 @@ message TextSensorStateResponse {
// If the text sensor does not have a valid state yet.
// Equivalent to `!obj->has_state()` - inverse logic to make state packets smaller
bool missing_state = 3;
uint32 device_id = 4;
uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== SUBSCRIBE LOGS ====================
@ -869,7 +869,7 @@ message CameraImageResponse {
fixed32 key = 1;
bytes data = 2;
bool done = 3;
uint32 device_id = 4;
uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"];
}
message CameraImageRequest {
option (id) = 45;
@ -1020,7 +1020,7 @@ message ClimateCommandRequest {
string custom_preset = 21;
bool has_target_humidity = 22;
float target_humidity = 23;
uint32 device_id = 24;
uint32 device_id = 24 [(field_ifdef) = "USE_DEVICES"];
}
// ==================== NUMBER ====================

View File

@ -260,13 +260,17 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_fixed32(1, this->key);
buffer.encode_bool(2, this->state);
buffer.encode_bool(3, this->missing_state);
#ifdef USE_DEVICES
buffer.encode_uint32(4, this->device_id);
#endif
}
void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
#endif
#ifdef USE_COVER
@ -312,7 +316,9 @@ void CoverStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_float(3, this->position);
buffer.encode_float(4, this->tilt);
buffer.encode_uint32(5, static_cast<uint32_t>(this->current_operation));
#ifdef USE_DEVICES
buffer.encode_uint32(6, this->device_id);
#endif
}
void CoverStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
@ -320,7 +326,9 @@ void CoverStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_float_field(total_size, 1, this->position);
ProtoSize::add_float_field(total_size, 1, this->tilt);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
bool CoverCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
switch (field_id) {
@ -468,9 +476,11 @@ bool FanCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
case 12:
this->has_preset_mode = value.as_bool();
break;
#ifdef USE_DEVICES
case 14:
this->device_id = value.as_uint32();
break;
#endif
default:
return false;
}
@ -566,7 +576,9 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_float(12, this->cold_white);
buffer.encode_float(13, this->warm_white);
buffer.encode_string(9, this->effect);
#ifdef USE_DEVICES
buffer.encode_uint32(14, this->device_id);
#endif
}
void LightStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
@ -582,7 +594,9 @@ void LightStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_float_field(total_size, 1, this->cold_white);
ProtoSize::add_float_field(total_size, 1, this->warm_white);
ProtoSize::add_string_field(total_size, 1, this->effect);
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
switch (field_id) {
@ -634,9 +648,11 @@ bool LightCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
case 18:
this->has_effect = value.as_bool();
break;
#ifdef USE_DEVICES
case 28:
this->device_id = value.as_uint32();
break;
#endif
default:
return false;
}
@ -706,7 +722,9 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_uint32(11, static_cast<uint32_t>(this->legacy_last_reset_type));
buffer.encode_bool(12, this->disabled_by_default);
buffer.encode_uint32(13, static_cast<uint32_t>(this->entity_category));
#ifdef USE_DEVICES
buffer.encode_uint32(14, this->device_id);
#endif
}
void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_string_field(total_size, 1, this->object_id);
@ -723,19 +741,25 @@ void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_last_reset_type));
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
void SensorStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_fixed32(1, this->key);
buffer.encode_float(2, this->state);
buffer.encode_bool(3, this->missing_state);
#ifdef USE_DEVICES
buffer.encode_uint32(4, this->device_id);
#endif
}
void SensorStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_float_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
#endif
#ifdef USE_SWITCH
@ -772,21 +796,27 @@ void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const {
void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_fixed32(1, this->key);
buffer.encode_bool(2, this->state);
#ifdef USE_DEVICES
buffer.encode_uint32(3, this->device_id);
#endif
}
void SwitchStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_bool_field(total_size, 1, this->state);
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
bool SwitchCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
switch (field_id) {
case 2:
this->state = value.as_bool();
break;
#ifdef USE_DEVICES
case 3:
this->device_id = value.as_uint32();
break;
#endif
default:
return false;
}
@ -836,13 +866,17 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_fixed32(1, this->key);
buffer.encode_string(2, this->state);
buffer.encode_bool(3, this->missing_state);
#ifdef USE_DEVICES
buffer.encode_uint32(4, this->device_id);
#endif
}
void TextSensorStateResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->state);
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
#endif
bool SubscribeLogsRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
@ -1151,13 +1185,17 @@ void CameraImageResponse::encode(ProtoWriteBuffer buffer) const {
buffer.encode_fixed32(1, this->key);
buffer.encode_bytes(2, reinterpret_cast<const uint8_t *>(this->data.data()), this->data.size());
buffer.encode_bool(3, this->done);
#ifdef USE_DEVICES
buffer.encode_uint32(4, this->device_id);
#endif
}
void CameraImageResponse::calculate_size(uint32_t &total_size) const {
ProtoSize::add_fixed32_field(total_size, 1, this->key);
ProtoSize::add_string_field(total_size, 1, this->data);
ProtoSize::add_bool_field(total_size, 1, this->done);
#ifdef USE_DEVICES
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
#endif
}
bool CameraImageRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
switch (field_id) {
@ -1362,9 +1400,11 @@ bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value)
case 22:
this->has_target_humidity = value.as_bool();
break;
#ifdef USE_DEVICES
case 24:
this->device_id = value.as_uint32();
break;
#endif
default:
return false;
}

View File

@ -883,10 +883,13 @@ void BinarySensorStateResponse::dump_to(std::string &out) const {
out.append(YESNO(this->missing_state));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif
@ -976,10 +979,13 @@ void CoverStateResponse::dump_to(std::string &out) const {
out.append(proto_enum_to_string<enums::CoverOperation>(this->current_operation));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
void CoverCommandRequest::dump_to(std::string &out) const {
@ -1192,10 +1198,13 @@ void FanCommandRequest::dump_to(std::string &out) const {
out.append("'").append(this->preset_mode).append("'");
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif
@ -1342,10 +1351,13 @@ void LightStateResponse::dump_to(std::string &out) const {
out.append("'").append(this->effect).append("'");
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
void LightCommandRequest::dump_to(std::string &out) const {
@ -1471,10 +1483,13 @@ void LightCommandRequest::dump_to(std::string &out) const {
out.append("'").append(this->effect).append("'");
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif
@ -1534,10 +1549,13 @@ void ListEntitiesSensorResponse::dump_to(std::string &out) const {
out.append(proto_enum_to_string<enums::EntityCategory>(this->entity_category));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
void SensorStateResponse::dump_to(std::string &out) const {
@ -1557,10 +1575,13 @@ void SensorStateResponse::dump_to(std::string &out) const {
out.append(YESNO(this->missing_state));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif
@ -1624,10 +1645,13 @@ void SwitchStateResponse::dump_to(std::string &out) const {
out.append(YESNO(this->state));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
void SwitchCommandRequest::dump_to(std::string &out) const {
@ -1642,10 +1666,13 @@ void SwitchCommandRequest::dump_to(std::string &out) const {
out.append(YESNO(this->state));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif
@ -1709,10 +1736,13 @@ void TextSensorStateResponse::dump_to(std::string &out) const {
out.append(YESNO(this->missing_state));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif
@ -2009,10 +2039,13 @@ void CameraImageResponse::dump_to(std::string &out) const {
out.append(YESNO(this->done));
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
void CameraImageRequest::dump_to(std::string &out) const {
@ -2337,10 +2370,13 @@ void ClimateCommandRequest::dump_to(std::string &out) const {
out.append(buffer);
out.append("\n");
#ifdef USE_DEVICES
out.append(" device_id: ");
snprintf(buffer, sizeof(buffer), "%" PRIu32, this->device_id);
out.append(buffer);
out.append("\n");
#endif
out.append("}");
}
#endif