|
@@ -414,6 +414,8 @@ void Statemachine::input(int n) {
|
414
|
414
|
}
|
415
|
415
|
} else if (state == fullauto_fert_run) {
|
416
|
416
|
// allow user to stop fertizilers and continue with tank filling
|
|
417
|
+ plants.abort();
|
|
418
|
+ stop_time = millis();
|
417
|
419
|
auto wl = plants.getWaterlevel();
|
418
|
420
|
if ((wl != Plants::full) && (wl != Plants::invalid)) {
|
419
|
421
|
// if the waterlevel is currently empty, we
|
|
@@ -661,6 +663,12 @@ void Statemachine::input(int n) {
|
661
|
663
|
return;
|
662
|
664
|
}
|
663
|
665
|
|
|
666
|
+#ifdef FULLAUTO_MIN_PLANT_COUNT
|
|
667
|
+ if (selected_plants.countSet() < FULLAUTO_MIN_PLANT_COUNT) {
|
|
668
|
+ return;
|
|
669
|
+ }
|
|
670
|
+#endif
|
|
671
|
+
|
664
|
672
|
// check if we need to run fertilizers
|
665
|
673
|
if (selected_ferts.countSet() > 0) {
|
666
|
674
|
// stirr before pumping fertilizers
|
|
@@ -1470,16 +1478,7 @@ void Statemachine::act(void) {
|
1470
|
1478
|
debug.println("ms");
|
1471
|
1479
|
|
1472
|
1480
|
#if defined(PLATFORM_ESP)
|
1473
|
|
- bool success = wifi_write_database(time_to_fill, "calibrated_filling", -1);
|
1474
|
|
- if (!success) {
|
1475
|
|
- debug.print("Error writing to InfluxDB ");
|
1476
|
|
- debug.print(INFLUXDB_HOST);
|
1477
|
|
- debug.print(":");
|
1478
|
|
- debug.print(INFLUXDB_PORT);
|
1479
|
|
- debug.print("/");
|
1480
|
|
- debug.print(INFLUXDB_DATABASE);
|
1481
|
|
- debug.println("/calibrated_filling");
|
1482
|
|
- }
|
|
1481
|
+ wifi_write_database(time_to_fill, "calibrated_filling", -1);
|
1483
|
1482
|
#endif // PLATFORM_ESP
|
1484
|
1483
|
}
|
1485
|
1484
|
|
|
@@ -1637,18 +1636,9 @@ void Statemachine::act(void) {
|
1637
|
1636
|
debug.print(String(time_to_water));
|
1638
|
1637
|
debug.println("ms");
|
1639
|
1638
|
|
1640
|
|
- #if defined(PLATFORM_ESP)
|
1641
|
|
- bool success = wifi_write_database(time_to_water, "calibrated_watering", selected_plants.getFirstSet() + 1);
|
1642
|
|
- if (!success) {
|
1643
|
|
- debug.print("Error writing to InfluxDB ");
|
1644
|
|
- debug.print(INFLUXDB_HOST);
|
1645
|
|
- debug.print(":");
|
1646
|
|
- debug.print(INFLUXDB_PORT);
|
1647
|
|
- debug.print("/");
|
1648
|
|
- debug.print(INFLUXDB_DATABASE);
|
1649
|
|
- debug.println("/calibrated_watering");
|
1650
|
|
- }
|
1651
|
|
- #endif // PLATFORM_ESP
|
|
1639
|
+#if defined(PLATFORM_ESP)
|
|
1640
|
+ wifi_write_database(time_to_water, "calibrated_watering", selected_plants.getFirstSet() + 1);
|
|
1641
|
+#endif // PLATFORM_ESP
|
1652
|
1642
|
}
|
1653
|
1643
|
}
|
1654
|
1644
|
|
|
@@ -1917,29 +1907,11 @@ void Statemachine::switch_to(States s) {
|
1917
|
1907
|
if ((old_state == auto_plant_run) || (old_state == fillnwater_plant_run)) {
|
1918
|
1908
|
for (int i = 0; i < plants.countPlants(); i++) {
|
1919
|
1909
|
if (selected_plants.isSet(i)) {
|
1920
|
|
- bool success = wifi_write_database(runtime / 1000, "plant", i + 1);
|
1921
|
|
- if (!success) {
|
1922
|
|
- debug.print("Error writing to InfluxDB ");
|
1923
|
|
- debug.print(INFLUXDB_HOST);
|
1924
|
|
- debug.print(":");
|
1925
|
|
- debug.print(INFLUXDB_PORT);
|
1926
|
|
- debug.print("/");
|
1927
|
|
- debug.print(INFLUXDB_DATABASE);
|
1928
|
|
- debug.println("/plant");
|
1929
|
|
- }
|
|
1910
|
+ wifi_write_database(runtime / 1000, "plant", i + 1);
|
1930
|
1911
|
}
|
1931
|
1912
|
}
|
1932
|
1913
|
} else if (old_state == auto_fert_run) {
|
1933
|
|
- bool success = wifi_write_database(runtime / 1000, "fertilizer", selected_id);
|
1934
|
|
- if (!success) {
|
1935
|
|
- debug.print("Error writing to InfluxDB ");
|
1936
|
|
- debug.print(INFLUXDB_HOST);
|
1937
|
|
- debug.print(":");
|
1938
|
|
- debug.print(INFLUXDB_PORT);
|
1939
|
|
- debug.print("/");
|
1940
|
|
- debug.print(INFLUXDB_DATABASE);
|
1941
|
|
- debug.println("/fertilizer");
|
1942
|
|
- }
|
|
1914
|
+ wifi_write_database(runtime / 1000, "fertilizer", selected_id);
|
1943
|
1915
|
}
|
1944
|
1916
|
#endif // PLATFORM_ESP
|
1945
|
1917
|
} else if (s == menu_pumps) {
|
|
@@ -1995,16 +1967,7 @@ void Statemachine::switch_to(States s) {
|
1995
|
1967
|
|
1996
|
1968
|
#if defined(PLATFORM_ESP)
|
1997
|
1969
|
unsigned long runtime = stop_time - start_time;
|
1998
|
|
- bool success = wifi_write_database(runtime / 1000, "fertilizer", selected_id);
|
1999
|
|
- if (!success) {
|
2000
|
|
- debug.print("Error writing to InfluxDB ");
|
2001
|
|
- debug.print(INFLUXDB_HOST);
|
2002
|
|
- debug.print(":");
|
2003
|
|
- debug.print(INFLUXDB_PORT);
|
2004
|
|
- debug.print("/");
|
2005
|
|
- debug.print(INFLUXDB_DATABASE);
|
2006
|
|
- debug.println("/fertilizer");
|
2007
|
|
- }
|
|
1970
|
+ wifi_write_database(runtime / 1000, "fertilizer", selected_id);
|
2008
|
1971
|
#endif // PLATFORM_ESP
|
2009
|
1972
|
} else if (s == menu_valves) {
|
2010
|
1973
|
String a = String(F("(Input 1 to ")) + String(plants.countPlants() + 1) + String(F(")"));
|
|
@@ -2060,16 +2023,7 @@ void Statemachine::switch_to(States s) {
|
2060
|
2023
|
#if defined(PLATFORM_ESP)
|
2061
|
2024
|
unsigned long runtime = stop_time - start_time;
|
2062
|
2025
|
if (selected_id <= plants.countPlants()) {
|
2063
|
|
- bool success = wifi_write_database(runtime / 1000, "plant", selected_id);
|
2064
|
|
- if (!success) {
|
2065
|
|
- debug.print("Error writing to InfluxDB ");
|
2066
|
|
- debug.print(INFLUXDB_HOST);
|
2067
|
|
- debug.print(":");
|
2068
|
|
- debug.print(INFLUXDB_PORT);
|
2069
|
|
- debug.print("/");
|
2070
|
|
- debug.print(INFLUXDB_DATABASE);
|
2071
|
|
- debug.println("/plant");
|
2072
|
|
- }
|
|
2026
|
+ wifi_write_database(runtime / 1000, "plant", selected_id);
|
2073
|
2027
|
}
|
2074
|
2028
|
#endif // PLATFORM_ESP
|
2075
|
2029
|
} else if (s == menu_aux) {
|