From 7650c91297b8ba7e508d1635a320bdb3b49c8900 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 18 Jan 2026 18:50:02 -1000 Subject: [PATCH] switch back to %f --- esphome/components/statsd/statsd.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/esphome/components/statsd/statsd.cpp b/esphome/components/statsd/statsd.cpp index f48a40c2a8..559b14bf0c 100644 --- a/esphome/components/statsd/statsd.cpp +++ b/esphome/components/statsd/statsd.cpp @@ -126,10 +126,9 @@ void StatsdComponent::update() { } out.append(s.name); // Buffer for ":" + value + "|g\n". - // %g uses max 13 chars for value (sign + 6 significant digits + e+xxx) - // Total: 1 + 13 + 4 = 18 chars + null, use 24 for safety - char val_buf[24]; - buf_append_printf(val_buf, sizeof(val_buf), 0, ":%g|g\n", val); + // %f with -DBL_MAX can produce up to 321 chars, plus ":" and "|g\n" (5) + null = 327 + char val_buf[330]; + buf_append_printf(val_buf, sizeof(val_buf), 0, ":%f|g\n", val); out.append(val_buf); if (out.length() > SEND_THRESHOLD) {