From f6c12229e515ce81918c12bbc1c4ed497fee1782 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 15 Jul 2025 19:57:43 -1000 Subject: [PATCH] fix a few more that are missing --- esphome/components/api/api.proto | 4 ++-- esphome/components/api/api_pb2.cpp | 6 ++++++ esphome/components/api/api_pb2_dump.cpp | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 3d11037f2d..87da838e87 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1915,7 +1915,7 @@ message TextStateResponse { // If the Text 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"]; } message TextCommandRequest { option (id) = 99; @@ -1926,7 +1926,7 @@ message TextCommandRequest { fixed32 key = 1; string state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 56fb8b442f..f67cda5bdd 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -2894,19 +2894,25 @@ void TextStateResponse::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 TextStateResponse::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 } bool TextCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { +#ifdef USE_DEVICES case 3: this->device_id = value.as_uint32(); break; +#endif default: return false; } diff --git a/esphome/components/api/api_pb2_dump.cpp b/esphome/components/api/api_pb2_dump.cpp index 1d85bc31d5..f83112d240 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -3954,10 +3954,13 @@ void TextStateResponse::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("}"); } void TextCommandRequest::dump_to(std::string &out) const { @@ -3972,10 +3975,13 @@ void TextCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->state).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