diff --git a/src/utility/fan_policy.cpp b/src/utility/fan_policy.cpp index 39983a9..293e3bc 100644 --- a/src/utility/fan_policy.cpp +++ b/src/utility/fan_policy.cpp @@ -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) { @@ -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