Add target_pct field to PlantInfo for target moisture mode
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use crate::config::SensorCombineMode;
|
||||
use crate::hal::Moistures;
|
||||
use crate::plant_state::PlantWateringMode::TargetMoisture;
|
||||
use crate::{config::PlantConfig, hal::HAL, in_time_range};
|
||||
use chrono::{DateTime, TimeDelta, Utc};
|
||||
use chrono_tz::Tz;
|
||||
@@ -353,6 +355,11 @@ impl PlantState {
|
||||
sensor_a: Self::sensor_to_telemetry(&self.sensor_a),
|
||||
sensor_b: Self::sensor_to_telemetry(&self.sensor_b),
|
||||
mode: plant_conf.mode,
|
||||
target_pct: if plant_conf.mode == TargetMoisture {
|
||||
Some(plant_conf.target_moisture as f32)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
do_water: self.needs_to_be_watered(plant_conf, current_time),
|
||||
dry: if let Some(moisture_percent) = moisture_pct {
|
||||
moisture_percent < plant_conf.target_moisture.into()
|
||||
@@ -438,6 +445,8 @@ impl PlantState {
|
||||
pub struct PlantInfo {
|
||||
/// combined plant moisture from available sensors
|
||||
moisture_pct: Option<f32>,
|
||||
/// moisture target, if in targetmode
|
||||
target_pct: Option<f32>,
|
||||
/// state of humidity sensor on bank a
|
||||
sensor_a: SensorTelemetry,
|
||||
/// state of humidity sensor on bank b
|
||||
|
||||
Reference in New Issue
Block a user