mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-10 18:24:27 +05:00
feat: setting the cooling setpoint if cooling support is enabled
This commit is contained in:
@@ -236,7 +236,7 @@ protected:
|
||||
vars.slave.heating.active = CustomOpenTherm::isCentralHeatingActive(response);
|
||||
vars.slave.dhw.active = settings.opentherm.options.dhwSupport ? CustomOpenTherm::isHotWaterActive(response) : false;
|
||||
vars.slave.flame = CustomOpenTherm::isFlameOn(response);
|
||||
vars.slave.cooling = CustomOpenTherm::isCoolingActive(response);
|
||||
vars.slave.cooling.active = CustomOpenTherm::isCoolingActive(response);
|
||||
vars.slave.ch2.active = CustomOpenTherm::isCh2Active(response);
|
||||
vars.slave.fault.active = CustomOpenTherm::isFault(response);
|
||||
|
||||
@@ -250,7 +250,7 @@ protected:
|
||||
Log.snoticeln(
|
||||
FPSTR(L_OT), F("Received boiler status. Heating: %hhu; DHW: %hhu; flame: %hhu; cooling: %hhu; channel 2: %hhu; fault: %hhu; diag: %hhu"),
|
||||
vars.slave.heating.active, vars.slave.dhw.active,
|
||||
vars.slave.flame, vars.slave.cooling, vars.slave.ch2.active, vars.slave.fault.active, vars.slave.diag.active
|
||||
vars.slave.flame, vars.slave.cooling.active, vars.slave.ch2.active, vars.slave.fault.active, vars.slave.diag.active
|
||||
);
|
||||
}
|
||||
|
||||
@@ -318,6 +318,8 @@ protected:
|
||||
vars.slave.dhw.enabled = false;
|
||||
vars.slave.dhw.active = false;
|
||||
vars.slave.flame = false;
|
||||
vars.slave.cooling.active = false;
|
||||
vars.slave.cooling.setpoint = 0;
|
||||
vars.slave.fault.active = false;
|
||||
vars.slave.fault.code = 0;
|
||||
vars.slave.diag.active = false;
|
||||
@@ -688,6 +690,22 @@ protected:
|
||||
this->prevUpdateNonEssentialVars = millis();
|
||||
}
|
||||
|
||||
// Set cooling setpoint = heating max modulation
|
||||
if (settings.opentherm.options.coolingSupport) {
|
||||
if (this->setCoolingSetpoint(settings.heating.maxModulation)) {
|
||||
Log.snoticeln(
|
||||
FPSTR(L_OT), F("Set cooling setpoint: %hhu%% (response: %hhu%%)"),
|
||||
settings.heating.maxModulation, vars.slave.cooling.setpoint
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.swarningln(
|
||||
FPSTR(L_OT), F("Failed set cooling setpoint: %hhu%% (response: %hhu%%)"),
|
||||
settings.heating.maxModulation, vars.slave.cooling.setpoint
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Set max modulation level
|
||||
uint8_t targetMaxModulation = vars.slave.modulation.max;
|
||||
if (vars.slave.heating.active) {
|
||||
@@ -1568,6 +1586,26 @@ protected:
|
||||
return CustomOpenTherm::getUInt(response) == request;
|
||||
}
|
||||
|
||||
bool setCoolingSetpoint(const uint8_t value) {
|
||||
const unsigned int request = CustomOpenTherm::toFloat(value);
|
||||
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
|
||||
OpenThermRequestType::WRITE_DATA,
|
||||
OpenThermMessageID::CoolingControl,
|
||||
request
|
||||
));
|
||||
|
||||
if (!CustomOpenTherm::isValidResponse(response)) {
|
||||
return false;
|
||||
|
||||
} else if (!CustomOpenTherm::isValidResponseId(response, OpenThermMessageID::CoolingControl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vars.slave.cooling.setpoint = CustomOpenTherm::getFloat(response);
|
||||
|
||||
return CustomOpenTherm::getUInt(response) == request;
|
||||
}
|
||||
|
||||
bool setMaxModulationLevel(const uint8_t value) {
|
||||
const unsigned int request = CustomOpenTherm::toFloat(value);
|
||||
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
|
||||
|
||||
@@ -329,10 +329,14 @@ struct Variables {
|
||||
|
||||
bool connected = false;
|
||||
bool flame = false;
|
||||
bool cooling = false;
|
||||
float pressure = 0.0f;
|
||||
float heatExchangerTemp = 0.0f;
|
||||
|
||||
struct {
|
||||
bool active = false;
|
||||
uint8_t setpoint = 0;
|
||||
} cooling;
|
||||
|
||||
struct {
|
||||
bool active = false;
|
||||
uint8_t code = 0;
|
||||
|
||||
@@ -190,6 +190,7 @@ const char S_STA[] PROGMEM = "sta";
|
||||
const char S_STATE[] PROGMEM = "state";
|
||||
const char S_STATIC_CONFIG[] PROGMEM = "staticConfig";
|
||||
const char S_STATUS_LED_GPIO[] PROGMEM = "statusLedGpio";
|
||||
const char S_SETPOINT[] PROGMEM = "setpoint";
|
||||
const char S_SETPOINT_TEMP[] PROGMEM = "setpointTemp";
|
||||
const char S_SUBNET[] PROGMEM = "subnet";
|
||||
const char S_SUMMER_WINTER_MODE[] PROGMEM = "summerWinterMode";
|
||||
|
||||
@@ -2060,7 +2060,10 @@ void varsToJson(const Variables& src, JsonVariant dst) {
|
||||
slave[FPSTR(S_PROTOCOL_VERSION)] = src.slave.appVersion;
|
||||
slave[FPSTR(S_CONNECTED)] = src.slave.connected;
|
||||
slave[FPSTR(S_FLAME)] = src.slave.flame;
|
||||
slave[FPSTR(S_COOLING)] = src.slave.cooling;
|
||||
|
||||
auto sCooling = slave[FPSTR(S_COOLING)].to<JsonObject>();
|
||||
sCooling[FPSTR(S_ACTIVE)] = src.slave.cooling.active;
|
||||
sCooling[FPSTR(S_SETPOINT)] = src.slave.cooling.setpoint;
|
||||
|
||||
auto sModulation = slave[FPSTR(S_MODULATION)].to<JsonObject>();
|
||||
sModulation[FPSTR(S_MIN)] = src.slave.modulation.min;
|
||||
|
||||
Reference in New Issue
Block a user