From cf691a43b296942730bcca356d2d48e4d9dd99e2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 3 Feb 2026 05:48:37 +0100 Subject: [PATCH] [cse7766] Fix power reading stuck when load switches off When the load is switched off and current drops below the chip's measurable threshold (~50mA), the CSE7766 sets have_power=false indicating no valid power measurement. The code was not publishing any value in this case, leaving the power sensor stuck at its last reading (e.g., 200W) for 10-20 seconds. This regression was introduced in 2024.2.0 when PR #6180 refactored the code from an accumulator-based design to direct publishing. The original code handled this case by incrementing power_counts_ when have_voltage && !have_power, effectively publishing 0W. Fixes esphome/esphome#13613 --- esphome/components/cse7766/cse7766.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/cse7766/cse7766.cpp b/esphome/components/cse7766/cse7766.cpp index 4432195365..c36e57c929 100644 --- a/esphome/components/cse7766/cse7766.cpp +++ b/esphome/components/cse7766/cse7766.cpp @@ -152,6 +152,10 @@ void CSE7766Component::parse_data_() { if (this->power_sensor_ != nullptr) { this->power_sensor_->publish_state(power); } + } else if (this->power_sensor_ != nullptr) { + // No valid power measurement from chip - publish 0W to avoid stale readings + // This typically happens when current is below the measurable threshold (~50mA) + this->power_sensor_->publish_state(0.0f); } float current = 0.0f;