From 6da4f95258c351004ae98c1856a83d1cf9b410dd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 25 Jan 2026 23:04:33 -1000 Subject: [PATCH] [mqtt] Refactor state publishing with dedicated enum-to-string helpers --- esphome/components/mqtt/mqtt_component.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/esphome/components/mqtt/mqtt_component.cpp b/esphome/components/mqtt/mqtt_component.cpp index 66df994a32..a77afd3f4e 100644 --- a/esphome/components/mqtt/mqtt_component.cpp +++ b/esphome/components/mqtt/mqtt_component.cpp @@ -159,8 +159,7 @@ bool MQTTComponent::publish(const char *topic, ProgmemStr payload) { if (topic[0] == '\0') return false; // On ESP8266, ProgmemStr is __FlashStringHelper* - need to copy from flash - // Max state string is "armed_custom_bypass" (19 chars) + null = 20 bytes - char buf[24]; + char buf[64]; strncpy_P(buf, reinterpret_cast(payload), sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; return global_mqtt_client->publish(topic, buf, strlen(buf), this->qos_, this->retain_);