diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 32e3b532..4cc99a6a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -48,10 +48,10 @@ jobs:
- name: Add MD5 checksum to ESP32 binary
run: cd HeishaMon && MD5=`md5sum HeishaMon.ino.bin | cut -d\ -f1` && mv HeishaMon.ino.bin HeishaMon_ESP32-alpha-$MD5.bin
- shell: bash
+ shell: bash
- name: Upload artifacts
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: HeishaMon.ino.bin
- path: HeishaMon/HeishaMon_*.bin
\ No newline at end of file
+ path: HeishaMon/HeishaMon_*.bin
diff --git a/HeishaMon/HeishaMon.ino b/HeishaMon/HeishaMon.ino
index c99bafa1..af4a90e9 100644
--- a/HeishaMon/HeishaMon.ino
+++ b/HeishaMon/HeishaMon.ino
@@ -1486,16 +1486,21 @@ void setup() {
}
loggingSerial.println(F("Enabling rules.."));
+ if (heishamonSettings.force_rules == false) {
#if defined(ESP8266)
rst_info *resetInfo = ESP.getResetInfoPtr();
loggingSerial.printf(PSTR("Reset reason: %d, exception cause: %d\n"), resetInfo->reason, resetInfo->exccause);
- if (resetInfo->reason > 0 && resetInfo->reason < 4) {
+ if (resetInfo->reason > 0 && resetInfo->reason < 4) {
#elif defined(ESP32)
- esp_reset_reason_t reset_reason = esp_reset_reason();
- loggingSerial.printf(PSTR("Reset reason: %d\n"), reset_reason);
- if (reset_reason > 3 && reset_reason < 12) { //is this correct for esp32?
+ esp_reset_reason_t reset_reason = esp_reset_reason();
+ loggingSerial.printf(PSTR("Reset reason: %d\n"), reset_reason);
+ if (reset_reason > 3 && reset_reason < 12) { //is this correct for esp32?
#endif
- loggingSerial.println("Not loading rules due to crash reboot!");
+ loggingSerial.println("Not loading rules due to crash reboot!");
+ } else {
+ rules_parse((char *)"/rules.txt");
+ rules_boot();
+ }
} else {
rules_parse((char *)"/rules.txt");
rules_boot();
diff --git a/HeishaMon/htmlcode.h b/HeishaMon/htmlcode.h
index 821a2c6b..30af0f5c 100644
--- a/HeishaMon/htmlcode.h
+++ b/HeishaMon/htmlcode.h
@@ -858,6 +858,13 @@ static const char settingsForm2[] PROGMEM =
" "
" "
" "
+ "
"
+ " "
+ " Force loading rules on boot (despite crash conditions): | "
+ " "
+ " "
+ " | "
+ "
"
" "
" "
" "
diff --git a/HeishaMon/webfunctions.cpp b/HeishaMon/webfunctions.cpp
index 1ba03ad9..c3b81815 100755
--- a/HeishaMon/webfunctions.cpp
+++ b/HeishaMon/webfunctions.cpp
@@ -217,6 +217,7 @@ void loadSettings(settingsStruct *heishamonSettings) {
if ( jsonDoc["mqtt_password"] ) strlcpy(heishamonSettings->mqtt_password, jsonDoc["mqtt_password"], sizeof(heishamonSettings->mqtt_password));
if ( jsonDoc["ntp_servers"] ) strlcpy(heishamonSettings->ntp_servers, jsonDoc["ntp_servers"], sizeof(heishamonSettings->ntp_servers));
if ( jsonDoc["timezone"]) heishamonSettings->timezone = jsonDoc["timezone"];
+ heishamonSettings->force_rules = ( jsonDoc["force_rules"] == "enabled" ) ? true : false;
heishamonSettings->use_1wire = ( jsonDoc["use_1wire"] == "enabled" ) ? true : false;
heishamonSettings->use_s0 = ( jsonDoc["use_s0"] == "enabled" ) ? true : false;
heishamonSettings->hotspot = ( jsonDoc["hotspot"] == "disabled" ) ? false : true; //default to true if not found in settings
@@ -414,6 +415,10 @@ void settingsToJson(JsonDocument &jsonDoc, settingsStruct *heishamonSettings) {
jsonDoc["listenonly"] = "enabled";
} else {
jsonDoc["listenonly"] = "disabled";
+ } if (heishamonSettings->force_rules) {
+ jsonDoc["force_rules"] = "enabled";
+ } else {
+ jsonDoc["force_rules"] = "disabled";
}
if (heishamonSettings->listenmqtt) {
jsonDoc["listenmqtt"] = "enabled";
@@ -482,6 +487,7 @@ int saveSettings(struct webserver_t *client, settingsStruct *heishamonSettings)
settingsToJson(jsonDoc, heishamonSettings); //stores current settings in a json document
+ jsonDoc["force_rules"] = String("disabled");
jsonDoc["hotspot"] = String("disabled");
jsonDoc["listenonly"] = String("disabled");
jsonDoc["listenmqtt"] = String("disabled");
@@ -490,6 +496,7 @@ int saveSettings(struct webserver_t *client, settingsStruct *heishamonSettings)
jsonDoc["logSerial1"] = String("disabled");
jsonDoc["optionalPCB"] = String("disabled");
jsonDoc["opentherm"] = String("disabled");
+
#ifdef ESP32
jsonDoc["proxy"] = String("disabled");
#endif
@@ -523,6 +530,8 @@ int saveSettings(struct webserver_t *client, settingsStruct *heishamonSettings)
jsonDoc["hotspot"] = tmp->value;
} else if (strcmp(tmp->name.c_str(), "listenonly") == 0) {
jsonDoc["listenonly"] = tmp->value;
+ } else if (strcmp(tmp->name.c_str(), "force_rules") == 0) {
+ jsonDoc["force_rules"] = tmp->value;
} else if (strcmp(tmp->name.c_str(), "listenmqtt") == 0) {
jsonDoc["listenmqtt"] = tmp->value;
} else if (strcmp(tmp->name.c_str(), "logMqtt") == 0) {
@@ -791,6 +800,12 @@ int getSettings(struct webserver_t *client, settingsStruct *heishamonSettings) {
itoa(heishamonSettings->listenonly, str, 10);
webserver_send_content(client, str, strlen(str));
+
+ webserver_send_content_P(client, PSTR(",\"force_rules\":"), 15);
+
+ itoa(heishamonSettings->force_rules, str, 10);
+ webserver_send_content(client, str, strlen(str));
+
} break;
case 6: {
char str[20];
diff --git a/HeishaMon/webfunctions.h b/HeishaMon/webfunctions.h
index 043b1a02..16ab8a06 100644
--- a/HeishaMon/webfunctions.h
+++ b/HeishaMon/webfunctions.h
@@ -47,6 +47,7 @@ struct settingsStruct {
char mqtt_topic_listen[128] = "master_panasonic_heat_pump";
char ntp_servers[254] = "pool.ntp.org";
+ bool force_rules = false; //force rules on boot, even after a crash
bool listenonly = false; //listen only so heishamon can be installed parallel to cz-taw1, set commands will not work though
bool listenmqtt = false; //do we get heatpump data from another heishamon over mqtt?
bool optionalPCB = false; //do we emulate an optional PCB?