From 3df03e4be962687ddc6feeb1c8184534a0c526eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Sun, 11 Oct 2026 14:31:07 +0200 Subject: [PATCH] [emontx] Read UART bytes with read_byte() (#20514) Co-authored-by: Claude Opus 5.5 --- esphome/components/emontx/emontx.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/emontx/emontx.cpp b/esphome/components/emontx/emontx.cpp index ae92b737316..17497984c39 100644 --- a/esphome/components/emontx/emontx.cpp +++ b/esphome/components/emontx/emontx.cpp @@ -18,7 +18,9 @@ void EmonTx::setup() { this->buffer_pos_ = 0; } void EmonTx::loop() { // Read all available data to prevent UART buffer overflow while (this->available() > 0) { - uint8_t received = this->read(); + uint8_t received; + if (!this->read_byte(&received)) + break; if (received == '\r') { continue; // Ignore CR