diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 37edabb169..5c925268aa 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -1516,13 +1516,7 @@ void APIConnection::process_batch_() { } // Encode the message directly from the stored ProtoMessage - bool success = item.message->encode(batch_buffer); - - if (!success) { - ESP_LOGW(TAG, "Failed to encode message type %u", item.message->get_message_type()); - // Since we pre-calculated sizes, encoding should not fail - // If it does, we have a serious issue - } + item.message->encode(batch_buffer); } // Send all collected packets diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index 6287210479..e882dd1812 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -330,7 +330,7 @@ class ProtoMessage { virtual void encode(ProtoWriteBuffer buffer) const = 0; void decode(const uint8_t *buffer, size_t length); virtual void calculate_size(uint32_t &total_size) const = 0; - virtual uint16_t get_message_type() const = 0; + virtual uint16_t get_message_type() const { return 0; } // Default for nested types #ifdef HAS_PROTO_MESSAGE_DUMP std::string dump() const; virtual void dump_to(std::string &out) const = 0;