mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 23:45:40 -07:00
[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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user