Skip to content

Commit 708fd68

Browse files
authored
Remove Autostart parameter and make the flow to be always enabled (#3423)
* removed Autostart parameter and make it enabled by default * . * show menu entry in UI * cleanup migration * . * . * . * . * . * . * . * .
1 parent 1b5ff2e commit 708fd68

File tree

10 files changed

+24
-30
lines changed

10 files changed

+24
-30
lines changed

code/components/jomjol_flowcontroll/ClassFlowControll.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ bool ClassFlowControll::StartMQTTService()
196196

197197
void ClassFlowControll::SetInitialParameter(void)
198198
{
199-
AutoStart = false;
199+
AutoStart = true;
200200
SetupModeActive = false;
201201
AutoInterval = 10; // Minutes
202202
flowdigit = NULL;
@@ -210,7 +210,8 @@ void ClassFlowControll::SetInitialParameter(void)
210210

211211
bool ClassFlowControll::getIsAutoStart(void)
212212
{
213-
return AutoStart;
213+
//return AutoStart;
214+
return true; // Flow must always be enabled, else the manual trigger (REST, MQTT) will not work!
214215
}
215216

216217

@@ -557,10 +558,6 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
557558

558559
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) {
559560
splitted = ZerlegeZeile(aktparamgraph, " =");
560-
561-
if ((toUpper(splitted[0]) == "AUTOSTART") && (splitted.size() > 1)) {
562-
AutoStart = alphanumericToBoolean(splitted[1]);
563-
}
564561

565562
if ((toUpper(splitted[0]) == "INTERVAL") && (splitted.size() > 1)) {
566563
if (isStringNumeric(splitted[1]))

code/components/jomjol_flowcontroll/MainFlowControl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,7 @@ esp_err_t handler_flow_start(httpd_req_t *req)
422422
else
423423
{
424424
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Flow start triggered by REST API, but flow is not active!");
425-
const char *resp_str = "WARNING: Flow start triggered by REST API, but flow is not active";
426-
httpd_resp_send(req, resp_str, HTTPD_RESP_USE_STRLEN);
425+
httpd_resp_send_err(req, HTTPD_403_FORBIDDEN, "Flow start triggered by REST API, but flow is not active");
427426
}
428427

429428
#ifdef DEBUG_DETAIL_ON

code/main/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,7 @@ void migrateConfiguration(void) {
727727
}
728728
else if (section == "[AutoTimer]") {
729729
migrated = migrated | replaceString(configLines[i], "Intervall", "Interval");
730-
migrated = migrated | replaceString(configLines[i], ";AutoStart = true", ";AutoStart = false"); // Set it to its default value
731-
migrated = migrated | replaceString(configLines[i], ";AutoStart", "AutoStart"); // Enable it
730+
migrated = migrated | replaceString(configLines[i], "Autostart", ";UNUSED_PARAMETER"); // This parameter is no longer used
732731
}
733732
else if (section == "[Debug]") {
734733
migrated = migrated | replaceString(configLines[i], "Logfile ", "LogLevel "); // Whitespace needed so it does not match `LogfileRetentionInDays`
@@ -741,7 +740,7 @@ void migrateConfiguration(void) {
741740
else if (section == "[System]") {
742741
migrated = migrated | replaceString(configLines[i], "RSSIThreashold", "RSSIThreshold");
743742
migrated = migrated | replaceString(configLines[i], "AutoAdjustSummertime", ";UNUSED_PARAMETER"); // This parameter is no longer used
744-
743+
745744
migrated = migrated | replaceString(configLines[i], ";SetupMode = true", ";SetupMode = false"); // Set it to its default value
746745
migrated = migrated | replaceString(configLines[i], ";SetupMode", "SetupMode"); // Enable it
747746
}

param-docs/parameter-pages/AutoTimer/AutoStart.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,4 @@
22
Default Value: `true`
33

44
!!! Warning
5-
This is an **Expert Parameter**! Only change it if you understand what it does!
6-
7-
Automatically start the Flow (Digitization Rounds) immediately after power up.
8-
9-
!!! Note
10-
Typically this is set to `true`.
11-
The main reasons to set it to `false` is when you want to trigger it manually using the
12-
[REST API](../REST-API) or [MQTT-API](../MQTT-API) or for debugging.
5+
This parameter is no longer available. The flow is now always enabled. If you want it to be disabled, set an interval which is high enough (eg. 1440 = 24h).

param-docs/parameter-pages/AutoTimer/Interval.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ Default Value: `5`
44
Unit: Minutes
55

66
Interval in which the Flow (Digitization Round) is run.
7+
It will run immediately on startup and then the next time after the given interval.
78
If a round takes longer than this interval, the next round gets postponed until the current round completes.
9+
10+
!!! Note
11+
If you want the flow to be disabled, set an interval which is high enough (eg. 1440 = 24h).

sd-card/config/config.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ LEDNumbers = 2
124124
LEDColor = 150 150 150
125125

126126
[AutoTimer]
127-
AutoStart = true
128127
Interval = 5
129128

130129
[DataLogging]

sd-card/demo/config.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ LEDNumbers = 2
115115
LEDColor = 150 150 150
116116

117117
[AutoTimer]
118-
AutoStart = true
119118
Interval = 1
120119

121120
[DataLogging]

sd-card/html/edit_config_template.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,7 @@ <h4><input type="checkbox" id="Category_GPIO_enabled" value="1" onclick='Update
19201920

19211921

19221922
<!------------- Autotimer ------------------>
1923+
<!--
19231924
<tr style="border-bottom: 2px solid lightgray;">
19241925
<td colspan="3" style="padding-left: 0px; padding-bottom: 3px;"><h4>Auto Timer</h4></td>
19251926
</tr>
@@ -1936,6 +1937,7 @@ <h4><input type="checkbox" id="Category_GPIO_enabled" value="1" onclick='Update
19361937
</td>
19371938
<td>$TOOLTIP_AutoTimer_AutoStart</td>
19381939
</tr>
1940+
-->
19391941

19401942
<tr>
19411943
<td class="indent1">
@@ -2381,7 +2383,7 @@ <h4><input type="checkbox" id="Category_GPIO_enabled" value="1" onclick='Update
23812383
WriteParameter(param, category, "GPIO", "LEDNumbers", false);
23822384
WriteParameter(param, category, "GPIO", "LEDColor", false);
23832385

2384-
WriteParameter(param, category, "AutoTimer", "AutoStart", false);
2386+
//WriteParameter(param, category, "AutoTimer", "AutoStart", false);
23852387
WriteParameter(param, category, "AutoTimer", "Interval", false);
23862388

23872389
WriteParameter(param, category, "DataLogging", "DataLogActive", false);
@@ -2556,7 +2558,7 @@ <h4><input type="checkbox" id="Category_GPIO_enabled" value="1" onclick='Update
25562558
param["GPIO"]["LEDNumbers"]["found"] = true;
25572559
param["GPIO"]["LEDColor"]["found"] = true;
25582560

2559-
ReadParameter(param, "AutoTimer", "AutoStart", false);
2561+
//ReadParameter(param, "AutoTimer", "AutoStart", false);
25602562
ReadParameter(param, "AutoTimer", "Interval", false);
25612563

25622564
ReadParameter(param, "DataLogging", "DataLogActive", false);

sd-card/html/index.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h2>An ESP32 all inclusive neural network recognition system for meter Digitizat
159159
</li>
160160
<li id="ManualControl" style="display:none;"><a>Manual Control <i class="arrow down"></i></a> <!-- Workaround: Hide menu if no entry is available -->
161161
<ul class="submenu" style="width: 300px">
162-
<!--<li><a href="#" onclick="flow_start()">Start Round</a></li>--> <!-- Needs to be adapted on code side first to ensure proper user feedback -->
162+
<li><a href="#" onclick="flow_start()">Start Round</a></li>
163163
<li id="HASendDiscovery" style="width: 300px" style="display:none;"><a href="#" onclick="HA_send_discovery()">Resend Homeassistant Discovery</a></li>
164164
</ul>
165165
</li>
@@ -170,6 +170,7 @@ <h2>An ESP32 all inclusive neural network recognition system for meter Digitizat
170170

171171
<span id="Version" style="font-size: 10px; margin-top: -5px;padding-left: 10px;">Loading version...</span>
172172

173+
<!-- # Disabled footer, since it wastes a lot of space and the images are broken
173174
<div class="footer">
174175
<div class="footer-section">
175176
<span>Support & Contact Us</span>
@@ -189,7 +190,7 @@ <h2>An ESP32 all inclusive neural network recognition system for meter Digitizat
189190
<img src="https://github.com/jomjol/AI-on-the-edge-device/images/paypal.png" alt="PayPal" style="width: 60px; height: auto;">
190191
</a>
191192
</div>
192-
</div>
193+
</div> -->
193194

194195
<script type="text/javascript">
195196
LoadHostname();
@@ -203,13 +204,14 @@ <h2>An ESP32 all inclusive neural network recognition system for meter Digitizat
203204
console.log("Loading page: " + getCookie("page"));
204205
document.getElementById('maincontent').src = getCookie("page");
205206

206-
/*
207+
207208
function flow_start() {
208209
var url = getDomainname() + '/flow_start';
209210
var xhttp = new XMLHttpRequest();
210211
xhttp.onreadystatechange = function() {
211212
if (this.readyState == 4 && this.status == 200) {
212-
if (xhttp.responseText.substring(0,3) == "001") {
213+
firework.launch(xhttp.responseText, 'success', 5000);
214+
/*if (xhttp.responseText.substring(0,3) == "001") {
213215
firework.launch('Flow start triggered', 'success', 5000);
214216
window.location.reload();
215217
}
@@ -218,13 +220,13 @@ <h2>An ESP32 all inclusive neural network recognition system for meter Digitizat
218220
}
219221
else if (xhttp.responseText.substring(0,3) == "099") {
220222
firework.launch('Flow start triggered, but start not possible (no flow task available)', 'danger', 5000);
221-
}
223+
}*/
222224
}
223225
}
224226
xhttp.open("GET", url, true);
225227
xhttp.send();
226228
}
227-
*/
229+
228230

229231
function HA_send_discovery_visibility() {
230232
loadConfig(domainname);

sd-card/html/readconfigparam.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function ParseConfig() {
267267
category[catname]["enabled"] = false;
268268
category[catname]["found"] = false;
269269
param[catname] = new Object();
270-
ParamAddValue(param, catname, "AutoStart");
270+
//ParamAddValue(param, catname, "AutoStart");
271271
ParamAddValue(param, catname, "Interval");
272272

273273
var catname = "DataLogging";

0 commit comments

Comments
 (0)