diff --git a/src/actuators.rs b/src/actuators.rs index ef862ec..966eb58 100644 --- a/src/actuators.rs +++ b/src/actuators.rs @@ -57,6 +57,7 @@ pub fn pump_water(water_mass_g: u16, program_state: &mut ProgramState) -> Generi .history .watering_records .push(WateringRecord::new(water_mass_g.into())); + program_state.history.save()?; Ok(()) } diff --git a/src/state.rs b/src/state.rs index 9458dd4..7c49982 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,7 +11,7 @@ pub struct ProgramState { pub fn init_state(config: Configuration) -> GenericResult { let relay = io::Relay::new(&config)?; - let history = History::load()?; + let history = History::load().unwrap_or_default(); Ok(Arc::new(Mutex::new(ProgramState { config, relay,