From 66e80fe13bf4e22e83d48afda879a0557e2c0bfd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 14 Jan 2026 16:28:16 -1000 Subject: [PATCH 1/2] Update esphome/components/modbus_controller/modbus_controller.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- esphome/components/modbus_controller/modbus_controller.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/modbus_controller/modbus_controller.h b/esphome/components/modbus_controller/modbus_controller.h index 466598e9cd..111b0d574e 100644 --- a/esphome/components/modbus_controller/modbus_controller.h +++ b/esphome/components/modbus_controller/modbus_controller.h @@ -286,7 +286,7 @@ class ServerRegister { return std::to_string(value); case SensorValueType::FP32_R: case SensorValueType::FP32: { - // max 48: float with %.1f can be up to 41 chars (3.4e38 → 39 digits + sign + decimal + 1 digit) + null + // max 48: float with %.1f can be up to 42 chars incl. null (3.4e38 → 38 integer digits + decimal point + 1 decimal digit + optional sign) char buf[48]; snprintf(buf, sizeof(buf), "%.1f", bit_cast(static_cast(value))); return buf; From 5b6be2c8d96e8bb63d1032ff87f29082667b223b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 14 Jan 2026 16:28:26 -1000 Subject: [PATCH 2/2] Update esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../modbus_controller/text_sensor/modbus_textsensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp index c50e8317fa..b26411b72e 100644 --- a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +++ b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp @@ -24,7 +24,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector &data) { break; } case RawEncoding::COMMA: { - // max 5: ","(1) + uint8(3) + null + // max 5: optional ','(1) + uint8(3) + null, for both ",%d" and "%d" char dec_buf[5]; snprintf(dec_buf, sizeof(dec_buf), index != this->offset ? ",%d" : "%d", b); output_str += dec_buf;