Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force rules on boot despite crash #143

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
path: HeishaMon/HeishaMon_*.bin
15 changes: 10 additions & 5 deletions HeishaMon/HeishaMon.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions HeishaMon/htmlcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,13 @@ static const char settingsForm2[] PROGMEM =
" <input type=\"checkbox\" name=\"opentherm\" value=\"enabled\">"
" </td>"
" </tr>"
" <tr>"
" <td style=\"text-align:right; width: 50%\">"
" Force loading rules on boot (despite crash conditions):</td>"
" <td style=\"text-align:left\">"
" <input type=\"checkbox\" name=\"force_rules\" value=\"enabled\">"
" </td>"
" </tr>"
" </table>"
" <table style=\"width:100%\">"
" <tr>"
Expand Down
15 changes: 15 additions & 0 deletions HeishaMon/webfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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");
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions HeishaMon/webfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Loading