Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
RC300 changes - #256
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Feb 13, 2020
1 parent 98f44f4 commit fd24fe3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
30 changes: 19 additions & 11 deletions src/ems-esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ _EMS_THERMOSTAT_MODE _getThermostatMode(uint8_t hc_num) {
}

// figures out the thermostat day/night mode depending on the thermostat type
// returns {EMS_THERMOSTAT_MODE_NIGHT, EMS_THERMOSTAT_MODE_DAY}
// returns {EMS_THERMOSTAT_MODE_NIGHT, EMS_THERMOSTAT_MODE_DAY, etc...}
// hc_num is 1 to 4
_EMS_THERMOSTAT_MODE _getThermostatDayMode(uint8_t hc_num) {
_EMS_THERMOSTAT_MODE _getThermostatMode2(uint8_t hc_num) {
_EMS_THERMOSTAT_MODE thermoMode = EMS_THERMOSTAT_MODE_UNKNOWN;
uint8_t model = ems_getThermostatModel();

uint8_t mode = EMS_Thermostat.hc[hc_num - 1].day_mode;
uint8_t mode = EMS_Thermostat.hc[hc_num - 1].mode_type;

if (model == EMS_DEVICE_FLAG_JUNKERS) {
if (mode == 3) {
Expand All @@ -205,9 +205,9 @@ _EMS_THERMOSTAT_MODE _getThermostatDayMode(uint8_t hc_num) {
}
} else if (model == EMS_DEVICE_FLAG_RC300) {
if (mode == 0) {
thermoMode = EMS_THERMOSTAT_MODE_NIGHT;
thermoMode = EMS_THERMOSTAT_MODE_ECO;
} else if (mode == 1) {
thermoMode = EMS_THERMOSTAT_MODE_DAY;
thermoMode = EMS_THERMOSTAT_MODE_COMFORT;
}
}

Expand Down Expand Up @@ -447,6 +447,8 @@ void showInfo() {
_renderIntValue(" Night temperature", "C", EMS_Thermostat.hc[hc_num - 1].nighttemp, 2); // convert to a single byte * 2
_renderIntValue(" Vacation temperature", "C", EMS_Thermostat.hc[hc_num - 1].holidaytemp, 2); // convert to a single byte * 2
}

// show flow temp if we have it
if (EMS_Thermostat.hc[hc_num - 1].circuitcalctemp < EMS_VALUE_INT_NOTSET)
_renderIntValue(" Calculated flow temperature", "C", EMS_Thermostat.hc[hc_num - 1].circuitcalctemp);

Expand All @@ -465,12 +467,18 @@ void showInfo() {
myDebug_P(PSTR(" Mode is set to day"));
}

// Render Thermostat Day Mode
thermoMode = _getThermostatDayMode(hc_num);
if (thermoMode == EMS_THERMOSTAT_MODE_NIGHT) {
myDebug_P(PSTR(" Day Mode is set to night"));
} else if (thermoMode == EMS_THERMOSTAT_MODE_DAY) {
myDebug_P(PSTR(" Day Mode is set to day"));
// Render Thermostat Mode2, only if its in Auto mode
if (thermoMode == EMS_THERMOSTAT_MODE_AUTO) {
thermoMode = _getThermostatMode2(hc_num);
if (thermoMode == EMS_THERMOSTAT_MODE_NIGHT) {
myDebug_P(PSTR(" Mode type is set to night"));
} else if (thermoMode == EMS_THERMOSTAT_MODE_DAY) {
myDebug_P(PSTR(" Mode type is set to day"));
} else if (thermoMode == EMS_THERMOSTAT_MODE_COMFORT) {
myDebug_P(PSTR(" Mode type is set to comfort"));
} else if (thermoMode == EMS_THERMOSTAT_MODE_ECO) {
myDebug_P(PSTR(" Mode type is set to eco"));
}
}
}
}
Expand Down
35 changes: 20 additions & 15 deletions src/ems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ems_init() {
EMS_Thermostat.hc[i].hc = i + 1;
EMS_Thermostat.hc[i].active = false;
EMS_Thermostat.hc[i].mode = EMS_VALUE_INT_NOTSET;
EMS_Thermostat.hc[i].day_mode = EMS_VALUE_INT_NOTSET;
EMS_Thermostat.hc[i].mode_type = EMS_VALUE_INT_NOTSET;
EMS_Thermostat.hc[i].summer_mode = EMS_VALUE_INT_NOTSET;
EMS_Thermostat.hc[i].holiday_mode = EMS_VALUE_INT_NOTSET;
EMS_Thermostat.hc[i].daytemp = EMS_VALUE_INT_NOTSET;
Expand Down Expand Up @@ -1270,7 +1270,7 @@ void _process_RC35StatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
}

_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].curr_roomTemp, EMS_OFFSET_RC35StatusMessage_curr); // is * 10
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].day_mode, EMS_OFFSET_RC35StatusMessage_mode, 1);
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].mode_type, EMS_OFFSET_RC35StatusMessage_mode, 1);
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].summer_mode, EMS_OFFSET_RC35StatusMessage_mode, 0);
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].holiday_mode, EMS_OFFSET_RC35StatusMessage_mode1, 5);
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].circuitcalctemp, EMS_OFFSET_RC35Set_circuitcalctemp);
Expand Down Expand Up @@ -1351,12 +1351,13 @@ void _process_RCPLUSStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {
// quite often this is 0x8000 (n/a). still not sure why
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].curr_roomTemp, EMS_OFFSET_RCPLUSStatusMessage_curr); // value is * 10

_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].day_mode, EMS_OFFSET_RCPLUSStatusMessage_mode, 1);
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].mode_type, EMS_OFFSET_RCPLUSStatusMessage_mode, 1);
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].mode, EMS_OFFSET_RCPLUSStatusMessage_mode, 0); // bit 1, mode (auto=1 or manual=0)

// setpoint is in position 3 and also 6 (EMS_OFFSET_RCPLUSStatusMessage_currsetpoint). We're sticking to 3 for now.
// don't fetch temp if in nightmode
if (EMS_Thermostat.hc[hc].day_mode) {
// only fetch temp if in comfort mode (not eco/night mode)
// also ignore if its 0 - see https://github.com/proddy/EMS-ESP/issues/256#issuecomment-585171426
if ((EMS_Thermostat.hc[hc].mode_type) && (EMS_RxTelegram->data[EMS_OFFSET_RCPLUSStatusMessage_setpoint] != 0)) {
_setValue8(EMS_RxTelegram, &EMS_Thermostat.hc[hc].setpoint_roomTemp, EMS_OFFSET_RCPLUSStatusMessage_setpoint); // convert to single byte, value is * 2
}
}
Expand All @@ -1381,7 +1382,7 @@ void _process_JunkersStatusMessage(_EMS_RxTelegram * EMS_RxTelegram) {

_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].curr_roomTemp, EMS_OFFSET_JunkersStatusMessage_curr); // value is * 10
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].setpoint_roomTemp, EMS_OFFSET_JunkersStatusMessage_setpoint); // value is * 10
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].day_mode, EMS_OFFSET_JunkersStatusMessage_daymode); // 3 = day, 2 = night
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].mode_type, EMS_OFFSET_JunkersStatusMessage_daymode); // 3 = day, 2 = night
_setValue(EMS_RxTelegram, &EMS_Thermostat.hc[hc].mode, EMS_OFFSET_JunkersStatusMessage_mode); // 1 = manual, 2 = auto
}

Expand Down Expand Up @@ -2328,7 +2329,7 @@ void ems_sendRawTelegram(char * telegram) {
/**
* Set the temperature of the thermostat
* hc_num is 1 to 4
* temptype 0 = normal, 1=night temp, 2=day temp, 3=holiday temp
* temptype 0=normal, 1=night temp, 2=day temp, 3=holiday temp
*/
void ems_setThermostatTemp(float temperature, uint8_t hc_num, uint8_t temptype) {
if (!ems_getThermostatEnabled()) {
Expand Down Expand Up @@ -2357,10 +2358,14 @@ void ems_setThermostatTemp(float temperature, uint8_t hc_num, uint8_t temptype)
EMS_TxTelegram.dest = device_id;

char s[10] = {0};
myDebug_P(PSTR("Setting new thermostat temperature to %s for heating circuit %d type %d (0=auto,1=night,2=day,3=holiday)"),
_float_to_char(s, temperature),
hc_num,
temptype);
if ((model == EMS_DEVICE_FLAG_RC35) || (model == EMS_DEVICE_FLAG_RC30N)) {
myDebug_P(PSTR("Setting new thermostat temperature to %s for heating circuit %d type %d (0=auto,1=night,2=day,3=holiday)"),
_float_to_char(s, temperature),
hc_num,
temptype);
} else {
myDebug_P(PSTR("Setting new thermostat temperature to %s for heating circuit %d"), _float_to_char(s, temperature), hc_num);
}

if (model == EMS_DEVICE_FLAG_RC20) {
EMS_TxTelegram.type = EMS_TYPE_RC20Set;
Expand Down Expand Up @@ -2421,9 +2426,9 @@ void ems_setThermostatTemp(float temperature, uint8_t hc_num, uint8_t temptype)
// https://github.com/proddy/EMS-ESP/issues/310
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_seltemp;
} else {
if (EMS_Thermostat.hc[hc_num - 1].day_mode == 0) {
if (EMS_Thermostat.hc[hc_num - 1].mode_type == 0) {
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_night;
} else if (EMS_Thermostat.hc[hc_num - 1].day_mode == 1) {
} else if (EMS_Thermostat.hc[hc_num - 1].mode_type == 1) {
EMS_TxTelegram.offset = EMS_OFFSET_RC35Set_temp_day;
}
}
Expand Down Expand Up @@ -2460,9 +2465,9 @@ void ems_setThermostatTemp(float temperature, uint8_t hc_num, uint8_t temptype)
default:
case 0: // automatic selection, if no type is defined, we use the standard code
// not sure if this is correct for Junkers
if (EMS_Thermostat.hc[hc_num - 1].day_mode == 0) {
if (EMS_Thermostat.hc[hc_num - 1].mode_type == 0) {
EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_night_temp;
} else if (EMS_Thermostat.hc[hc_num - 1].day_mode == 1) {
} else if (EMS_Thermostat.hc[hc_num - 1].mode_type == 1) {
EMS_TxTelegram.offset = EMS_OFFSET_JunkersSetMessage_day_temp;
}
break;
Expand Down
6 changes: 4 additions & 2 deletions src/ems.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ typedef enum {
EMS_THERMOSTAT_MODE_MANUAL,
EMS_THERMOSTAT_MODE_AUTO,
EMS_THERMOSTAT_MODE_NIGHT,
EMS_THERMOSTAT_MODE_DAY
EMS_THERMOSTAT_MODE_DAY,
EMS_THERMOSTAT_MODE_ECO,
EMS_THERMOSTAT_MODE_COMFORT
} _EMS_THERMOSTAT_MODE;

// trigger settings to determine if hot tap water or the heating is active
Expand Down Expand Up @@ -397,7 +399,7 @@ typedef struct {
int16_t setpoint_roomTemp; // current set temp
int16_t curr_roomTemp; // current room temp
uint8_t mode; // 0=low, 1=manual, 2=auto (or night, day on RC35s)
uint8_t day_mode; // 0=night, 1=day
uint8_t mode_type; // 0=night/eco, 1=day/comfort
uint8_t summer_mode;
uint8_t holiday_mode;
uint8_t daytemp;
Expand Down

0 comments on commit fd24fe3

Please sign in to comment.