Compare commits

..

1 Commits

Author SHA1 Message Date
J. Nick Koston
cf691a43b2 [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
2026-02-03 05:48:47 +01:00

View File

@@ -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;