diff --git a/docs/Modbus-Entity-Registers.md b/docs/Modbus-Entity-Registers.md index 8df89219d..7f9d2108d 100644 --- a/docs/Modbus-Entity-Registers.md +++ b/docs/Modbus-Entity-Registers.md @@ -4849,7 +4849,7 @@ | hc1.controlmode | control mode | enum [optimized\|simple\|n/a\|room\|power] | | true | HC | 25 | 1 | 1 | | hc1.program | program | enum [prog 1\|prog 2] | | true | HC | 26 | 1 | 1 | | hc1.tempautotemp | temporary set temperature automode | int8 (>=-1<=30) | C | true | HC | 27 | 1 | 1/2 | -| hc1.remoteseltemp | temporary set temperature from remote | int8 (>=-1<=30) | C | true | HC | 28 | 1 | 1/2 | +| hc1.cooltemp | cooling temperature | int8 (>=-1<=30) | C | true | HC | 28 | 1 | 1/2 | | hc1.fastheatup | fast heatup | uint8 (>=0<=100) | % | true | HC | 29 | 1 | 1 | | hc1.switchonoptimization | switch-on optimization | boolean | | true | HC | 30 | 1 | 1 | | hc1.reducemode | reduce mode | enum [outdoor\|room\|reduce] | | true | HC | 31 | 1 | 1 | diff --git a/docs/dump_entities.csv b/docs/dump_entities.csv index 2f39ed05e..8fed5d32b 100644 --- a/docs/dump_entities.csv +++ b/docs/dump_entities.csv @@ -3412,7 +3412,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "UI800, BC400",thermostat,4,hc1.controlmode,control mode,enum [weather compensated\|outside basepoint\|n/a\|room\|power\|constant], ,true,select.thermostat_hc1_control_mode,select.thermostat_hc1_controlmode,6,1,1,25,1 "UI800, BC400",thermostat,4,hc1.program,program,enum [prog 1\|prog 2], ,true,select.thermostat_hc1_program,select.thermostat_hc1_program,6,1,1,26,1 "UI800, BC400",thermostat,4,hc1.tempautotemp,temporary set temperature automode,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_automode,number.thermostat_hc1_tempautotemp,6,1,1/2,27,1 -"UI800, BC400",thermostat,4,hc1.remoteseltemp,temporary set temperature from remote,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_from_remote,number.thermostat_hc1_remoteseltemp,6,1,1/2,28,1 +"UI800, BC400",thermostat,4,hc1.cooltemp,cooling temperature,int8 (>=-1<=30),C,true,number.thermostat_hc1_cooling_temperature,number.thermostat_hc1_cooltemp,6,1,1/2,28,1 "UI800, BC400",thermostat,4,hc1.fastheatup,fast heatup,uint8 (>=0<=100),%,true,number.thermostat_hc1_fast_heatup,number.thermostat_hc1_fastheatup,6,1,1,29,1 "UI800, BC400",thermostat,4,hc1.switchonoptimization,switch-on optimization,boolean, ,true,switch.thermostat_hc1_switch-on_optimization,switch.thermostat_hc1_switchonoptimization,6,1,1,30,1 "UI800, BC400",thermostat,4,hc1.reducemode,reduce mode,enum [outdoor\|room\|reduce], ,true,select.thermostat_hc1_reduce_mode,select.thermostat_hc1_reducemode,6,1,1,31,1 @@ -3796,7 +3796,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "RC200, CW100, CR120, CR50",thermostat,157,hc1.controlmode,control mode,enum [optimized\|simple\|n/a\|room\|power], ,true,select.thermostat_hc1_control_mode,select.thermostat_hc1_controlmode,6,1,1,25,1 "RC200, CW100, CR120, CR50",thermostat,157,hc1.program,program,enum [prog 1\|prog 2], ,true,select.thermostat_hc1_program,select.thermostat_hc1_program,6,1,1,26,1 "RC200, CW100, CR120, CR50",thermostat,157,hc1.tempautotemp,temporary set temperature automode,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_automode,number.thermostat_hc1_tempautotemp,6,1,1/2,27,1 -"RC200, CW100, CR120, CR50",thermostat,157,hc1.remoteseltemp,temporary set temperature from remote,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_from_remote,number.thermostat_hc1_remoteseltemp,6,1,1/2,28,1 +"RC200, CW100, CR120, CR50",thermostat,157,hc1.cooltemp,cooling temperature,int8 (>=-1<=30),C,true,number.thermostat_hc1_cooling_temperature,number.thermostat_hc1_cooltemp,6,1,1/2,28,1 "RC200, CW100, CR120, CR50",thermostat,157,hc1.fastheatup,fast heatup,uint8 (>=0<=100),%,true,number.thermostat_hc1_fast_heatup,number.thermostat_hc1_fastheatup,6,1,1,29,1 "RC200, CW100, CR120, CR50",thermostat,157,hc1.switchonoptimization,switch-on optimization,boolean, ,true,switch.thermostat_hc1_switch-on_optimization,switch.thermostat_hc1_switchonoptimization,6,1,1,30,1 "RC200, CW100, CR120, CR50",thermostat,157,hc1.reducemode,reduce mode,enum [outdoor\|room\|reduce], ,true,select.thermostat_hc1_reduce_mode,select.thermostat_hc1_reducemode,6,1,1,31,1 @@ -3884,7 +3884,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.controlmode,control mode,enum [weather compensated\|outside basepoint\|n/a\|room\|power\|constant], ,true,select.thermostat_hc1_control_mode,select.thermostat_hc1_controlmode,6,1,1,25,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.program,program,enum [prog 1\|prog 2], ,true,select.thermostat_hc1_program,select.thermostat_hc1_program,6,1,1,26,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.tempautotemp,temporary set temperature automode,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_automode,number.thermostat_hc1_tempautotemp,6,1,1/2,27,1 -"RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.remoteseltemp,temporary set temperature from remote,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_from_remote,number.thermostat_hc1_remoteseltemp,6,1,1/2,28,1 +"RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.cooltemp,cooling temperature,int8 (>=-1<=30),C,true,number.thermostat_hc1_cooling_temperature,number.thermostat_hc1_cooltemp,6,1,1/2,28,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.fastheatup,fast heatup,uint8 (>=0<=100),%,true,number.thermostat_hc1_fast_heatup,number.thermostat_hc1_fastheatup,6,1,1,29,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.switchonoptimization,switch-on optimization,boolean, ,true,switch.thermostat_hc1_switch-on_optimization,switch.thermostat_hc1_switchonoptimization,6,1,1,30,1 "RC3*0, Moduline 3000/1010H, CW400, Sense II, HPC410",thermostat,158,hc1.reducemode,reduce mode,enum [outdoor\|room\|reduce], ,true,select.thermostat_hc1_reduce_mode,select.thermostat_hc1_reducemode,6,1,1,31,1 @@ -3975,7 +3975,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.controlmode,control mode,enum [optimized\|simple\|n/a\|room\|power], ,true,select.thermostat_hc1_control_mode,select.thermostat_hc1_controlmode,6,1,1,25,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.program,program,enum [prog 1\|prog 2], ,true,select.thermostat_hc1_program,select.thermostat_hc1_program,6,1,1,26,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.tempautotemp,temporary set temperature automode,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_automode,number.thermostat_hc1_tempautotemp,6,1,1/2,27,1 -"RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.remoteseltemp,temporary set temperature from remote,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_from_remote,number.thermostat_hc1_remoteseltemp,6,1,1/2,28,1 +"RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.cooltemp,cooling temperature,int8 (>=-1<=30),C,true,number.thermostat_hc1_cooling_temperature,number.thermostat_hc1_cooltemp,6,1,1/2,28,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.fastheatup,fast heatup,uint8 (>=0<=100),%,true,number.thermostat_hc1_fast_heatup,number.thermostat_hc1_fastheatup,6,1,1,29,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.switchonoptimization,switch-on optimization,boolean, ,true,switch.thermostat_hc1_switch-on_optimization,switch.thermostat_hc1_switchonoptimization,6,1,1,30,1 "RC100, CR10, Moduline 1000/1010",thermostat,165,hc1.reducemode,reduce mode,enum [outdoor\|room\|reduce], ,true,select.thermostat_hc1_reduce_mode,select.thermostat_hc1_reducemode,6,1,1,31,1 @@ -4064,7 +4064,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "Rego 2000/3000",thermostat,172,hc1.controlmode,control mode,enum [weather compensated\|outside basepoint\|n/a\|room\|power\|constant], ,true,select.thermostat_hc1_control_mode,select.thermostat_hc1_controlmode,6,1,1,25,1 "Rego 2000/3000",thermostat,172,hc1.program,program,enum [prog 1\|prog 2], ,true,select.thermostat_hc1_program,select.thermostat_hc1_program,6,1,1,26,1 "Rego 2000/3000",thermostat,172,hc1.tempautotemp,temporary set temperature automode,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_automode,number.thermostat_hc1_tempautotemp,6,1,1/2,27,1 -"Rego 2000/3000",thermostat,172,hc1.remoteseltemp,temporary set temperature from remote,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_from_remote,number.thermostat_hc1_remoteseltemp,6,1,1/2,28,1 +"Rego 2000/3000",thermostat,172,hc1.cooltemp,cooling temperature,int8 (>=-1<=30),C,true,number.thermostat_hc1_cooling_temperature,number.thermostat_hc1_cooltemp,6,1,1/2,28,1 "Rego 2000/3000",thermostat,172,hc1.fastheatup,fast heatup,uint8 (>=0<=100),%,true,number.thermostat_hc1_fast_heatup,number.thermostat_hc1_fastheatup,6,1,1,29,1 "Rego 2000/3000",thermostat,172,hc1.switchonoptimization,switch-on optimization,boolean, ,true,switch.thermostat_hc1_switch-on_optimization,switch.thermostat_hc1_switchonoptimization,6,1,1,30,1 "Rego 2000/3000",thermostat,172,hc1.reducemode,reduce mode,enum [outdoor\|room\|reduce], ,true,select.thermostat_hc1_reduce_mode,select.thermostat_hc1_reducemode,6,1,1,31,1 @@ -4181,7 +4181,7 @@ device name,device type,product id,shortname,fullname,type [options...] \| (min/ "Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.controlmode,control mode,enum [weather compensated\|outside basepoint\|n/a\|room\|power\|constant], ,true,select.thermostat_hc1_control_mode,select.thermostat_hc1_controlmode,6,1,1,25,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.program,program,enum [prog 1\|prog 2], ,true,select.thermostat_hc1_program,select.thermostat_hc1_program,6,1,1,26,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.tempautotemp,temporary set temperature automode,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_automode,number.thermostat_hc1_tempautotemp,6,1,1/2,27,1 -"Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.remoteseltemp,temporary set temperature from remote,int8 (>=-1<=30),C,true,number.thermostat_hc1_temporary_set_temperature_from_remote,number.thermostat_hc1_remoteseltemp,6,1,1/2,28,1 +"Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.cooltemp,cooling temperature,int8 (>=-1<=30),C,true,number.thermostat_hc1_cooling_temperature,number.thermostat_hc1_cooltemp,6,1,1/2,28,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.fastheatup,fast heatup,uint8 (>=0<=100),%,true,number.thermostat_hc1_fast_heatup,number.thermostat_hc1_fastheatup,6,1,1,29,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.switchonoptimization,switch-on optimization,boolean, ,true,switch.thermostat_hc1_switch-on_optimization,switch.thermostat_hc1_switchonoptimization,6,1,1,30,1 "Rego 3000, UI800, Logamatic BC400",thermostat,253,hc1.reducemode,reduce mode,enum [outdoor\|room\|reduce], ,true,select.thermostat_hc1_reduce_mode,select.thermostat_hc1_reducemode,6,1,1,31,1 diff --git a/src/core/locale_translations.h b/src/core/locale_translations.h index 5f795415d..fee95d4c2 100644 --- a/src/core/locale_translations.h +++ b/src/core/locale_translations.h @@ -711,7 +711,8 @@ MAKE_TRANSLATION(nighttemp2, "nighttemp", "night temperature T1", "Nachttemperat MAKE_TRANSLATION(ecotemp, "ecotemp", "eco temperature", "eco Temperatur", "Temperatuur eco", "Eko-temperatur", "temperatura w trybie eko", "øko temperatur", "température éco", "eko sıcaklık", "Temperatura eco", "eko teplota", "eko teplota") MAKE_TRANSLATION(manualtemp, "manualtemp", "manual temperature", "manuelle Temperatur", "Temperatuur handmatig", "Temperatur Manuell", "temperatura ustawiona ręcznie", "manuell temperatur", "température manuelle", "manuel sıcaklık", "temperatura manuale", "manuálna teplota", "manuální teplota") MAKE_TRANSLATION(tempautotemp, "tempautotemp", "temporary set temperature automode", "temporäre Solltemperatur Automatikmodus", "Streeftemperatuur automodus tijdelijk", "Temporär Aktivering av Auto-läge", "zadana temperatura w pomieszczeniu w trybie \"auto\" (tymczasowa)", "temporær valgt temp i automodus", "température temporaire mode automatique", "geçici ayarlı sıcaklık otomatik mod", "impostare temporaneamente temperatura automatica", "automatický režim dočasnej nastavenej teploty", "dočasné nastavení teploty v automatickém režimu") -MAKE_TRANSLATION(remoteseltemp, "remoteseltemp", "temporary set temperature from remote", "temporäre Solltemperatur Remote", "Temperatuur van afstandsbedieding", "Temperatur från fjärruppkoppling", "zadana zdalnie temperatura a pomieszczeniu (tymczasowa)", "temporær valgt temp fra fjernbetjening", "température temporaire depuis télécommande", "geçici ayarlı sıcaklık uzaktan", "Temperatura temporanea da remoto", "dočasne nastavená teplota z diaľkového ovládania", "dočasné nastavení teploty z dálkového ovladače") +MAKE_TRANSLATION(cooltemp, "cooltemp", "cooling temperature", "Kühltemperatur", "Temperatuur koelbedrijf", "Temperatur Kyla", "temperatura ciepła", "chłodzenie temperatur", "température kjøling", "soğuyor sıcaklık", "temperatura calore", "chladenie teplota", "chlazení teplota") +// MAKE_TRANSLATION(remoteseltemp, "remoteseltemp", "temporary set temperature from remote", "temporäre Solltemperatur Remote", "Temperatuur van afstandsbedieding", "Temperatur från fjärruppkoppling", "zadana zdalnie temperatura a pomieszczeniu (tymczasowa)", "temporær valgt temp fra fjernbetjening", "température temporaire depuis télécommande", "geçici ayarlı sıcaklık uzaktan", "Temperatura temporanea da remoto", "dočasne nastavená teplota z diaľkového ovládania", "dočasné nastavení teploty z dálkového ovladače") MAKE_TRANSLATION(comforttemp, "comforttemp", "comfort temperature", "Komforttemperatur", "Comforttemperatuur", "Komforttemperatur", "temperatura w trybie komfort", "komforttemperatur", "température confort", "konfor sıcaklığı", "temperatura comfort", "komfortná teplota", "komfortní teplota") MAKE_TRANSLATION(summertemp, "summertemp", "summer temperature", "Sommertemperatur", "Zomertemperatuur", "Sommartemperatur", "temperatura przełączania lato/zima", "Sommertemperatur", "température été", "yaz sıcaklığı", "temperatura estiva", "letná teplota", "letní teplota") MAKE_TRANSLATION(designtemp, "designtemp", "design temperature", "Auslegungstemperatur", "Ontwerptemperatuur", "Design-temperatur", "temperatura projektowa", "designtemperatur", "température conception", "özel sıcaklık", "temperatura predefinita", "návrhová teplota", "dimenzovaná teplota") diff --git a/src/core/modbus_entity_parameters.hpp b/src/core/modbus_entity_parameters.hpp index 26d16a6e7..4d074aa27 100644 --- a/src/core/modbus_entity_parameters.hpp +++ b/src/core/modbus_entity_parameters.hpp @@ -318,7 +318,7 @@ const std::initializer_list Modbus::modbus_register_ma REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(controlmode), 25, 1), // controlmode REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(program), 26, 1), // program REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(tempautotemp), 27, 1), // tempautotemp - REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(remoteseltemp), 28, 1), // remoteseltemp + REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(cooltemp), 28, 1), // cooltemp REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(fastheatup), 29, 1), // fastheatup REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(switchonoptimization), 30, 1), // switchonoptimization REGISTER_MAPPING(dt::THERMOSTAT, TAG_TYPE_HC, FL_(reducemode), 31, 1), // reducemode diff --git a/src/core/shuntingYard.hpp b/src/core/shuntingYard.hpp index 3448fa1fc..8de767b0d 100644 --- a/src/core/shuntingYard.hpp +++ b/src/core/shuntingYard.hpp @@ -93,6 +93,9 @@ std::deque exprToTokens(const std::string & expr) { } else if (strncmp(p, "pow", 3) == 0) { p += 2; tokens.emplace_back(Token::Type::Unary, "p", 5); + } else if (strncmp(p, "hex", 3) == 0) { + p += 2; + tokens.emplace_back(Token::Type::Unary, "h", 5); } else if (*p >= 'a' && *p <= 'z') { const auto * b = p; while ((*p >= 'a' && *p <= 'z') || (*p == '_')) { @@ -380,7 +383,7 @@ std::string commands(std::string & expr, bool quotes = true) { data.insert(data.begin(), '"'); data.insert(data.end(), '"'); } - expr.replace(f, l, data); + expr.replace(f, l, emsesp::Helpers::toLower(data)); e = f + data.length(); } else { return expr = ""; @@ -490,6 +493,9 @@ std::string calculate(const std::string & expr) { case 'p': stack.push_back(to_string(std::pow(std::stod(rhs), 2))); break; + case 'h': + stack.push_back(to_string(std::stoi(rhs, 0, 16))); + break; } } break; case Token::Type::Compare: { @@ -694,14 +700,29 @@ std::string compute(const std::string & expr) { if (c1 == std::string::npos) { return ""; // error: missing colon } - std::string cond = calculate(expr_new.substr(0, q)); + auto s = q; // start search brackets + int br = 0; // count brackets + while (s > 0 && (br || expr_new[s - 1] != '(')) { + s--; + br += (expr_new[s] == '(' ? -1 : expr_new[s] == ')' ? 1 : 0); + } + std::string cond = calculate(expr_new.substr(s, q - s)); if (cond.length() == 0) { return ""; } else if (cond[0] == '1') { - expr_new.erase(c1); // remove second expression after colon - expr_new.erase(0, q + 1); // remove condition before questionmark + auto e = expr_new.length(); // end + if (s) { // there was a opening bracket, find the closing one + e = c1; + br = 0; + while (e < expr_new.length() && (br || expr_new[e + 1] != ')')) { + e++; + br += (expr_new[e] == ')' ? -1 : expr_new[e] == '(' ? 1 : 0); + } + } + expr_new.erase(c1, e + 1 - c1); // remove second expression after colon + expr_new.erase(s, q + 1 - s); // remove condition before questionmark } else if (cond[0] == '0') { - expr_new.erase(0, c1 + 1); // remove condition and first expression + expr_new.erase(s, c1 + 1 - s); // remove condition and first expression } else { return ""; // error } diff --git a/src/core/telegram.h b/src/core/telegram.h index c8a0d472c..622b7a832 100644 --- a/src/core/telegram.h +++ b/src/core/telegram.h @@ -37,7 +37,7 @@ #define MAX_TX_TELEGRAMS 200 // size of Tx queue #else #define MAX_RX_TELEGRAMS 10 // size of Rx queue -#define MAX_TX_TELEGRAMS 100 // size of Tx queue +#define MAX_TX_TELEGRAMS 160 // size of Tx queue #endif // default values for null values diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 350b750ea..6137a1360 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1166,7 +1166,7 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { has_enumupdate(telegram, hc->reducemode, 5, 1); // 1-outdoor temp threshold, 2-room temp threshold, 3-reduced mode has_update(telegram, hc->reducetemp, 9); has_update(telegram, hc->noreducetemp, 12); - has_update(telegram, hc->remoteseltemp, 17); // see https://github.com/emsesp/EMS-ESP32/issues/590 + has_update(telegram, hc->cooltemp, 17); // see https://github.com/emsesp/EMS-ESP32/issues/590 and 2456 has_enumupdate(telegram, hc->switchProgMode, 19, 1); // 1-level, 2-absolute has_update(telegram, hc->redThreshold, 20); has_update(telegram, hc->boost, 23); @@ -3827,7 +3827,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co factor = 1; // to write 0xFF } break; - case HeatingCircuit::Mode::REMOTESELTEMP: + case HeatingCircuit::Mode::COOLTEMP: offset = 0x11; break; case HeatingCircuit::Mode::COMFORT: @@ -4686,12 +4686,12 @@ void Thermostat::register_device_values_hc(std::shared_ptrremoteseltemp, + &hc->cooltemp, DeviceValueType::INT8, DeviceValueNumOp::DV_NUMOP_DIV2, - FL_(remoteseltemp), + FL_(cooltemp), DeviceValueUOM::DEGREES, - MAKE_CF_CB(set_remoteseltemp), + MAKE_CF_CB(set_cooltemp), -1, 30); register_device_value(tag, &hc->fastHeatup, DeviceValueType::UINT8, FL_(fastheatup), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_fastheatup)); diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index cba27470a..843872f52 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -39,7 +39,7 @@ class Thermostat : public EMSdevice { int16_t remotetemp; // for readback uint8_t remotehum; // for readback uint8_t tempautotemp; - int8_t remoteseltemp; + int8_t cooltemp; uint8_t mode; uint8_t mode_new; uint8_t modetype; @@ -159,7 +159,7 @@ class Thermostat : public EMSdevice { ON, DAYLOW, DAYMID, - REMOTESELTEMP, + COOLTEMP, COOLSTART, UNKNOWN @@ -571,8 +571,8 @@ class Thermostat : public EMSdevice { inline bool set_roominfluence(const char * value, const int8_t id) { return set_temperature_value(value, id, HeatingCircuit::Mode::ROOMINFLUENCE, true); } - inline bool set_remoteseltemp(const char * value, const int8_t id) { - return set_temperature_value(value, id, HeatingCircuit::Mode::REMOTESELTEMP); + inline bool set_cooltemp(const char * value, const int8_t id) { + return set_temperature_value(value, id, HeatingCircuit::Mode::COOLTEMP); } inline bool set_coolstart(const char * value, const int8_t id) { return set_temperature_value(value, id, HeatingCircuit::Mode::COOLSTART); diff --git a/test/test_api/test_api.cpp b/test/test_api/test_api.cpp index 8338af0c1..ff7b15ee0 100644 --- a/test/test_api/test_api.cpp +++ b/test/test_api/test_api.cpp @@ -23,6 +23,7 @@ #include #include "ESPAsyncWebServer.h" #include "web/WebAPIService.h" +#include "test_shuntingYard.hpp" using namespace emsesp; @@ -452,9 +453,10 @@ int main() { // UNITY_BEGIN(); - run_tests(); // execute the generated tests - run_manual_tests(); // execute some other manual tests from this file - run_console_tests(); // execute some console tests + run_tests(); // execute the generated tests + run_manual_tests(); // execute some other manual tests from this file + run_console_tests(); // execute some console tests + run_shuntingYard_tests(); // execute the shuntingYard tests return UNITY_END(); } diff --git a/test/test_api/test_shuntingYard.hpp b/test/test_api/test_shuntingYard.hpp new file mode 100644 index 000000000..d3e2b2c0e --- /dev/null +++ b/test/test_api/test_shuntingYard.hpp @@ -0,0 +1,150 @@ + +#include +#include +#include +#include "core/shuntingYard.hpp" + +void shuntingYard_test1() { + std::string expected_result = "locale is en"; + std::string test_value = "\"locale is \"system/settings/locale"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test2() { + // test with negative value + std::string expected_result = "rssi is -23"; + std::string test_value = "\"rssi is \"0+system/network/rssi"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test3() { + std::string expected_result = "rssi is -23 dbm"; + std::string test_value = "\"rssi is \"(system/network/rssi)\" dBm\""; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test4() { + std::string expected_result = "14"; + std::string test_value = "(custom/seltemp/value)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test5() { + std::string expected_result = "seltemp=14"; + std::string test_value = "\"seltemp=\"(custom/seltemp/value)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test6() { + std::string expected_result = "14"; + std::string test_value = "(custom/seltemp)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test7() { + std::string expected_result = "40"; + std::string test_value = "boiler/flowtempoffset"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test8() { + std::string expected_result = "40"; + std::string test_value = "(boiler/flowtempoffset/value)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test9() { + std::string expected_result = "53.8"; + std::string test_value = "(boiler/storagetemp1/value)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test10() { + // (14 - 40) * 2.8 + 5 = -67.8 + std::string expected_result = "-67.8"; + std::string test_value = "(custom/seltemp - boiler/flowtempoffset) * 2.8 + 5"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test11() { + std::string expected_result = "4"; + std::string test_value = "1 > 2 ? 3 : 4"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test12() { + std::string expected_result = "3"; + std::string test_value = "1 < 2 ? 3 : 4"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test13() { + std::string expected_result = "5"; + std::string test_value = "1<2?(3<4?5:6):7"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test14() { + std::string expected_result = "7"; + std::string test_value = "1>2?(3<4?5:6):7"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test15() { + std::string expected_result = "6"; + std::string test_value = "1<2?(3>4?5:6):7"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test16() { + std::string expected_result = "3"; + std::string test_value = "1<2?3:(4<5?6:7)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test17() { + std::string expected_result = "6"; + std::string test_value = "1>2?3:(4<5?6:7)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test18() { + std::string expected_result = "7"; + std::string test_value = "1>2?3:(4>5?6:7)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test19() { + std::string expected_result = "44"; + std::string test_value = "(1>2?3:4)+(10>20?30:40)"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void shuntingYard_test20() { + std::string expected_result = "8"; + std::string test_value = "1<2 ? 3>4 ? 5 : 6<7 ? 8 : 9 : 10"; + TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str()); +} + +void run_shuntingYard_tests() { + RUN_TEST(shuntingYard_test1); + RUN_TEST(shuntingYard_test2); + RUN_TEST(shuntingYard_test3); + RUN_TEST(shuntingYard_test4); + RUN_TEST(shuntingYard_test5); + RUN_TEST(shuntingYard_test6); + RUN_TEST(shuntingYard_test7); + RUN_TEST(shuntingYard_test8); + RUN_TEST(shuntingYard_test9); + RUN_TEST(shuntingYard_test10); + RUN_TEST(shuntingYard_test11); + RUN_TEST(shuntingYard_test12); + RUN_TEST(shuntingYard_test13); + RUN_TEST(shuntingYard_test14); + RUN_TEST(shuntingYard_test15); + RUN_TEST(shuntingYard_test16); + RUN_TEST(shuntingYard_test17); + RUN_TEST(shuntingYard_test18); + RUN_TEST(shuntingYard_test19); + RUN_TEST(shuntingYard_test20); +}