From fcc521d5edaed080c59b4885eda6d2fc5775cbd0 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 28 Sep 2021 14:06:26 +0200 Subject: [PATCH] enum thermostat programs, add junkers remote, program --- CHANGELOG_LATEST.md | 2 + src/devices/thermostat.cpp | 104 +++++++++++++++++++++++-------------- src/locale_EN.h | 8 ++- 3 files changed, 72 insertions(+), 42 deletions(-) diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 6a6921553..c011d049a 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -9,6 +9,7 @@ - Add RC300 second summermode telegram [#108](https://github.com/emsesp/EMS-ESP32/issues/108) - Add support for the RC25 thermostat [#106](https://github.com/emsesp/EMS-ESP32/issues/106) - Add new command 'entities' for a device, e.g. http://ems-esp/api/boiler/entities to show the shortname, description and HA Entity name (if HA enabled) [#116](https://github.com/emsesp/EMS-ESP32/issues/116) +- Junkers program and remote (fb10/fb110) temperature ## Fixed @@ -24,6 +25,7 @@ - rename `fastheatupfactor` to `fastheatup` and add percent [#122] - "unit" renamed to "uom" in API call to recall a Device Value - initial backend React changes to replace the class components (HOCs) with React Hooks +- program-names instead of numbers ## **BREAKING CHANGES** diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 298412471..479a2f517 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -682,8 +682,8 @@ void Thermostat::process_RC20Set_2(std::shared_ptr telegram) { has_update(telegram->read_value(hc->nighttemp, 1)); // is * 2, has_update(telegram->read_value(hc->daytemp, 2)); // is * 2, has_update(telegram->read_value(hc->mode, 3)); - hc->hamode = hc->mode; // set special HA mode - has_update(telegram->read_value(hc->program, 11)); // 1 .. 9 predefined programs + hc->hamode = hc->mode; // set special HA mode + has_update(telegram->read_enumvalue(hc->program, 11, 1)); // 1 .. 9 predefined programs // RC25 extension: has_update(telegram->read_value(ibaMinExtTemperature_, 14)); has_update(telegram->read_value(hc->minflowtemp, 15)); @@ -727,11 +727,13 @@ void Thermostat::process_JunkersSet(std::shared_ptr telegram) { return; } - has_update(telegram->read_value(hc->daytemp, 17)); // is * 2 - has_update(telegram->read_value(hc->nighttemp, 16)); // is * 2 - has_update(telegram->read_value(hc->nofrosttemp, 15)); // is * 2 - has_update(telegram->read_enumvalue(hc->mode, 14, 1)); // 0 = nofrost, 1 = eco, 2 = heat, 3 = auto - hc->hamode = hc->mode ? hc->mode - 1 : 0; // set special HA mode: off, on, auto + has_update(telegram->read_value(hc->daytemp, 17)); // is * 2 + has_update(telegram->read_value(hc->nighttemp, 16)); // is * 2 + has_update(telegram->read_value(hc->nofrosttemp, 15)); // is * 2 + has_update(telegram->read_value(hc->control, 1)); // remote: 0-off, 1-FB10, 2-FB100 + has_update(telegram->read_enumvalue(hc->program, 13, 1)); // 1-6: 1 = A, 2 = B,... + has_update(telegram->read_enumvalue(hc->mode, 14, 1)); // 0 = nofrost, 1 = eco, 2 = heat, 3 = auto + hc->hamode = hc->mode ? hc->mode - 1 : 0; // set special HA mode: off, on, auto } // type 0x0179, ff @@ -741,11 +743,12 @@ void Thermostat::process_JunkersSet2(std::shared_ptr telegram) { return; } - has_update(telegram->read_value(hc->daytemp, 7)); // is * 2 - has_update(telegram->read_value(hc->nighttemp, 6)); // is * 2 - has_update(telegram->read_value(hc->nofrosttemp, 5)); // is * 2 - has_update(telegram->read_enumvalue(hc->mode, 4, 1)); // 0 = nofrost, 1 = eco, 2 = heat, 3 = auto - hc->hamode = hc->mode ? hc->mode - 1 : 0; // set special HA mode: off, on, auto + has_update(telegram->read_value(hc->daytemp, 7)); // is * 2 + has_update(telegram->read_value(hc->nighttemp, 6)); // is * 2 + has_update(telegram->read_value(hc->nofrosttemp, 5)); // is * 2 + has_update(telegram->read_enumvalue(hc->program, 10, 1)); // 1-6: 1 = A, 2 = B,... + has_update(telegram->read_enumvalue(hc->mode, 4, 1)); // 0 = nofrost, 1 = eco, 2 = heat, 3 = auto + hc->hamode = hc->mode ? hc->mode - 1 : 0; // set special HA mode: off, on, auto } // type 0xA3 - for external temp settings from the the RC* thermostats (e.g. RC35) @@ -818,10 +821,14 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr telegram return; } - has_update(telegram->read_value(hc->curr_roomTemp, 4)); // value is * 10 has_update(telegram->read_value(hc->setpoint_roomTemp, 2)); // value is * 10 + has_update(telegram->read_enumvalue(hc->modetype, 0, 1)); // 1 = nofrost, 2 = eco, 3 = heat - has_update(telegram->read_enumvalue(hc->modetype, 0, 1)); // 1 = nofrost, 2 = eco, 3 = heat + if ((hc->control == 1) || (hc->control == 2)) { + has_update(telegram->read_value(hc->curr_roomTemp, 6)); // roomTemp from remote + } else { + has_update(telegram->read_value(hc->curr_roomTemp, 4)); // value is * 10 + } } // type 0x02A5 - data from Worchester CRF200 @@ -883,8 +890,8 @@ void Thermostat::process_RC300Set(std::shared_ptr telegram) { has_update(telegram->read_value(hc->daytemp, 2)); // is * 2 has_update(telegram->read_value(hc->nighttemp, 4)); // is * 2 has_update(telegram->read_value(hc->tempautotemp, 8)); - has_update(telegram->read_value(hc->manualtemp, 10)); // is * 2 - has_update(telegram->read_value(hc->program, 11)); // timer program 1 or 2 + has_update(telegram->read_value(hc->manualtemp, 10)); // is * 2 + has_update(telegram->read_enumvalue(hc->program, 11, 1)); // timer program 1 or 2 } // types 0x2AF ff @@ -1305,22 +1312,26 @@ bool Thermostat::set_language(const char * value, const int8_t id) { // Set the control-mode for hc 0-off, 1-RC20, 2-RC3x bool Thermostat::set_control(const char * value, const int8_t id) { - uint8_t ctrl = 0; - if (!Helpers::value2enum(value, ctrl, FL_(enum_control))) { - LOG_WARNING(F("Set control: Invalid value")); - return false; - } - uint8_t hc_num = (id == -1) ? AUTO_HEATING_CIRCUIT : id; std::shared_ptr hc = heating_circuit(hc_num); if (hc == nullptr) { return false; } - LOG_INFO(F("Setting circuit-control for hc%d to %d"), hc_num, ctrl); - write_command(set_typeids[hc->hc_num() - 1], 26, ctrl); - - return true; + uint8_t ctrl = 0; + if (model() == EMS_DEVICE_FLAG_JUNKERS && !has_flags(EMS_DEVICE_FLAG_JUNKERS_OLD)) { + if (Helpers::value2enum(value, ctrl, FL_(enum_j_control))) { + LOG_INFO(F("Setting circuit-control for hc%d to %d"), hc_num, ctrl); + write_command(set_typeids[hc->hc_num() - 1], 1, ctrl); + return true; + } + } else if (Helpers::value2enum(value, ctrl, FL_(enum_control))) { + LOG_INFO(F("Setting circuit-control for hc%d to %d"), hc_num, ctrl); + write_command(set_typeids[hc->hc_num() - 1], 26, ctrl); + return true; + } + LOG_WARNING(F("Set control: Invalid value")); + return false; } // sets the thermostat ww working mode, where mode is a string, ems and ems+ @@ -1994,19 +2005,30 @@ bool Thermostat::set_program(const char * value, const int8_t id) { return false; } - int set = 0xFF; - if (!Helpers::value2number(value, set)) { - LOG_WARNING(F("Setting program: Invalid number")); - return false; + uint8_t set = 0xFF; + if (model() == EMS_DEVICE_FLAG_RC20_N) { + if (Helpers::value2enum(value, set, FL_(enum_progMode3))) { + write_command(set_typeids[hc->hc_num() - 1], 11, set + 1, set_typeids[hc->hc_num() - 1]); + } + } else if (model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_N) { + if (Helpers::value2enum(value, set, FL_(enum_progMode2))) { + write_command(timer_typeids[hc->hc_num() - 1], 84, set, timer_typeids[hc->hc_num() - 1]); + } + } else if (model() == EMS_DEVICE_FLAG_RC300 || model() == EMS_DEVICE_FLAG_RC100) { + if (Helpers::value2enum(value, set, FL_(enum_progMode))) { + write_command(set_typeids[hc->hc_num() - 1], 11, set + 1, set_typeids[hc->hc_num() - 1]); + } + } else if (model() == EMS_DEVICE_FLAG_JUNKERS) { + if (Helpers::value2enum(value, set, FL_(enum_progMode4))) { + if (has_flags(EMS_DEVICE_FLAG_JUNKERS_OLD)) { + write_command(set_typeids[hc->hc_num() - 1], 10, set + 1, set_typeids[hc->hc_num() - 1]); + } else { + write_command(set_typeids[hc->hc_num() - 1], 13, set + 1, set_typeids[hc->hc_num() - 1]); + } + } } - if (model() == EMS_DEVICE_FLAG_RC20_N && set > 0 && set < 10) { - write_command(set_typeids[hc->hc_num() - 1], 11, set, set_typeids[hc->hc_num() - 1]); - } else if ((model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_N) && set < 11) { - write_command(timer_typeids[hc->hc_num() - 1], 84, set, timer_typeids[hc->hc_num() - 1]); - } else if ((model() == EMS_DEVICE_FLAG_RC300 || model() == EMS_DEVICE_FLAG_RC100) && (set == 1 || set == 2)) { - write_command(set_typeids[hc->hc_num() - 1], 11, set, set_typeids[hc->hc_num() - 1]); - } else { + if (set == 0xFF) { LOG_WARNING(F("Setting program: Invalid number")); return false; } @@ -2623,7 +2645,7 @@ void Thermostat::register_device_values_hc(std::shared_ptrsummermode, DeviceValueType::BOOL, nullptr, FL_(summermode), DeviceValueUOM::NONE); register_device_value( tag, &hc->controlmode, DeviceValueType::ENUM, FL_(enum_controlmode), FL_(controlmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_controlmode)); - register_device_value(tag, &hc->program, DeviceValueType::UINT, nullptr, FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); + register_device_value(tag, &hc->program, DeviceValueType::ENUM, FL_(enum_progMode), FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); register_device_value(tag, &hc->tempautotemp, DeviceValueType::UINT, FL_(div2), FL_(tempautotemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_tempautotemp)); register_device_value(tag, &hc->fastHeatup, DeviceValueType::UINT, nullptr, FL_(fastheatup), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_fastheatup)); break; @@ -2640,7 +2662,7 @@ void Thermostat::register_device_values_hc(std::shared_ptrmodetype, DeviceValueType::ENUM, FL_(enum_modetype2), FL_(modetype), DeviceValueUOM::NONE); register_device_value(tag, &hc->daytemp, DeviceValueType::UINT, FL_(div2), FL_(daytemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_daytemp)); register_device_value(tag, &hc->nighttemp, DeviceValueType::UINT, FL_(div2), FL_(nighttemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_nighttemp)); - register_device_value(tag, &hc->program, DeviceValueType::UINT, nullptr, FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); + register_device_value(tag, &hc->program, DeviceValueType::ENUM, FL_(enum_progMode3), FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); // RC25 additions, guess, not validated by users, see:https://github.com/emsesp/EMS-ESP32/issues/106 register_device_value(tag, &hc->minflowtemp, DeviceValueType::UINT, nullptr, FL_(minflowtemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_minflowtemp)); register_device_value(tag, &hc->maxflowtemp, DeviceValueType::UINT, nullptr, FL_(maxflowtemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_maxflowtemp)); @@ -2674,7 +2696,7 @@ void Thermostat::register_device_values_hc(std::shared_ptrcontrolmode, DeviceValueType::ENUM, FL_(enum_controlmode2), FL_(controlmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_controlmode)); register_device_value(tag, &hc->control, DeviceValueType::ENUM, FL_(enum_control), FL_(control), DeviceValueUOM::NONE, MAKE_CF_CB(set_control)); - register_device_value(tag, &hc->program, DeviceValueType::UINT, nullptr, FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); + register_device_value(tag, &hc->program, DeviceValueType::ENUM, FL_(enum_progMode2), FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); register_device_value(tag, &hc->pause, DeviceValueType::UINT, nullptr, FL_(pause), DeviceValueUOM::HOURS, MAKE_CF_CB(set_pause)); register_device_value(tag, &hc->party, DeviceValueType::UINT, nullptr, FL_(party), DeviceValueUOM::HOURS, MAKE_CF_CB(set_party)); register_device_value(tag, &hc->tempautotemp, DeviceValueType::UINT, FL_(div2), FL_(tempautotemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_tempautotemp)); @@ -2689,6 +2711,8 @@ void Thermostat::register_device_values_hc(std::shared_ptrdaytemp, DeviceValueType::UINT, FL_(div2), FL_(heattemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_heattemp)); register_device_value(tag, &hc->nighttemp, DeviceValueType::UINT, FL_(div2), FL_(ecotemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_ecotemp)); register_device_value(tag, &hc->nofrosttemp, DeviceValueType::INT, FL_(div2), FL_(nofrosttemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_nofrosttemp)); + register_device_value(tag, &hc->control, DeviceValueType::ENUM, FL_(enum_j_control), FL_(control), DeviceValueUOM::NONE, MAKE_CF_CB(set_control)); + register_device_value(tag, &hc->program, DeviceValueType::ENUM, FL_(enum_progMode4), FL_(program), DeviceValueUOM::NONE, MAKE_CF_CB(set_program)); break; } } diff --git a/src/locale_EN.h b/src/locale_EN.h index 3f7f32872..9cde37bd3 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -351,10 +351,14 @@ MAKE_PSTR_LIST(enum_controlmode, F_(off), F_(optimized), F_(simple), F_(mpc), F_ MAKE_PSTR_LIST(enum_controlmode2, F_(outdoor), F_(room)) MAKE_PSTR_LIST(enum_controlmode3, F_(off), F_(room), F_(outdoor), F("room+outdoor")) MAKE_PSTR_LIST(enum_control, F_(off), F_(rc20), F_(rc3x)) +MAKE_PSTR_LIST(enum_j_control, F_(off), F("fb10"), F("fb110")) -MAKE_PSTR_LIST(enum_wwProgMode, F("std prog"), F_(own_prog)) +MAKE_PSTR_LIST(enum_wwProgMode, F("std_prog"), F_(own_prog)) MAKE_PSTR_LIST(enum_dayOfWeek, F("mo"), F("tu"), F("we"), F("th"), F("fr"), F("sa"), F("so"), F("all")) -// MAKE_PSTR_LIST(enum_wwChargeDuration, F_(off), F("15min"), F("30min"), F("45min"), F("60min"), F("75min"), F("90min"), F("105min"), F("120min")) +MAKE_PSTR_LIST(enum_progMode, F("prog_1"), F("prog_2")) +MAKE_PSTR_LIST(enum_progMode2, F("own_1"), F("family"), F("morning"), F("evening"), F("am"), F("pm"), F("midday"), F("singles"), F("seniors"), F("own_2")) +MAKE_PSTR_LIST(enum_progMode3, F("family"), F("morning"), F("evening"), F("am"), F("pm"), F("midday"), F("singles"), F("seniors")) +MAKE_PSTR_LIST(enum_progMode4, F("prog_a"), F("prog_b"), F("prog_c"), F("prog_d"), F("prog_e"), F("prog_f")) // solar list MAKE_PSTR_LIST(enum_solarmode, F_(constant), F("pwm"), F("analog"))