support writing to FR100 - #335

This commit is contained in:
Paul
2020-03-03 22:23:53 +01:00
parent 3c66031870
commit 98a41db973
6 changed files with 220 additions and 141 deletions

View File

@@ -113,8 +113,8 @@ static const command_t project_cmds[] PROGMEM = {
{false, "queue", "show current Tx queue"},
{false, "send XX ...", "send raw telegram data to EMS bus (XX are hex values)"},
{false, "thermostat read <type ID>", "send read request to the thermostat for heating circuit hc 1-4"},
{false, "thermostat temp [hc] <degrees>", "set current thermostat temperature"},
{false, "thermostat mode [hc] <mode>", "set mode (0=off, 1=manual, 2=auto) for heating circuit hc 1-4"},
{false, "thermostat temp <hc> <degrees> [temp]", "set current thermostat temperature. temp=0-6 (see wiki)"},
{false, "thermostat mode <hc> <mode>", "set mode (0=off, 1=manual, 2=auto) for heating circuit hc 1-4"},
{false, "boiler read <type ID>", "send read request to boiler"},
{false, "boiler wwtemp <degrees>", "set boiler warm water temperature"},
{false, "boiler wwactive <on | off>", "set boiler warm water on/off"},
@@ -144,7 +144,7 @@ _EMS_THERMOSTAT_MODE _getThermostatMode(uint8_t hc_num) {
_EMS_THERMOSTAT_MODE thermoMode = EMS_THERMOSTAT_MODE_UNKNOWN;
uint8_t mode = EMS_Thermostat.hc[hc_num - 1].mode;
uint8_t model = ems_getThermostatModel();
uint8_t model = ems_getThermostatFlags();
if (model == EMS_DEVICE_FLAG_RC20) {
if (mode == 0) {
@@ -184,7 +184,7 @@ _EMS_THERMOSTAT_MODE _getThermostatMode(uint8_t hc_num) {
// hc_num is 1 to 4
_EMS_THERMOSTAT_MODE _getThermostatMode2(uint8_t hc_num) {
_EMS_THERMOSTAT_MODE thermoMode = EMS_THERMOSTAT_MODE_UNKNOWN;
uint8_t model = ems_getThermostatModel();
uint8_t model = ems_getThermostatFlags();
uint8_t mode = EMS_Thermostat.hc[hc_num - 1].mode_type;
@@ -424,7 +424,7 @@ void showInfo() {
myDebug_P(PSTR(" Thermostat: %s"), ems_getDeviceDescription(EMS_DEVICE_TYPE_THERMOSTAT, buffer_type, false));
// Render Thermostat Date & Time
uint8_t model = ems_getThermostatModel();
uint8_t model = ems_getThermostatFlags();
if ((model != EMS_DEVICE_FLAG_EASY)) {
myDebug_P(PSTR(" Thermostat time is %s"), EMS_Thermostat.datetime);
}
@@ -733,7 +733,7 @@ bool publishEMSValues_boiler() {
rootBoiler["wWRecharge"] = _bool_to_char(s, EMS_Boiler.wWRecharging);
}
if (EMS_Boiler.wWActivated != EMS_VALUE_BOOL_NOTSET) {
rootBoiler["wWTempOK"] = _bool_to_char(s, EMS_Boiler.wWTemperaturOK);
rootBoiler["wWTempOK"] = _bool_to_char(s, EMS_Boiler.wWTemperatureOK);
}
if (EMS_Boiler.wWCirc != EMS_VALUE_BOOL_NOTSET) {
rootBoiler["wWCirc"] = _bool_to_char(s, EMS_Boiler.wWCirc);
@@ -814,7 +814,7 @@ bool publishEMSValues_thermostat() {
// only send if we have an active Heating Circuit with an actual setpoint temp temperature values
if ((thermostat->active) && (thermostat->setpoint_roomTemp > EMS_VALUE_SHORT_NOTSET)) {
uint8_t model = ems_getThermostatModel(); // fetch model flags
uint8_t model = ems_getThermostatFlags(); // fetch model flags
has_data = true;
if (myESP.mqttUseNestedJson()) {
@@ -1603,19 +1603,21 @@ void TelnetCommandCallback(uint8_t wc, const char * commandLine) {
// thermostat commands
if ((strcmp(first_cmd, "thermostat") == 0) && (wc >= 3)) {
char * second_cmd = _readWord();
uint8_t hc = EMS_THERMOSTAT_DEFAULTHC;
char * second_cmd = _readWord();
if (strcmp(second_cmd, "temp") == 0) {
if (wc == 4) {
hc = _readIntNumber(); // next parameter is the heating circuit
uint8_t hc = _readIntNumber(); // next parameter is the heating circuit
float temp = _readFloatNumber(); // read in next param which is the temp
if (wc == 5) {
// we have a temp mode given
_THERMOSTAT_TEMP_MODE temp_mode = (_THERMOSTAT_TEMP_MODE)_readIntNumber(); // next parameter is the temp mode type
ems_setThermostatTemp(temp, hc, temp_mode);
} else {
ems_setThermostatTemp(temp, hc);
}
ems_setThermostatTemp(_readFloatNumber(), hc);
ok = true;
} else if (strcmp(second_cmd, "mode") == 0) {
if (wc == 4) {
hc = _readIntNumber(); // next parameter is the heating circuit
}
uint8_t hc = _readIntNumber(); // next parameter is the heating circuit
ems_setThermostatMode(_readIntNumber(), hc);
ok = true;
} else if (strcmp(second_cmd, "read") == 0) {
@@ -2005,7 +2007,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (EMS_Thermostat.hc[hc - 1].active) {
float f = doc["data"];
if (f) {
ems_setThermostatTemp(f, hc, 1); // night
ems_setThermostatTemp(f, hc, THERMOSTAT_TEMP_MODE_NIGHT); // night
return;
}
}
@@ -2017,7 +2019,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (EMS_Thermostat.hc[hc - 1].active) {
float f = doc["data"];
if (f) {
ems_setThermostatTemp(f, hc, 2); // day
ems_setThermostatTemp(f, hc, THERMOSTAT_TEMP_MODE_DAY); // day
}
return;
}
@@ -2029,7 +2031,43 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
if (EMS_Thermostat.hc[hc - 1].active) {
float f = doc["data"];
if (f) {
ems_setThermostatTemp(f, hc, 3); // holiday
ems_setThermostatTemp(f, hc, THERMOSTAT_TEMP_MODE_HOLIDAY); // holiday
}
return;
}
}
// set eco value
hc = _hasHCspecified(TOPIC_THERMOSTAT_CMD_ECOTEMP, command);
if (hc) {
if (EMS_Thermostat.hc[hc - 1].active) {
float f = doc["data"];
if (f) {
ems_setThermostatTemp(f, hc, THERMOSTAT_TEMP_MODE_ECO); // holiday
}
return;
}
}
// set heat value
hc = _hasHCspecified(TOPIC_THERMOSTAT_CMD_HEATTEMP, command);
if (hc) {
if (EMS_Thermostat.hc[hc - 1].active) {
float f = doc["data"];
if (f) {
ems_setThermostatTemp(f, hc, THERMOSTAT_TEMP_MODE_HEAT); // holiday
}
return;
}
}
// set nofrost value
hc = _hasHCspecified(TOPIC_THERMOSTAT_CMD_NOFROSTTEMP, command);
if (hc) {
if (EMS_Thermostat.hc[hc - 1].active) {
float f = doc["data"];
if (f) {
ems_setThermostatTemp(f, hc, THERMOSTAT_TEMP_MODE_NOFROST); // holiday
}
return;
}
@@ -2109,7 +2147,7 @@ void WebCallback(JsonObject root) {
thermostat["tm"] = ems_getDeviceDescription(EMS_DEVICE_TYPE_THERMOSTAT, buffer, true);
uint8_t hc_num = 1; // default to HC1
uint8_t model = ems_getThermostatModel();
uint8_t model = ems_getThermostatFlags();
while (hc_num < EMS_THERMOSTAT_MAXHC && !EMS_Thermostat.hc[hc_num - 1].active)
hc_num++; // first active hc
// Render Current & Setpoint Room Temperature