mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +00:00
Bugfix to allow negative temperature setpoints
This commit is contained in:
parent
27aab6ab45
commit
a8f892e2e1
@ -765,6 +765,7 @@
|
|||||||
//#define USE_THERMOSTAT // Add support for Thermostat
|
//#define USE_THERMOSTAT // Add support for Thermostat
|
||||||
#define THERMOSTAT_CONTROLLER_OUTPUTS 1 // Number of outputs to be controlled independently
|
#define THERMOSTAT_CONTROLLER_OUTPUTS 1 // Number of outputs to be controlled independently
|
||||||
#define THERMOSTAT_SENSOR_NAME "DS18B20" // Name of the local sensor to be used
|
#define THERMOSTAT_SENSOR_NAME "DS18B20" // Name of the local sensor to be used
|
||||||
|
#define THERMOSTAT_SENSOR_NUMBER 1 // Number of local sensors to be used
|
||||||
#define THERMOSTAT_RELAY_NUMBER 1 // Default output relay number for the first controller (+i for following ones)
|
#define THERMOSTAT_RELAY_NUMBER 1 // Default output relay number for the first controller (+i for following ones)
|
||||||
#define THERMOSTAT_SWITCH_NUMBER 1 // Default input switch number for the first controller (+i for following ones)
|
#define THERMOSTAT_SWITCH_NUMBER 1 // Default input switch number for the first controller (+i for following ones)
|
||||||
#define THERMOSTAT_TIME_ALLOW_RAMPUP 300 // Default time after last target update to allow ramp-up controller phase in minutes
|
#define THERMOSTAT_TIME_ALLOW_RAMPUP 300 // Default time after last target update to allow ramp-up controller phase in minutes
|
||||||
|
@ -234,9 +234,9 @@ struct THERMOSTAT {
|
|||||||
uint16_t time_max_action = THERMOSTAT_TIME_MAX_ACTION; // Maximum thermostat time per cycle in minutes
|
uint16_t time_max_action = THERMOSTAT_TIME_MAX_ACTION; // Maximum thermostat time per cycle in minutes
|
||||||
uint16_t time_min_action = THERMOSTAT_TIME_MIN_ACTION; // Minimum thermostat time per cycle in minutes
|
uint16_t time_min_action = THERMOSTAT_TIME_MIN_ACTION; // Minimum thermostat time per cycle in minutes
|
||||||
uint16_t time_min_turnoff_action = THERMOSTAT_TIME_MIN_TURNOFF_ACTION; // Minimum turnoff time in minutes, below it the thermostat will stay on
|
uint16_t time_min_turnoff_action = THERMOSTAT_TIME_MIN_TURNOFF_ACTION; // Minimum turnoff time in minutes, below it the thermostat will stay on
|
||||||
|
int16_t temp_frost_protect = THERMOSTAT_TEMP_FROST_PROTECT; // Minimum temperature for frost protection, in tenths of degrees celsius
|
||||||
uint8_t temp_reset_anti_windup = THERMOSTAT_TEMP_RESET_ANTI_WINDUP; // Range where reset antiwindup is disabled, in tenths of degrees celsius
|
uint8_t temp_reset_anti_windup = THERMOSTAT_TEMP_RESET_ANTI_WINDUP; // Range where reset antiwindup is disabled, in tenths of degrees celsius
|
||||||
int8_t temp_hysteresis = THERMOSTAT_TEMP_HYSTERESIS; // Range hysteresis for temperature PI controller, in tenths of degrees celsius
|
int8_t temp_hysteresis = THERMOSTAT_TEMP_HYSTERESIS; // Range hysteresis for temperature PI controller, in tenths of degrees celsius
|
||||||
uint8_t temp_frost_protect = THERMOSTAT_TEMP_FROST_PROTECT; // Minimum temperature for frost protection, in tenths of degrees celsius
|
|
||||||
ThermostatDiagBitfield diag; // Bittfield including diagnostic flags
|
ThermostatDiagBitfield diag; // Bittfield including diagnostic flags
|
||||||
#ifdef USE_PI_AUTOTUNING
|
#ifdef USE_PI_AUTOTUNING
|
||||||
uint8_t dutycycle_step_autotune = THERMOSTAT_DUTYCYCLE_AUTOTUNE; // Duty cycle for the step response of the autotune PI function in %
|
uint8_t dutycycle_step_autotune = THERMOSTAT_DUTYCYCLE_AUTOTUNE; // Duty cycle for the step response of the autotune PI function in %
|
||||||
@ -1237,7 +1237,7 @@ bool ThermostatTimerArm(uint8_t ctr_output, int16_t tempVal)
|
|||||||
// TempVal unit is tenths of degrees celsius
|
// TempVal unit is tenths of degrees celsius
|
||||||
if ((tempVal >= -1000)
|
if ((tempVal >= -1000)
|
||||||
&& (tempVal <= 1000)
|
&& (tempVal <= 1000)
|
||||||
&& (tempVal >= (int16_t)Thermostat[ctr_output].temp_frost_protect)) {
|
&& (tempVal >= Thermostat[ctr_output].temp_frost_protect)) {
|
||||||
Thermostat[ctr_output].temp_target_level = tempVal;
|
Thermostat[ctr_output].temp_target_level = tempVal;
|
||||||
Thermostat[ctr_output].status.thermostat_mode = THERMOSTAT_AUTOMATIC_OP;
|
Thermostat[ctr_output].status.thermostat_mode = THERMOSTAT_AUTOMATIC_OP;
|
||||||
result = true;
|
result = true;
|
||||||
@ -1332,7 +1332,14 @@ void ThermostatGetLocalSensor(uint8_t ctr_output) {
|
|||||||
JsonParser parser((char*)buf.c_str());
|
JsonParser parser((char*)buf.c_str());
|
||||||
JsonParserObject root = parser.getRootObject();
|
JsonParserObject root = parser.getRootObject();
|
||||||
if (root) {
|
if (root) {
|
||||||
JsonParserToken value_token = root[PSTR(THERMOSTAT_SENSOR_NAME)].getObject()[PSTR("Temperature")];
|
String sensor_name = THERMOSTAT_SENSOR_NAME;
|
||||||
|
const char* value_c;
|
||||||
|
if ( (THERMOSTAT_SENSOR_NUMBER > 1)
|
||||||
|
&&(THERMOSTAT_CONTROLLER_OUTPUTS > 1)
|
||||||
|
&&(ctr_output < THERMOSTAT_SENSOR_NUMBER)) {
|
||||||
|
sensor_name.concat("_" + (ctr_output + 1));
|
||||||
|
}
|
||||||
|
JsonParserToken value_token = root[sensor_name].getObject()[PSTR("Temperature")];
|
||||||
if (value_token.isNum()) {
|
if (value_token.isNum()) {
|
||||||
int16_t value = value_token.getFloat() * 10;
|
int16_t value = value_token.getFloat() * 10;
|
||||||
if (Thermostat[ctr_output].status.temp_format == TEMP_FAHRENHEIT) {
|
if (Thermostat[ctr_output].status.temp_format == TEMP_FAHRENHEIT) {
|
||||||
@ -1404,16 +1411,16 @@ void CmndTempFrostProtectSet(void)
|
|||||||
else {
|
else {
|
||||||
value = (int16_t)(CharToFloat(XdrvMailbox.data) * 10);
|
value = (int16_t)(CharToFloat(XdrvMailbox.data) * 10);
|
||||||
}
|
}
|
||||||
if ( (value >= 0)
|
if ( (value >= -1000)
|
||||||
&& (value <= 127)) {
|
&& (value <= 1000)) {
|
||||||
Thermostat[ctr_output].temp_frost_protect = (uint8_t)value;
|
Thermostat[ctr_output].temp_frost_protect = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Thermostat[ctr_output].status.temp_format == TEMP_FAHRENHEIT) {
|
if (Thermostat[ctr_output].status.temp_format == TEMP_FAHRENHEIT) {
|
||||||
value = ThermostatCelsiusToFahrenheit((int32_t)Thermostat[ctr_output].temp_frost_protect, TEMP_CONV_ABSOLUTE);
|
value = ThermostatCelsiusToFahrenheit((int32_t)Thermostat[ctr_output].temp_frost_protect, TEMP_CONV_ABSOLUTE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
value = (int16_t)Thermostat[ctr_output].temp_frost_protect;
|
value = Thermostat[ctr_output].temp_frost_protect;
|
||||||
}
|
}
|
||||||
ResponseCmndFloat((float)value / 10, 1);
|
ResponseCmndFloat((float)value / 10, 1);
|
||||||
}
|
}
|
||||||
@ -1575,7 +1582,7 @@ void CmndTempTargetSet(void)
|
|||||||
}
|
}
|
||||||
if ( (value >= -1000)
|
if ( (value >= -1000)
|
||||||
&& (value <= 1000)
|
&& (value <= 1000)
|
||||||
&& (value >= (int16_t)Thermostat[ctr_output].temp_frost_protect)) {
|
&& (value >= Thermostat[ctr_output].temp_frost_protect)) {
|
||||||
Thermostat[ctr_output].temp_target_level = value;
|
Thermostat[ctr_output].temp_target_level = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user