Skip to content

Commit

Permalink
Merge branch '3.9b' of https://github.com/IgorYbema/HeishaMon into 3.9b
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorYbema committed Jan 10, 2025
2 parents e48a4fb + 47b4855 commit aba49b6
Show file tree
Hide file tree
Showing 18 changed files with 738 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ 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@v4
Expand Down
2 changes: 1 addition & 1 deletion HeatPumpType.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Assuming that bytes from #129 to #138 are unique for each model of Aquarea heat
|26 | 42 D4 0B 83 71 42 D2 0C 46 55 | WH-ADC0309J3E5C | WH-UD07JE5 | KIT-ADC07JE5C | 7 | 1ph | HP - All-In-One Compact |
|27 | C2 D3 0C 34 65 B2 D3 0B 95 65 | Monoblock | WH-MDC07J3E5 | Monoblock | 7 | 1ph | HP (new version?) |
|28 | C2 D3 0C 33 65 B2 D3 0B 94 65 | Monoblock | WH-MDC05J3E5 | Monoblock | 5 | 1ph | HP (new version) |
|29 | E2 CF 0B 83 05 12 D0 0D 92 05 | WH-UQ12HE8 | WH-SQC12H9E8 | KIT-WQC12H9E8 | 12 | 3ph | T-CAP - Super Quiet |
|29 | E2 CF 0B 83 05 12 D0 0D 92 05 | WH-SQC12H9E8 | WH-UQ12HE8 | KIT-WQC12H9E8 | 12 | 3ph | T-CAP - Super Quiet |
|30 | E2 CF 0C 78 09 12 D0 0B 06 11 | WH-SXC12H6E5 | WH-UX12HE5 | KIT-WXC12H6E5 | 12 | 1ph | T-CAP |
|31 | C2 D3 0C 35 65 B2 D3 0B 96 65 | Monoblock | WH-MDC09J3E5 | Monoblock | 9 | 1ph | HP (new version?) |
|32 | 32 D4 0B 99 77 62 90 0B 01 78 | Monoblock | WH-MXC09J3E5 | Monoblock | 9 | 1ph | T-CAP
Expand Down
15 changes: 10 additions & 5 deletions HeishaMon/HeishaMon.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1482,16 +1482,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
76 changes: 76 additions & 0 deletions HeishaMon/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,82 @@ unsigned int set_gpio16state(char *msg, unsigned char *cmd, char *log_msg) {
return 0; // do nothing
}

unsigned int set_external_control(char *msg, unsigned char *cmd, char *log_msg){
const byte off_state=1;
const byte address=23;
byte value = off_state;
if ( String(msg).toInt() == 1 ) {
value = off_state * 2;
}
{
char tmp[256] = { 0 };
snprintf_P(tmp, 255, PSTR("set external control enabled to %d"), ((value / off_state) - 1) );
memcpy(log_msg, tmp, sizeof(tmp));
}
{
memcpy_P(cmd, panasonicSendQuery, sizeof(panasonicSendQuery));
cmd[address] = value;
}
return sizeof(panasonicSendQuery);
}

unsigned int set_external_heat_cool_control(char *msg, unsigned char *cmd, char *log_msg){
const byte off_state=4;
const byte address=23;
byte value = off_state;
if ( String(msg).toInt() == 1 ) {
value = off_state * 2;
}
{
char tmp[256] = { 0 };
snprintf_P(tmp, 255, PSTR("set external cool/heat control enabled to %d"), ((value / off_state) - 1) );
memcpy(log_msg, tmp, sizeof(tmp));
}
{
memcpy_P(cmd, panasonicSendQuery, sizeof(panasonicSendQuery));
cmd[address] = value;
}
return sizeof(panasonicSendQuery);
}

unsigned int set_external_error(char *msg, unsigned char *cmd, char *log_msg){
const byte off_state=16;
const byte address=23;
byte value = off_state;
if ( String(msg).toInt() == 1 ) {
value = off_state * 2;
}
{
char tmp[256] = { 0 };
snprintf_P(tmp, 255, PSTR("set external error signal enabled to %d"), ((value / off_state) - 1) );
memcpy(log_msg, tmp, sizeof(tmp));
}
{
memcpy_P(cmd, panasonicSendQuery, sizeof(panasonicSendQuery));
cmd[address] = value;
}
return sizeof(panasonicSendQuery);
}

unsigned int set_external_compressor_control(char *msg, unsigned char *cmd, char *log_msg){
const byte off_state=64;
const byte address=23;
byte value = off_state;
if ( String(msg).toInt() == 1 ) {
value = off_state * 2;
}
{
char tmp[256] = { 0 };
snprintf_P(tmp, 255, PSTR("set external compressor control enabled to %d"), ((value / off_state) - 1) );
memcpy(log_msg, tmp, sizeof(tmp));
}
{
memcpy_P(cmd, panasonicSendQuery, sizeof(panasonicSendQuery));
cmd[address] = value;
}
return sizeof(panasonicSendQuery);
}

//start of optional pcb commands
unsigned int set_byte_6(int val, int base, int bit, char *log_msg, const char *func) {
unsigned char hex = (optionalPCBQuery[6] & ~(base << bit)) | (val << bit);
Expand Down
11 changes: 9 additions & 2 deletions HeishaMon/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ unsigned int set_buffer_delta(char *msg, unsigned char *cmd, char *log_msg);
unsigned int set_buffer(char *msg, unsigned char *cmd, char *log_msg);
unsigned int set_heatingoffoutdoortemp(char *msg, unsigned char *cmd, char *log_msg);
unsigned int set_gpio16state(char *msg, unsigned char *cmd, char *log_msg);

unsigned int set_external_control(char *msg, unsigned char *cmd, char *log_msg);
unsigned int set_external_error(char *msg, unsigned char *cmd, char *log_msg);

//optional pcb commands
unsigned int set_heat_cool_mode(char *msg, char *log_msg);
Expand All @@ -77,9 +78,11 @@ unsigned int set_z2_room_temp(char *msg, char *log_msg);
unsigned int set_z2_water_temp(char *msg, char *log_msg);
unsigned int set_solar_temp(char *msg, char *log_msg);
unsigned int set_byte_9(char *msg, char *log_msg);
unsigned int set_external_compressor_control(char *msg, unsigned char *cmd, char *log_msg);
unsigned int set_external_heat_cool_control(char *msg, unsigned char *cmd, char *log_msg);

struct cmdStruct {
char name[28];
char name[29];
unsigned int (*func)(char *msg, unsigned char *cmd, char *log_msg);
};

Expand Down Expand Up @@ -133,6 +136,10 @@ const cmdStruct commands[] PROGMEM = {
// set Outdoor Temperature to stop heating 5-35
{ "SetHeatingOffOutdoorTemp", set_heatingoffoutdoortemp },
{ "SetGPIO16State", set_gpio16state },
{ "SetExternalControl", set_external_control },
{ "SetExternalError", set_external_error },
{ "SetExternalCompressorControl", set_external_compressor_control },
{ "SetExternalHeatCoolControl", set_external_heat_cool_control },
};

struct optCmdStruct{
Expand Down
46 changes: 44 additions & 2 deletions HeishaMon/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static const byte knownModels[sizeof(Model) / sizeof(Model[0])][10] PROGMEM = {
0xE2, 0xD5, 0x0D, 0x99, 0x94, 0x02, 0xD6, 0x0D, 0x68, 0x95, //46
};

#define NUMBER_OF_TOPICS 119 //last topic number + 1
#define NUMBER_OF_TOPICS 129 //last topic number + 1
#define NUMBER_OF_TOPICS_EXTRA 6 //last topic number + 1
#define NUMBER_OF_OPT_TOPICS 7 //last topic number + 1
#define MAX_TOPIC_LEN 41 // max length + 1
Expand Down Expand Up @@ -291,6 +291,16 @@ static const char topics[][MAX_TOPIC_LEN] PROGMEM = {
"Second_Inlet_Temp", //TOP116
"Economizer_Outlet_Temp", //TOP117
"Second_Room_Thermostat_Temp",//TOP118
"External_Control", //TOP119
"External_Heat_Cool_Control", //TOP120
"External_Error_Signal", //TOP121
"External_Compressor_Control", //TOP122
"Z2_Pump_State", //TOP123
"Z1_Pump_State", //TOP124
"TwoWay_Valve_State", //TOP125
"ThreeWay_Valve_State2", //TOP126
"Z2_Valve_PID", //TOP127
"Z1_Valve_PID", //TOP128
};

static const byte topicBytes[] PROGMEM = { //can store the index as byte (8-bit unsigned humber) as there aren't more then 255 bytes (actually only 203 bytes) to decode
Expand Down Expand Up @@ -413,6 +423,17 @@ static const byte topicBytes[] PROGMEM = { //can store the index as byte (8-bit
126, //TOP116
127, //TOP117
128, //TOP118
23, //TOP119
23, //TOP120
23, //TOP121
23, //TOP122
116, //TOP123
116, //TOP124
116, //TOP125
116, //TOP126
177, //TOP127
178, //TOP128

};


Expand Down Expand Up @@ -547,6 +568,16 @@ static const topicFP topicFunctions[] PROGMEM = {
getIntMinus128, //TOP116
getIntMinus128, //TOP117
getIntMinus128, //TOP118
getBit7and8, //TOP119
getBit5and6, //TOP120
getBit3and4, //TOP121
getBit1and2, //TOP122
getBit1and2, //TOP123
getBit3and4, //TOP124
getBit5and6, //TOP125
getBit7and8, //TOP126
getIntMinus1, //TOP127
getIntMinus1, //TOP128
};

static const char *DisabledEnabled[] PROGMEM = {"2", "Disabled", "Enabled"};
Expand All @@ -559,6 +590,7 @@ static const char *OpModeDesc[] PROGMEM = {"9", "Heat", "Cool", "Auto(heat)", "D
static const char *Powerfulmode[] PROGMEM = {"4", "Off", "30min", "60min", "90min"};
static const char *Quietmode[] PROGMEM = {"4", "Off", "Level 1", "Level 2", "Level 3"};
static const char *Valve[] PROGMEM = {"2", "Room", "DHW"};
static const char *Valve2[] PROGMEM = {"2", "Cool", "Heat"};
static const char *MixingValve[] PROGMEM = {"4", "Off", "Increase","Nothing","Decrease"};
static const char *LitersPerMin[] PROGMEM = {"0", "l/min"};
static const char *RotationsPerMin[] PROGMEM = {"0", "r/min"};
Expand All @@ -580,7 +612,7 @@ static const char *SolarModeDesc[] PROGMEM = {"3", "Disabled", "Buffer", "DHW"};
static const char *ZonesSensorType[] PROGMEM = {"4", "Water Temperature", "External Thermostat", "Internal Thermostat", "Thermistor"};
static const char *LiquidType[] PROGMEM = {"2", "Water", "Glycol"};
static const char *ExtPadHeaterType[] PROGMEM = {"3", "Disabled", "Type-A","Type-B"};

static const char *Percent[] PROGMEM = {"0", "%"};

static const char **opttopicDescription[] PROGMEM = {
OffOn, //OPT0
Expand Down Expand Up @@ -721,4 +753,14 @@ static const char **topicDescription[] PROGMEM = {
Celsius, //TOP116
Celsius, //TOP117
Celsius, //TOP118
DisabledEnabled, //TOP119
DisabledEnabled, //TOP120
DisabledEnabled, //TOP121
DisabledEnabled, //TOP122
OffOn, //TOP123
OffOn, //TOP124
Valve2, //TOP125
Valve, //TOP126
Percent, //TOP127
Percent, //TOP128
};
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
39 changes: 36 additions & 3 deletions HeishaMon/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,33 @@ static int8_t event_cb(struct rules_t *obj, char *name) {
return 1;
}

static int8_t check_is_number(char *str) {
uint16_t i = 0, nrdot = 0, pos = 0, len = strlen(str);
char current = str[0];

if(isdigit(current) || current == '-') {
/*
* The dot cannot be the first character
* and we cannot have more than 1 dot
*/
while(pos <= len) {
if(!(isdigit(current) || (i == 0 && current == '-') || (i > 0 && nrdot == 0 && current == '.'))) {
return -1;
}
if(current == '.') {
nrdot++;
}
pos++;
current = str[pos];
i++;
}

return 0;
} else {
return -1;
}
}

static int8_t vm_value_get(struct rules_t *obj) {
int16_t x = 0;

Expand Down Expand Up @@ -414,7 +441,7 @@ static int8_t vm_value_get(struct rules_t *obj) {
char *str = (char *)dataValue.c_str();
if(strlen(str) == 0) {
rules_pushnil(obj);
} else {
} else if(check_is_number(str) == 0) {
float var = atof(str);
float nr = 0;

Expand All @@ -425,6 +452,8 @@ static int8_t vm_value_get(struct rules_t *obj) {
rules_pushfloat(obj, var);
return 0;
}
} else {
rules_pushstring(obj, str);
}
}
}
Expand All @@ -436,7 +465,7 @@ static int8_t vm_value_get(struct rules_t *obj) {
char *str = (char *)dataValue.c_str();
if(strlen(str) == 0) {
rules_pushnil(obj);
} else {
} else if(check_is_number(str) == 0) {
float var = atof(str);
float nr = 0;

Expand All @@ -447,6 +476,8 @@ static int8_t vm_value_get(struct rules_t *obj) {
rules_pushfloat(obj, var);
return 0;
}
} else {
rules_pushstring(obj, str);
}
}
}
Expand All @@ -458,7 +489,7 @@ static int8_t vm_value_get(struct rules_t *obj) {
char *str = (char *)dataValue.c_str();
if(strlen(str) == 0) {
rules_pushnil(obj);
} else {
} else if(check_is_number(str) == 0) {
float var = atof(str);
float nr = 0;

Expand All @@ -469,6 +500,8 @@ static int8_t vm_value_get(struct rules_t *obj) {
rules_pushfloat(obj, var);
return 0;
}
} else {
rules_pushstring(obj, str);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion HeishaMon/src/rules/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "functions/isset.h"
#include "functions/concat.h"
#include "functions/print.h"
#include "functions/gpio.h"

struct rule_function_t rule_functions[] = {
{ "max", rule_function_max_callback },
Expand All @@ -44,7 +45,8 @@ struct rule_function_t rule_functions[] = {
{ "setTimer", rule_function_set_timer_callback },
{ "isset", rule_function_isset_callback },
{ "print", rule_function_print_callback },
{ "concat", rule_function_concat_callback }
{ "concat", rule_function_concat_callback },
{ "gpio", rule_function_gpio_callback }
};

uint16_t nr_rule_functions = sizeof(rule_functions)/sizeof(rule_functions[0]);
Loading

0 comments on commit aba49b6

Please sign in to comment.