Skip to content

Commit

Permalink
fix: voc-improve-min misbehaving w/ exhaust > intake
Browse files Browse the repository at this point in the history
  • Loading branch information
SanaaHamel committed May 27, 2024
1 parent e407ae6 commit 14e308f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utility/fan_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ constexpr bool policy_voc_improving(VOCIndex voc_improve_min, VOCIndex intake, V
if (intake == NOT_KNOWN || exhaust == NOT_KNOWN) return false; // Need a reading for both sensors.

auto const voc_improvement = intake.value_or(0) - exhaust.value_or(0);
return voc_improve_min <= voc_improvement;
return 0 <= voc_improvement && voc_improve_min <= voc_improvement;
}

constexpr bool should_filter(FanPolicyEnvironmental const& params, VOCIndex intake, VOCIndex exhaust) {
Expand Down Expand Up @@ -80,5 +80,7 @@ static_assert(!policy_voc_improving(2, 3, NOT_KNOWN)); // basic case -
static_assert(!policy_voc_improving(2, NOT_KNOWN, 1)); // basic case - need both sensors
static_assert(!policy_voc_improving(NOT_KNOWN, 3, 1)); // disabled
static_assert(!policy_voc_improving(2, NOT_KNOWN, NOT_KNOWN)); // sensors not connected
static_assert(!policy_voc_improving(NOT_KNOWN, 68, 76)); // disabled, unusual intake/exhuast
static_assert(!policy_voc_improving(1, 68, 76)); // disabled, unusual intake/exhuast

} // namespace nevermore

0 comments on commit 14e308f

Please sign in to comment.