Browse Source

stop when sensors show empty tank in valve run mode

Thomas Buck 3 years ago
parent
commit
3ae0b30009
1 changed files with 15 additions and 0 deletions
  1. 15
    0
      src/Statemachine.cpp

+ 15
- 0
src/Statemachine.cpp View File

@@ -432,6 +432,21 @@ void Statemachine::act(void) {
432 432
         }
433 433
     }
434 434
     
435
+    if ((state == menu_valves_run) && (selected_id <= plants.countPlants())) {
436
+        // check water level state
437
+        auto wl = plants.getWaterlevel();
438
+        if (wl == Plants::empty) {
439
+            plants.abort();
440
+            stop_time = millis();
441
+            switch_to(menu_valves_done);
442
+        } else if (wl == Plants::invalid) {
443
+            plants.abort();
444
+            error_condition = "Invalid sensor state";
445
+            state = menu_valves;
446
+            switch_to(error);
447
+        }
448
+    }
449
+    
435 450
     if ((state == auto_fert_run) || (state == auto_tank_run)) {
436 451
         unsigned long runtime = millis() - start_time;
437 452
         if ((runtime / 1000UL) >= selected_time) {

Loading…
Cancel
Save