From 9509be95278ba54e0a5cacc08b5b2409373bc21e Mon Sep 17 00:00:00 2001 From: ju6ge Date: Thu, 20 Mar 2025 22:57:55 +0100 Subject: [PATCH] improve warn level function in ValueRangeError case --- rust/src/tank.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/src/tank.rs b/rust/src/tank.rs index f0a1de8..152fc29 100644 --- a/rust/src/tank.rs +++ b/rust/src/tank.rs @@ -86,7 +86,10 @@ impl TankState { pub fn warn_level(&self, config: &TankConfig) -> Result { match self { TankState::TankSensorDisabled => Err(TankError::SensorDisabled), - TankState::TankSensorError(err) => Err(err.clone()), + TankState::TankSensorError(err) => match err { + TankError::SensorValueError { value, min, max } => Ok(value < min), + _ => Err(err.clone()), + }, TankState::TankSensorPresent(raw_value_mv) => { let tank_fill_percent = raw_voltage_to_tank_fill_percent(*raw_value_mv, config)?; if tank_fill_percent < config.tank_warn_percent.into() {