mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 07:50:21 +00:00
[pid] Pid climate add set deadband parameters action (#14730)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
co-authored by
J. Nick Koston
J. Nick Koston
parent
f6e97b7ada
commit
cf3552b46e
@@ -0,0 +1,5 @@
|
||||
from tests.testing_helpers import ComponentManifestOverride
|
||||
|
||||
|
||||
def override_manifest(manifest: ComponentManifestOverride) -> None:
|
||||
manifest.dependencies = manifest.dependencies + ["climate", "output", "sensor"]
|
||||
@@ -12,6 +12,15 @@ esphome:
|
||||
kp: 0.0
|
||||
ki: 0.0
|
||||
kd: 0.0
|
||||
- climate.pid.set_deadband_control_parameters_multipliers:
|
||||
id: pid_climate
|
||||
kp_multiplier: 0.0
|
||||
ki_multiplier: 0.0
|
||||
kd_multiplier: 0.0
|
||||
- climate.pid.set_deadband_threshold_parameters:
|
||||
id: pid_climate
|
||||
threshold_high: 0.5°C
|
||||
threshold_low: !lambda return -0.5f;
|
||||
- climate.pid.reset_integral_term: pid_climate
|
||||
|
||||
output:
|
||||
@@ -30,6 +39,26 @@ sensor:
|
||||
}
|
||||
return 0.0;
|
||||
update_interval: 60s
|
||||
- platform: pid
|
||||
id: pid_kp_multiplier
|
||||
climate_id: pid_climate
|
||||
type: KP_DEADBAND_MULTIPLIER
|
||||
- platform: pid
|
||||
id: pid_ki_multiplier
|
||||
climate_id: pid_climate
|
||||
type: KI_DEADBAND_MULTIPLIER
|
||||
- platform: pid
|
||||
id: pid_kd_multiplier
|
||||
climate_id: pid_climate
|
||||
type: KD_DEADBAND_MULTIPLIER
|
||||
- platform: pid
|
||||
id: pid_threshold_high
|
||||
climate_id: pid_climate
|
||||
type: DEADBAND_THRESHOLD_HIGH
|
||||
- platform: pid
|
||||
id: pid_threshold_low
|
||||
climate_id: pid_climate
|
||||
type: DEADBAND_THRESHOLD_LOW
|
||||
|
||||
climate:
|
||||
- platform: pid
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "esphome/components/pid/pid_climate.h"
|
||||
|
||||
namespace esphome::pid {
|
||||
|
||||
TEST(PIDClimateDeadbandThresholds, InvalidThresholdsDoNotChangeController) {
|
||||
PIDClimate climate;
|
||||
climate.set_threshold_low(-1.0f);
|
||||
climate.set_threshold_high(1.0f);
|
||||
|
||||
EXPECT_FALSE(climate.set_deadband_thresholds(2.0f, 1.0f));
|
||||
|
||||
EXPECT_FLOAT_EQ(climate.get_threshold_low(), -1.0f);
|
||||
EXPECT_FLOAT_EQ(climate.get_threshold_high(), 1.0f);
|
||||
}
|
||||
|
||||
TEST(PIDClimateDeadbandThresholds, ValidThresholdsChangeController) {
|
||||
PIDClimate climate;
|
||||
climate.set_threshold_low(-1.0f);
|
||||
climate.set_threshold_high(1.0f);
|
||||
|
||||
EXPECT_TRUE(climate.set_deadband_thresholds(-2.0f, 0.5f));
|
||||
|
||||
EXPECT_FLOAT_EQ(climate.get_threshold_low(), -2.0f);
|
||||
EXPECT_FLOAT_EQ(climate.get_threshold_high(), 0.5f);
|
||||
}
|
||||
|
||||
TEST(PIDClimateDeadbandThresholds, EqualThresholdsDisableDeadband) {
|
||||
PIDClimate climate;
|
||||
climate.set_threshold_low(-1.0f);
|
||||
climate.set_threshold_high(1.0f);
|
||||
|
||||
EXPECT_TRUE(climate.set_deadband_thresholds(0.0f, 0.0f));
|
||||
|
||||
EXPECT_FLOAT_EQ(climate.get_threshold_low(), 0.0f);
|
||||
EXPECT_FLOAT_EQ(climate.get_threshold_high(), 0.0f);
|
||||
EXPECT_FALSE(climate.in_deadband());
|
||||
}
|
||||
|
||||
} // namespace esphome::pid
|
||||
Reference in New Issue
Block a user