From 9344d85414d26b5b2ff51624dfd6ceb6b8ecd01c Mon Sep 17 00:00:00 2001 From: Lewis Baker Date: Thu, 13 Jul 2023 06:27:45 +0930 Subject: [PATCH] Fix PIDController::in_deadband() to give correct result when error is zero (#5078) --- esphome/components/pid/pid_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/pid/pid_controller.cpp b/esphome/components/pid/pid_controller.cpp index afc2d91000..30f6038325 100644 --- a/esphome/components/pid/pid_controller.cpp +++ b/esphome/components/pid/pid_controller.cpp @@ -29,7 +29,7 @@ float PIDController::update(float setpoint, float process_value) { bool PIDController::in_deadband() { // return (fabs(error) < deadband_threshold); float err = -error_; - return ((err > 0 && err < threshold_high_) || (err < 0 && err > threshold_low_)); + return (threshold_low_ < err && err < threshold_high_); } void PIDController::calculate_proportional_term_() {