Skip to content

Commit

Permalink
feat: ability to use return heat carrier temp as indoor temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Laxilef committed Nov 1, 2024
1 parent 0e3473e commit 467cfea
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 18 deletions.
22 changes: 19 additions & 3 deletions src/OpenThermTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,14 @@ class OpenThermTask : public Task {
} else if (vars.states.otStatus && millis() - this->lastSuccessResponse > 1150) {
Log.swarningln(FPSTR(L_OT), F("Disconnected"));

if (settings.sensors.outdoor.type == SensorType::BOILER) {
if (settings.sensors.outdoor.type == SensorType::BOILER_OUTDOOR) {
vars.sensors.outdoor.connected = false;
}

if (settings.sensors.indoor.type == SensorType::BOILER_RETURN) {
vars.sensors.indoor.connected = false;
}

vars.states.otStatus = false;
this->isInitialized = false;
}
Expand Down Expand Up @@ -396,7 +400,7 @@ class OpenThermTask : public Task {
// update these parameters once a minute
if (!settings.opentherm.filterNumValues.enable) {
// Get outdoor temp (if necessary)
if (settings.sensors.outdoor.type == SensorType::BOILER) {
if (settings.sensors.outdoor.type == SensorType::BOILER_OUTDOOR) {
if (this->updateOutdoorTemp()) {
if (!vars.sensors.outdoor.connected) {
vars.sensors.outdoor.connected = true;
Expand Down Expand Up @@ -486,9 +490,21 @@ class OpenThermTask : public Task {

// Get heating return temp
if (this->updateHeatingReturnTemp()) {
if (settings.sensors.indoor.type == SensorType::BOILER_RETURN) {
vars.temperatures.indoor = settings.sensors.outdoor.offset + vars.temperatures.heatingReturn;

if (!vars.sensors.outdoor.connected) {
vars.sensors.indoor.connected = true;
}
}

Log.snoticeln(FPSTR(L_OT_HEATING), F("Received return temp: %.2f"), vars.temperatures.heatingReturn);

} else {
if (settings.sensors.indoor.type == SensorType::BOILER_RETURN && vars.sensors.outdoor.connected) {
vars.sensors.indoor.connected = false;
}

Log.swarningln(FPSTR(L_OT_HEATING), F("Failed receive return temp"));
}

Expand All @@ -504,7 +520,7 @@ class OpenThermTask : public Task {
// must be updated every time.
if (settings.opentherm.filterNumValues.enable) {
// Get outdoor temp (if necessary)
if (settings.sensors.outdoor.type == SensorType::BOILER) {
if (settings.sensors.outdoor.type == SensorType::BOILER_OUTDOOR) {
if (this->updateOutdoorTemp()) {
if (!vars.sensors.outdoor.connected) {
vars.sensors.outdoor.connected = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct Settings {

struct {
struct {
SensorType type = SensorType::BOILER;
SensorType type = SensorType::BOILER_OUTDOOR;
byte gpio = DEFAULT_SENSOR_OUTDOOR_GPIO;
uint8_t bleAddress[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
float offset = 0.0f;
Expand Down
9 changes: 5 additions & 4 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@
#define GPIO_IS_VALID(gpioNum) (gpioNum != GPIO_IS_NOT_CONFIGURED && GPIO_IS_VALID_GPIO(gpioNum))

enum class SensorType : byte {
BOILER,
MANUAL,
DS18B20,
BLUETOOTH
BOILER_OUTDOOR = 0,
BOILER_RETURN = 4,
MANUAL = 1,
DS18B20 = 2,
BLUETOOTH = 3
};

enum class UnitSystem : byte {
Expand Down
17 changes: 12 additions & 5 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1178,9 +1178,9 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
byte value = src["sensors"]["outdoor"]["type"].as<unsigned char>();

switch (value) {
case static_cast<byte>(SensorType::BOILER):
if (dst.sensors.outdoor.type != SensorType::BOILER) {
dst.sensors.outdoor.type = SensorType::BOILER;
case static_cast<byte>(SensorType::BOILER_OUTDOOR):
if (dst.sensors.outdoor.type != SensorType::BOILER_OUTDOOR) {
dst.sensors.outdoor.type = SensorType::BOILER_OUTDOOR;
changed = true;
}
break;
Expand Down Expand Up @@ -1248,7 +1248,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
if (!src["sensors"]["outdoor"]["offset"].isNull()) {
float value = src["sensors"]["outdoor"]["offset"].as<float>();

if (value >= -10 && value <= 10 && fabs(value - dst.sensors.outdoor.offset) > 0.0001f) {
if (value >= -20.0f && value <= 20.0f && fabs(value - dst.sensors.outdoor.offset) > 0.0001f) {
dst.sensors.outdoor.offset = roundd(value, 2);
changed = true;
}
Expand All @@ -1258,6 +1258,13 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
byte value = src["sensors"]["indoor"]["type"].as<unsigned char>();

switch (value) {
case static_cast<byte>(SensorType::BOILER_RETURN):
if (dst.sensors.indoor.type != SensorType::BOILER_RETURN) {
dst.sensors.indoor.type = SensorType::BOILER_RETURN;
changed = true;
}
break;

case static_cast<byte>(SensorType::MANUAL):
if (dst.sensors.indoor.type != SensorType::MANUAL) {
dst.sensors.indoor.type = SensorType::MANUAL;
Expand Down Expand Up @@ -1321,7 +1328,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
if (!src["sensors"]["indoor"]["offset"].isNull()) {
float value = src["sensors"]["indoor"]["offset"].as<float>();

if (value >= -10 && value <= 10 && fabs(value - dst.sensors.indoor.offset) > 0.0001f) {
if (value >= -20.0f && value <= 20.0f && fabs(value - dst.sensors.indoor.offset) > 0.0001f) {
dst.sensors.indoor.offset = roundd(value, 2);
changed = true;
}
Expand Down
3 changes: 2 additions & 1 deletion src_data/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@
"tempSensor": {
"source": {
"type": "Source type",
"boiler": "From boiler via OpenTherm",
"boilerOutdoor": "From boiler via OpenTherm",
"boilerReturn": "Return heat carrier temp via OpenTherm",
"manual": "Manual via MQTT/API",
"ext": "External (DS18B20)",
"ble": "BLE device"
Expand Down
3 changes: 2 additions & 1 deletion src_data/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@
"tempSensor": {
"source": {
"type": "Источник данных",
"boiler": "От котла через OpenTherm",
"boilerOutdoor": "От котла через OpenTherm",
"boilerReturn": "Температура обратки через OpenTherm",
"manual": "Вручную через MQTT/API",
"ext": "Внешний датчик (DS18B20)",
"ble": "BLE устройство"
Expand Down
11 changes: 8 additions & 3 deletions src_data/pages/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ <h2 data-i18n>settings.name</h2>

<label>
<input type="radio" class="outdoor-sensor-type" name="sensors[outdoor][type]" value="0" />
<span data-i18n>settings.tempSensor.source.boiler</span>
<span data-i18n>settings.tempSensor.source.boilerOutdoor</span>
</label>

<label>
Expand Down Expand Up @@ -599,7 +599,7 @@ <h2 data-i18n>settings.name</h2>

<label for="outdoor-sensor-offset">
<span data-i18n>settings.tempSensor.offset</span>
<input type="number" inputmode="numeric" id="outdoor-sensor-offset" name="sensors[outdoor][offset]" min="-10" max="10" step="0.01" required>
<input type="number" inputmode="numeric" id="outdoor-sensor-offset" name="sensors[outdoor][offset]" min="-20" max="20" step="0.01" required>
</label>

<fieldset>
Expand All @@ -621,6 +621,11 @@ <h2 data-i18n>settings.name</h2>
<fieldset>
<legend data-i18n>settings.tempSensor.source.type</legend>

<label>
<input type="radio" class="indoor-sensor-type" name="sensors[indoor][type]" value="4" />
<span data-i18n>settings.tempSensor.source.boilerReturn</span>
</label>

<label>
<input type="radio" class="indoor-sensor-type" name="sensors[indoor][type]" value="1" />
<span data-i18n>settings.tempSensor.source.manual</span>
Expand Down Expand Up @@ -651,7 +656,7 @@ <h2 data-i18n>settings.name</h2>

<label for="indoor-sensor-offset">
<span data-i18n>settings.tempSensor.offset</span>
<input type="number" inputmode="numeric" id="indoor-sensor-offset" name="sensors[indoor][offset]" min="-10" max="10" step="0.01" required>
<input type="number" inputmode="numeric" id="indoor-sensor-offset" name="sensors[indoor][offset]" min="-20" max="20" step="0.01" required>
</label>

<fieldset>
Expand Down

0 comments on commit 467cfea

Please sign in to comment.