From 5be6197f8c747fea400dc83bed62f99772650527 Mon Sep 17 00:00:00 2001 From: Empire Date: Sat, 24 Feb 2024 16:25:56 +0100 Subject: [PATCH] after pump fast restart cycle --- rust/src/main.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index d9a52cb..239d722 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -361,7 +361,7 @@ fn safe_main() -> anyhow::Result<()> { let _webserver = httpd(reboot_now.clone()); wait_infinity(WaitType::StayAlive, reboot_now.clone()); } - + let mut did_pump = false; match plant_to_pump { Some(plant) => { let mut state = plantstate[plant]; @@ -385,7 +385,7 @@ fn safe_main() -> anyhow::Result<()> { "Trying to pump for {}s with pump {} now", plant_config.pump_time_s, plant ); - + did_pump = true; board.any_pump(true)?; board.store_last_pump_time(plant, cur); board.pump(plant, true)?; @@ -512,14 +512,25 @@ fn safe_main() -> anyhow::Result<()> { } 12 * 60 } else if is_day { - if online_mode == OnlineMode::Online { - let _ = board.mqtt_publish( - &config, - "/deepsleep", - "Entering normal mode 20m deep sleep".as_bytes(), - ); + if did_pump { + if online_mode == OnlineMode::Online { + let _ = board.mqtt_publish( + &config, + "/deepsleep", + "Entering after pump restart deep sleep".as_bytes(), + ); + } + 0 + } else { + if online_mode == OnlineMode::Online { + let _ = board.mqtt_publish( + &config, + "/deepsleep", + "Entering normal mode 20m deep sleep".as_bytes(), + ); + } + 20 } - 20 } else { if online_mode == OnlineMode::Online { let _ = board.mqtt_publish(