mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-10 18:24:27 +05:00
reformat code
This commit is contained in:
@@ -88,7 +88,7 @@ public:
|
||||
return isValidResponse(response);
|
||||
}
|
||||
|
||||
bool setDHWTemp(float temperature) {
|
||||
bool setDhwTemp(float temperature) {
|
||||
unsigned int data = temperatureToData(temperature);
|
||||
unsigned long response = sendRequest(buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::TdhwSet, data));
|
||||
return isValidResponse(response);
|
||||
|
||||
@@ -378,7 +378,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
bool publishSwitchDHW(bool enabledByDefault = true) {
|
||||
bool publishSwitchDhw(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
return publish(getTopic("switch", "dhw").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishNumberDHWTarget(byte minTemp = 40, byte maxTemp = 60, bool enabledByDefault = true) {
|
||||
bool publishNumberDhwTarget(byte minTemp = 40, byte maxTemp = 60, bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
@@ -421,7 +421,7 @@ public:
|
||||
return publish(getTopic("number", "dhw_target").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishSensorCurrentDHWMinTemp(bool enabledByDefault = true) {
|
||||
bool publishSensorCurrentDhwMinTemp(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
@@ -439,7 +439,7 @@ public:
|
||||
return publish(getTopic("sensor", "current_dhw_min_temp").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishSensorCurrentDHWMaxTemp(bool enabledByDefault = true) {
|
||||
bool publishSensorCurrentDhwMaxTemp(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
@@ -457,7 +457,7 @@ public:
|
||||
return publish(getTopic("sensor", "current_dhw_max_temp").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishNumberDHWMinTemp(bool enabledByDefault = true) {
|
||||
bool publishNumberDhwMinTemp(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = devicePrefix + F("_dhw_min_temp");
|
||||
@@ -479,7 +479,7 @@ public:
|
||||
return publish(getTopic("number", "dhw_min_temp").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishNumberDHWMaxTemp(bool enabledByDefault = true) {
|
||||
bool publishNumberDhwMaxTemp(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = devicePrefix + F("_dhw_max_temp");
|
||||
@@ -788,7 +788,7 @@ public:
|
||||
return publish(getTopic("binary_sensor", "heating").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishBinSensorDHW(bool enabledByDefault = true) {
|
||||
bool publishBinSensorDhw(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
@@ -1056,7 +1056,7 @@ public:
|
||||
return publish(getTopic("sensor", "heating_temp").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishSensorDHWTemp(bool enabledByDefault = true) {
|
||||
bool publishSensorDhwTemp(bool enabledByDefault = true) {
|
||||
StaticJsonDocument<1536> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
@@ -1119,7 +1119,7 @@ public:
|
||||
return publish(getTopic("climate", "heating", "_").c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishClimateDHW(byte minTemp = 40, byte maxTemp = 60, bool enabledByDefault = true) {
|
||||
bool publishClimateDhw(byte minTemp = 40, byte maxTemp = 60, bool enabledByDefault = true) {
|
||||
StaticJsonDocument<2560> doc;
|
||||
doc[FPSTR(HA_AVAILABILITY)][FPSTR(HA_TOPIC)] = devicePrefix + F("/status");
|
||||
|
||||
@@ -1219,35 +1219,35 @@ public:
|
||||
return publish(getTopic("sensor", "indoor_temp").c_str());
|
||||
}
|
||||
|
||||
bool deleteSwitchDHW() {
|
||||
bool deleteSwitchDhw() {
|
||||
return publish(getTopic("switch", "dhw").c_str());
|
||||
}
|
||||
|
||||
bool deleteSensorCurrentDHWMinTemp() {
|
||||
bool deleteSensorCurrentDhwMinTemp() {
|
||||
return publish(getTopic("sensor", "current_dhw_min_temp").c_str());
|
||||
}
|
||||
|
||||
bool deleteSensorCurrentDHWMaxTemp() {
|
||||
bool deleteSensorCurrentDhwMaxTemp() {
|
||||
return publish(getTopic("sensor", "current_dhw_max_temp").c_str());
|
||||
}
|
||||
|
||||
bool deleteNumberDHWMinTemp() {
|
||||
bool deleteNumberDhwMinTemp() {
|
||||
return publish(getTopic("number", "dhw_min_temp").c_str());
|
||||
}
|
||||
|
||||
bool deleteNumberDHWMaxTemp() {
|
||||
bool deleteNumberDhwMaxTemp() {
|
||||
return publish(getTopic("number", "dhw_max_temp").c_str());
|
||||
}
|
||||
|
||||
bool deleteBinSensorDHW() {
|
||||
bool deleteBinSensorDhw() {
|
||||
return publish(getTopic("binary_sensor", "dhw").c_str());
|
||||
}
|
||||
|
||||
bool deleteSensorDHWTemp() {
|
||||
bool deleteSensorDhwTemp() {
|
||||
return publish(getTopic("sensor", "dhw_temp").c_str());
|
||||
}
|
||||
|
||||
bool deleteNumberDHWTarget() {
|
||||
bool deleteNumberDhwTarget() {
|
||||
return publish(getTopic("number", "dhw_target").c_str());
|
||||
}
|
||||
|
||||
@@ -1255,7 +1255,7 @@ public:
|
||||
return publish(getTopic("sensor", "dhw_flow_rate").c_str());
|
||||
}
|
||||
|
||||
bool deleteClimateDHW() {
|
||||
bool deleteClimateDhw() {
|
||||
return publish(getTopic("climate", "dhw", "_").c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -392,7 +392,6 @@ protected:
|
||||
// heating
|
||||
haHelper.publishSwitchHeating(false);
|
||||
haHelper.publishSwitchHeatingTurbo();
|
||||
//haHelper.publishNumberHeatingTarget(false);
|
||||
haHelper.publishNumberHeatingHysteresis();
|
||||
haHelper.publishSensorHeatingSetpoint(false);
|
||||
haHelper.publishSensorCurrentHeatingMinTemp(false);
|
||||
@@ -436,7 +435,6 @@ protected:
|
||||
|
||||
// temperatures
|
||||
haHelper.publishNumberIndoorTemp();
|
||||
//haHelper.publishNumberOutdoorTemp();
|
||||
haHelper.publishSensorHeatingTemp();
|
||||
|
||||
// buttons
|
||||
@@ -460,25 +458,25 @@ protected:
|
||||
_dhwPresent = settings.opentherm.dhwPresent;
|
||||
|
||||
if (_dhwPresent) {
|
||||
haHelper.publishSwitchDHW(false);
|
||||
haHelper.publishSensorCurrentDHWMinTemp(false);
|
||||
haHelper.publishSensorCurrentDHWMaxTemp(false);
|
||||
haHelper.publishNumberDHWMinTemp(false);
|
||||
haHelper.publishNumberDHWMaxTemp(false);
|
||||
haHelper.publishBinSensorDHW();
|
||||
haHelper.publishSensorDHWTemp();
|
||||
haHelper.publishSwitchDhw(false);
|
||||
haHelper.publishSensorCurrentDhwMinTemp(false);
|
||||
haHelper.publishSensorCurrentDhwMaxTemp(false);
|
||||
haHelper.publishNumberDhwMinTemp(false);
|
||||
haHelper.publishNumberDhwMaxTemp(false);
|
||||
haHelper.publishBinSensorDhw();
|
||||
haHelper.publishSensorDhwTemp();
|
||||
haHelper.publishSensorDhwFlowRate(false);
|
||||
|
||||
} else {
|
||||
haHelper.deleteSwitchDHW();
|
||||
haHelper.deleteSensorCurrentDHWMinTemp();
|
||||
haHelper.deleteSensorCurrentDHWMaxTemp();
|
||||
haHelper.deleteNumberDHWMinTemp();
|
||||
haHelper.deleteNumberDHWMaxTemp();
|
||||
haHelper.deleteBinSensorDHW();
|
||||
haHelper.deleteSensorDHWTemp();
|
||||
haHelper.deleteNumberDHWTarget();
|
||||
haHelper.deleteClimateDHW();
|
||||
haHelper.deleteSwitchDhw();
|
||||
haHelper.deleteSensorCurrentDhwMinTemp();
|
||||
haHelper.deleteSensorCurrentDhwMaxTemp();
|
||||
haHelper.deleteNumberDhwMinTemp();
|
||||
haHelper.deleteNumberDhwMaxTemp();
|
||||
haHelper.deleteBinSensorDhw();
|
||||
haHelper.deleteSensorDhwTemp();
|
||||
haHelper.deleteNumberDhwTarget();
|
||||
haHelper.deleteClimateDhw();
|
||||
haHelper.deleteSensorDhwFlowRate();
|
||||
}
|
||||
|
||||
@@ -503,8 +501,8 @@ protected:
|
||||
_dhwMinTemp = settings.dhw.minTemp;
|
||||
_dhwMaxTemp = settings.dhw.maxTemp;
|
||||
|
||||
haHelper.publishNumberDHWTarget(settings.dhw.minTemp, settings.dhw.maxTemp, false);
|
||||
haHelper.publishClimateDHW(settings.dhw.minTemp, settings.dhw.maxTemp);
|
||||
haHelper.publishNumberDhwTarget(settings.dhw.minTemp, settings.dhw.maxTemp, false);
|
||||
haHelper.publishClimateDhw(settings.dhw.minTemp, settings.dhw.maxTemp);
|
||||
|
||||
published = true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ protected:
|
||||
}
|
||||
|
||||
void loop() {
|
||||
static byte currentHeatingTemp, currentDHWTemp = 0;
|
||||
static byte currentHeatingTemp, currentDhwTemp = 0;
|
||||
unsigned long localResponse;
|
||||
|
||||
if (setMasterMemberIdCode()) {
|
||||
@@ -179,8 +179,8 @@ protected:
|
||||
yield();
|
||||
|
||||
if (settings.opentherm.dhwPresent) {
|
||||
updateDHWTemp();
|
||||
updateDHWFlowRate();
|
||||
updateDhwTemp();
|
||||
updateDhwFlowRate();
|
||||
} else {
|
||||
vars.temperatures.dhw = 0;
|
||||
vars.sensors.dhwFlowRate = 0.0f;
|
||||
@@ -221,17 +221,17 @@ protected:
|
||||
|
||||
//
|
||||
// Температура ГВС
|
||||
byte newDHWTemp = settings.dhw.target;
|
||||
if (settings.opentherm.dhwPresent && settings.dhw.enable && (needSetDhwTemp() || newDHWTemp != currentDHWTemp)) {
|
||||
if (newDHWTemp < settings.dhw.minTemp || newDHWTemp > settings.dhw.maxTemp) {
|
||||
newDHWTemp = constrain(newDHWTemp, settings.dhw.minTemp, settings.dhw.maxTemp);
|
||||
byte newDhwTemp = settings.dhw.target;
|
||||
if (settings.opentherm.dhwPresent && settings.dhw.enable && (needSetDhwTemp() || newDhwTemp != currentDhwTemp)) {
|
||||
if (newDhwTemp < settings.dhw.minTemp || newDhwTemp > settings.dhw.maxTemp) {
|
||||
newDhwTemp = constrain(newDhwTemp, settings.dhw.minTemp, settings.dhw.maxTemp);
|
||||
}
|
||||
|
||||
Log.sinfoln("OT.DHW", "Set temp = %u", newDHWTemp);
|
||||
Log.sinfoln("OT.DHW", "Set temp = %u", newDhwTemp);
|
||||
|
||||
// Записываем заданную температуру ГВС
|
||||
if (ot->setDHWTemp(newDHWTemp)) {
|
||||
currentDHWTemp = newDHWTemp;
|
||||
if (ot->setDhwTemp(newDhwTemp)) {
|
||||
currentDhwTemp = newDhwTemp;
|
||||
dhwSetTempTime = millis();
|
||||
|
||||
} else {
|
||||
@@ -239,7 +239,7 @@ protected:
|
||||
}
|
||||
|
||||
if (settings.opentherm.dhwToCh2) {
|
||||
if (!ot->setHeatingCh2Temp(newDHWTemp)) {
|
||||
if (!ot->setHeatingCh2Temp(newDhwTemp)) {
|
||||
Log.swarningln("OT.DHW", "Failed set ch2 temp");
|
||||
}
|
||||
}
|
||||
@@ -501,7 +501,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
bool updateDHWTemp() {
|
||||
bool updateDhwTemp() {
|
||||
unsigned long response = ot->sendRequest(ot->buildRequest(OpenThermMessageType::READ, OpenThermMessageID::Tdhw, 0));
|
||||
if (!ot->isValidResponse(response)) {
|
||||
return false;
|
||||
@@ -511,7 +511,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool updateDHWFlowRate() {
|
||||
bool updateDhwFlowRate() {
|
||||
unsigned long response = ot->sendRequest(ot->buildRequest(OpenThermMessageType::READ, OpenThermMessageID::DHWFlowRate, 0));
|
||||
if (!ot->isValidResponse(response)) {
|
||||
return false;
|
||||
|
||||
@@ -15,11 +15,11 @@ UnsignedIntParameter* wmMqttPublishInterval;
|
||||
UnsignedIntParameter* wmOtInPin;
|
||||
UnsignedIntParameter* wmOtOutPin;
|
||||
UnsignedIntParameter* wmOtMemberIdCode;
|
||||
CheckboxParameter* wmOtDHWPresent;
|
||||
CheckboxParameter* wmOtDhwPresent;
|
||||
CheckboxParameter* wmOtSummerWinterMode;
|
||||
CheckboxParameter* wmOtHeatingCh2Enabled;
|
||||
CheckboxParameter* wmOtHeatingCh1ToCh2;
|
||||
CheckboxParameter* wmOtDHWToCh2;
|
||||
CheckboxParameter* wmOtDhwToCh2;
|
||||
UnsignedIntParameter* wmOutdoorSensorPin;
|
||||
UnsignedIntParameter* wmIndoorSensorPin;
|
||||
|
||||
@@ -94,8 +94,8 @@ protected:
|
||||
wmOtMemberIdCode = new UnsignedIntParameter("ot_member_id_code", "Opentherm Master Member ID", settings.opentherm.memberIdCode, 5);
|
||||
wm.addParameter(wmOtMemberIdCode);
|
||||
|
||||
wmOtDHWPresent = new CheckboxParameter("ot_dhw_present", "Opentherm DHW present", settings.opentherm.dhwPresent);
|
||||
wm.addParameter(wmOtDHWPresent);
|
||||
wmOtDhwPresent = new CheckboxParameter("ot_dhw_present", "Opentherm DHW present", settings.opentherm.dhwPresent);
|
||||
wm.addParameter(wmOtDhwPresent);
|
||||
|
||||
wmOtSummerWinterMode = new CheckboxParameter("ot_summer_winter_mode", "Opentherm summer/winter mode", settings.opentherm.summerWinterMode);
|
||||
wm.addParameter(wmOtSummerWinterMode);
|
||||
@@ -106,8 +106,8 @@ protected:
|
||||
wmOtHeatingCh1ToCh2 = new CheckboxParameter("ot_heating_ch1_to_ch2", "Opentherm heating CH1 to CH2", settings.opentherm.heatingCh1ToCh2);
|
||||
wm.addParameter(wmOtHeatingCh1ToCh2);
|
||||
|
||||
wmOtDHWToCh2 = new CheckboxParameter("ot_dhw_to_ch2", "Opentherm DHW to CH2", settings.opentherm.dhwToCh2);
|
||||
wm.addParameter(wmOtDHWToCh2);
|
||||
wmOtDhwToCh2 = new CheckboxParameter("ot_dhw_to_ch2", "Opentherm DHW to CH2", settings.opentherm.dhwToCh2);
|
||||
wm.addParameter(wmOtDhwToCh2);
|
||||
|
||||
wmSep2 = new SeparatorParameter();
|
||||
wm.addParameter(wmSep2);
|
||||
@@ -240,9 +240,9 @@ protected:
|
||||
settings.opentherm.memberIdCode = wmOtMemberIdCode->getValue();
|
||||
}
|
||||
|
||||
if (wmOtDHWPresent->getCheckboxValue() != settings.opentherm.dhwPresent) {
|
||||
if (wmOtDhwPresent->getCheckboxValue() != settings.opentherm.dhwPresent) {
|
||||
changed = true;
|
||||
settings.opentherm.dhwPresent = wmOtDHWPresent->getCheckboxValue();
|
||||
settings.opentherm.dhwPresent = wmOtDhwPresent->getCheckboxValue();
|
||||
}
|
||||
|
||||
if (wmOtSummerWinterMode->getCheckboxValue() != settings.opentherm.summerWinterMode) {
|
||||
@@ -261,7 +261,7 @@ protected:
|
||||
|
||||
if (settings.opentherm.dhwToCh2) {
|
||||
settings.opentherm.dhwToCh2 = false;
|
||||
wmOtDHWToCh2->setValue(false);
|
||||
wmOtDhwToCh2->setValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,13 +276,13 @@ protected:
|
||||
|
||||
if (settings.opentherm.dhwToCh2) {
|
||||
settings.opentherm.dhwToCh2 = false;
|
||||
wmOtDHWToCh2->setValue(false);
|
||||
wmOtDhwToCh2->setValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (wmOtDHWToCh2->getCheckboxValue() != settings.opentherm.dhwToCh2) {
|
||||
if (wmOtDhwToCh2->getCheckboxValue() != settings.opentherm.dhwToCh2) {
|
||||
changed = true;
|
||||
settings.opentherm.dhwToCh2 = wmOtDHWToCh2->getCheckboxValue();
|
||||
settings.opentherm.dhwToCh2 = wmOtDhwToCh2->getCheckboxValue();
|
||||
|
||||
if (settings.opentherm.heatingCh2Enabled) {
|
||||
settings.opentherm.heatingCh2Enabled = false;
|
||||
|
||||
Reference in New Issue
Block a user