keep thermostat generic, and remove HA's heat mode

This commit is contained in:
proddy
2019-11-05 18:21:13 +01:00
parent b7835b2d39
commit 26b8185f56
5 changed files with 49 additions and 39 deletions

View File

@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Debug log times show real internet time (if NTP enabled)
- `system` shows local time instead of UTC
- fixed version numbers of libraries in `platformio.ini`
- Normalized Heating modes to `off`, `manual`, `auto`, `night` and `day` to keep generic and not Home Assistant specific (like `heat`)
### Removed

View File

@@ -11,7 +11,8 @@
current_temperature_topic: "home/ems-esp/thermostat_data"
temperature_state_topic: "home/ems-esp/thermostat_data"
mode_state_template: "{{ value_json.hc1.mode }}"
mode_state_template: "{% if value_json.hc1.mode == 'manual' %} heat {% else %} {{value_json.hc1.mode}} {% endif %}"
current_temperature_template: "{{ value_json.hc1.currtemp }}"
temperature_state_template: "{{ value_json.hc1.seltemp }}"

View File

@@ -153,44 +153,44 @@ void myDebugLog(const char * s) {
}
}
// figures out the thermostat mode
// returns 0xFF=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day
// figures out the thermostat mode depending on the thermostat type
// returns {EMS_THERMOSTAT_MODE_UNKNOWN, EMS_THERMOSTAT_MODE_OFF, EMS_THERMOSTAT_MODE_MANUAL, EMS_THERMOSTAT_MODE_AUTO, EMS_THERMOSTAT_MODE_NIGHT, EMS_THERMOSTAT_MODE_DAY}
// hc_num is 1 to 4
uint8_t _getThermostatMode(uint8_t hc_num) {
int thermoMode = EMS_VALUE_INT_NOTSET;
_EMS_THERMOSTAT_MODE _getThermostatMode(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].mode;
if (model == EMS_MODEL_RC20) {
if (mode == 0) {
thermoMode = 0; // low
thermoMode = EMS_THERMOSTAT_MODE_OFF;
} else if (mode == 1) {
thermoMode = 1; // manual
thermoMode = EMS_THERMOSTAT_MODE_MANUAL;
} else if (mode == 2) {
thermoMode = 2; // auto
thermoMode = EMS_THERMOSTAT_MODE_AUTO;
}
} else if (model == EMS_MODEL_RC300) {
if (mode == 0) {
thermoMode = 1; // manual
thermoMode = EMS_THERMOSTAT_MODE_MANUAL;
} else if (mode == 1) {
thermoMode = 2; // auto
thermoMode = EMS_THERMOSTAT_MODE_AUTO;
}
} else if (model == EMS_MODEL_FW100 || model == EMS_MODEL_FW120) {
if (mode == 3) {
thermoMode = 4;
thermoMode = EMS_THERMOSTAT_MODE_DAY;
} else if (mode == 2) {
thermoMode = 3;
thermoMode = EMS_THERMOSTAT_MODE_NIGHT;
} else if (mode == 1) {
thermoMode = 0;
thermoMode = EMS_THERMOSTAT_MODE_OFF;
}
} else { // default for all other thermostats
if (mode == 0) {
thermoMode = 3; // night
thermoMode = EMS_THERMOSTAT_MODE_NIGHT;
} else if (mode == 1) {
thermoMode = 4; // day
thermoMode = EMS_THERMOSTAT_MODE_DAY;
} else if (mode == 2) {
thermoMode = 2; // auto
thermoMode = EMS_THERMOSTAT_MODE_AUTO;
}
}
@@ -428,16 +428,16 @@ void showInfo() {
}
// Render Termostat Mode, if we have a mode
uint8_t thermoMode = _getThermostatMode(hc_num); // 0xFF=unknown, 0=off, 1=manual, 2=auto, 3=night, 4=day
if (thermoMode == 0) {
_EMS_THERMOSTAT_MODE thermoMode = _getThermostatMode(hc_num);
if (thermoMode == EMS_THERMOSTAT_MODE_OFF) {
myDebug_P(PSTR(" Mode is set to off"));
} else if (thermoMode == 1) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_MANUAL) {
myDebug_P(PSTR(" Mode is set to manual"));
} else if (thermoMode == 2) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_AUTO) {
myDebug_P(PSTR(" Mode is set to auto"));
} else if (thermoMode == 3) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_NIGHT) {
myDebug_P(PSTR(" Mode is set to night"));
} else if (thermoMode == 4) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_DAY) {
myDebug_P(PSTR(" Mode is set to day"));
} else {
myDebug_P(PSTR(" Mode is unknown"));
@@ -722,19 +722,19 @@ void publishValues(bool force) {
dataThermostat[THERMOSTAT_CIRCUITCALCTEMP] = thermostat->circuitcalctemp;
}
uint8_t thermoMode = _getThermostatMode(hc_v); // 0xFF=unknown, 0=low, 1=manual, 2=auto, 3=night, 4=day
_EMS_THERMOSTAT_MODE thermoMode = _getThermostatMode(hc_v);
// Termostat Mode
if (thermoMode == 0) {
if (thermoMode == EMS_THERMOSTAT_MODE_OFF) {
dataThermostat[THERMOSTAT_MODE] = "off";
} else if (thermoMode == 1) {
dataThermostat[THERMOSTAT_MODE] = "heat";
} else if (thermoMode == 2) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_MANUAL) {
dataThermostat[THERMOSTAT_MODE] = "manual";
} else if (thermoMode == EMS_THERMOSTAT_MODE_AUTO) {
dataThermostat[THERMOSTAT_MODE] = "auto";
} else if (thermoMode == 3) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_NIGHT) {
dataThermostat[THERMOSTAT_MODE] = "off"; // for night
} else if (thermoMode == 4) {
dataThermostat[THERMOSTAT_MODE] = "heat"; // for day
} else if (thermoMode == EMS_THERMOSTAT_MODE_DAY) {
dataThermostat[THERMOSTAT_MODE] = "manual"; // for day
} else {
dataThermostat[THERMOSTAT_MODE] = "auto"; // default to auto so HA doesn't complain
}
@@ -1811,16 +1811,16 @@ void WebCallback(JsonObject root) {
}
// Render Termostat Mode, if we have a mode
uint8_t thermoMode = _getThermostatMode(hc_num); // 0xFF=unknown, 0=off, 1=manual, 2=auto, 3=night, 4=day
if (thermoMode == 0) {
_EMS_THERMOSTAT_MODE thermoMode = _getThermostatMode(hc_num);
if (thermoMode == EMS_THERMOSTAT_MODE_OFF) {
thermostat["tmode"] = "off";
} else if (thermoMode == 1) {
thermostat["tmode"] = "heat";
} else if (thermoMode == 2) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_MANUAL) {
thermostat["tmode"] = "manual";
} else if (thermoMode == EMS_THERMOSTAT_MODE_AUTO) {
thermostat["tmode"] = "auto";
} else if (thermoMode == 3) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_NIGHT) {
thermostat["tmode"] = "night";
} else if (thermoMode == 4) {
} else if (thermoMode == EMS_THERMOSTAT_MODE_DAY) {
thermostat["tmode"] = "day";
}
} else {

View File

@@ -2962,7 +2962,7 @@ void ems_setThermostatMode(uint8_t mode, uint8_t hc_num) {
// RC300/1000/3000 have different settings
if (model_id == EMS_MODEL_RC300) {
if (mode == 1) {
set_mode = 0; // manual/heat
set_mode = 0; // manual
} else {
set_mode = 0xFF; // auto
}

View File

@@ -48,6 +48,14 @@
#define EMS_THERMOSTAT_DEFAULTHC 1 // default heating circuit is 1
#define EMS_THERMOSTAT_WRITE_YES true
#define EMS_THERMOSTAT_WRITE_NO false
typedef enum {
EMS_THERMOSTAT_MODE_UNKNOWN,
EMS_THERMOSTAT_MODE_OFF,
EMS_THERMOSTAT_MODE_MANUAL,
EMS_THERMOSTAT_MODE_AUTO,
EMS_THERMOSTAT_MODE_NIGHT,
EMS_THERMOSTAT_MODE_DAY
} _EMS_THERMOSTAT_MODE;
// trigger settings to determine if hot tap water or the heating is active
#define EMS_BOILER_BURNPOWER_TAPWATER 100