diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 856ae4b047..3d11037f2d 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1320,7 +1320,7 @@ message MediaPlayerStateResponse { MediaPlayerState state = 2; float volume = 3; bool muted = 4; - uint32 device_id = 5; + uint32 device_id = 5 [(field_ifdef) = "USE_DEVICES"]; } message MediaPlayerCommandRequest { option (id) = 65; @@ -1863,7 +1863,7 @@ message AlarmControlPanelStateResponse { option (no_delay) = true; fixed32 key = 1; AlarmControlPanelState state = 2; - uint32 device_id = 3; + uint32 device_id = 3 [(field_ifdef) = "USE_DEVICES"]; } message AlarmControlPanelCommandRequest { @@ -1875,7 +1875,7 @@ message AlarmControlPanelCommandRequest { fixed32 key = 1; AlarmControlPanelStateCommand command = 2; string code = 3; - uint32 device_id = 4; + uint32 device_id = 4 [(field_ifdef) = "USE_DEVICES"]; } // ===================== TEXT ===================== diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 21cffebac2..56fb8b442f 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -1939,14 +1939,18 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(2, static_cast(this->state)); buffer.encode_float(3, this->volume); buffer.encode_bool(4, this->muted); +#ifdef USE_DEVICES buffer.encode_uint32(5, this->device_id); +#endif } void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_enum_field(total_size, 1, static_cast(this->state)); ProtoSize::add_float_field(total_size, 1, this->volume); ProtoSize::add_bool_field(total_size, 1, this->muted); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool MediaPlayerCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { @@ -2804,21 +2808,27 @@ void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->key); buffer.encode_uint32(2, static_cast(this->state)); +#ifdef USE_DEVICES buffer.encode_uint32(3, this->device_id); +#endif } void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const { ProtoSize::add_fixed32_field(total_size, 1, this->key); ProtoSize::add_enum_field(total_size, 1, static_cast(this->state)); +#ifdef USE_DEVICES ProtoSize::add_uint32_field(total_size, 1, this->device_id); +#endif } bool AlarmControlPanelCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { switch (field_id) { case 2: this->command = static_cast(value.as_uint32()); break; +#ifdef USE_DEVICES case 4: 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 29cd2fa336..1d85bc31d5 100644 --- a/esphome/components/api/api_pb2_dump.cpp +++ b/esphome/components/api/api_pb2_dump.cpp @@ -2983,10 +2983,13 @@ void MediaPlayerStateResponse::dump_to(std::string &out) const { out.append(YESNO(this->muted)); 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 MediaPlayerCommandRequest::dump_to(std::string &out) const { @@ -3842,10 +3845,13 @@ void AlarmControlPanelStateResponse::dump_to(std::string &out) const { out.append(proto_enum_to_string(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 AlarmControlPanelCommandRequest::dump_to(std::string &out) const { @@ -3864,10 +3870,13 @@ void AlarmControlPanelCommandRequest::dump_to(std::string &out) const { out.append("'").append(this->code).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