Skip to content

Commit e2e63b9

Browse files
author
Kevin Hübner
committed
additional time stamp update in some cases
1 parent 947c1d4 commit e2e63b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

components/soyosource_virtual_meter/soyosource_virtual_meter.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,15 @@ int16_t SoyosourceVirtualMeter::calculate_power_demand_negative_measurements_(in
133133
ESP_LOGD(TAG, "'%s': Oscillation prevention, keeping previous demand: %d; reducing compensation",
134134
this->get_modbus_name(), last_power_demand);
135135
} else {
136-
this->power_demand_compensation_ += power_demand - last_power_demand;
136+
int16_t new_demand = this->power_demand_compensation_ + power_demand - last_power_demand;
137+
// if not really compensating at the moment and demand changes a bit more, increase current time stamp: helps to
138+
// reduce false time-outs
139+
if (abs(this->power_demand_compensation_) < 15 && abs(new_demand) > 50) {
140+
ESP_LOGD(TAG, "'%s': resetting only timeout: power_demand_compensation_: %d; new_deman: %d",
141+
this->get_modbus_name(), this->power_demand_compensation_, new_demand);
142+
this->power_demand_compensation_timestamp_ = millis();
143+
}
144+
this->power_demand_compensation_ = new_demand;
137145
}
138146
ESP_LOGD(TAG, "'%s': updated power_demand_compensation_ to %d", this->get_modbus_name(), this->power_demand_compensation_);
139147

0 commit comments

Comments
 (0)