Skip to content

Commit

Permalink
enum thermostat programs, add junkers remote, program
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Sep 28, 2021
1 parent 9100587 commit fcc521d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 42 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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**

Expand Down
104 changes: 64 additions & 40 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ void Thermostat::process_RC20Set_2(std::shared_ptr<const Telegram> 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));
Expand Down Expand Up @@ -727,11 +727,13 @@ void Thermostat::process_JunkersSet(std::shared_ptr<const Telegram> 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
Expand All @@ -741,11 +743,12 @@ void Thermostat::process_JunkersSet2(std::shared_ptr<const Telegram> 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)
Expand Down Expand Up @@ -818,10 +821,14 @@ void Thermostat::process_JunkersMonitor(std::shared_ptr<const Telegram> 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
Expand Down Expand Up @@ -883,8 +890,8 @@ void Thermostat::process_RC300Set(std::shared_ptr<const Telegram> 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
Expand Down Expand Up @@ -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<Thermostat::HeatingCircuit> 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+
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -2623,7 +2645,7 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->summermode, 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;
Expand All @@ -2640,7 +2662,7 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->modetype, 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));
Expand Down Expand Up @@ -2674,7 +2696,7 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(
tag, &hc->controlmode, 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));
Expand All @@ -2689,6 +2711,8 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->daytemp, 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;
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/locale_EN.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit fcc521d

Please sign in to comment.