From 1bad689b6b28a5028dad2018680ed15874e8acd4 Mon Sep 17 00:00:00 2001 From: Yurii Date: Sun, 24 Mar 2024 19:27:16 +0300 Subject: [PATCH 1/5] fix: revert board_build.ldscript for esp8266, update OpenTherm Library --- platformio.ini | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index d24bd9c..145297d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,9 +15,9 @@ extra_configs = secrets.default.ini [env] framework = arduino lib_deps = - bblanchon/ArduinoJson@^7.0.3 + bblanchon/ArduinoJson@^7.0.4 ;ihormelnyk/OpenTherm Library@^1.1.5 - https://github.com/ihormelnyk/opentherm_library.git + https://github.com/Laxilef/opentherm_library/archive/refs/heads/fix_lambda.zip arduino-libraries/ArduinoMqttClient@^0.1.8 lennarthennigs/ESP Telnet@^2.2 gyverlibs/FileData@^1.0.2 @@ -30,7 +30,7 @@ build_flags = -D PIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK305 -mtext-section-literals -D MQTT_CLIENT_STD_FUNCTION_CALLBACK=1 - ;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_PORT=Serial + ;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial -D USE_SERIAL=${secrets.use_serial} -D USE_TELNET=${secrets.use_telnet} -D DEBUG_BY_DEFAULT=${secrets.debug} @@ -58,13 +58,12 @@ version = 1.4.0-rc.17 platform = espressif8266 lib_deps = ${env.lib_deps} - nrwiersma/ESP8266Scheduler@^1.1 + nrwiersma/ESP8266Scheduler@^1.2 lib_ignore = extra_scripts = post:tools/build.py build_flags = ${env.build_flags} -board_build.ldscript = eagle.flash.1m256.ld -;board_build.ldscript = eagle.flash.4m1m.ld +board_build.ldscript = eagle.flash.4m1m.ld [esp32_defaults] platform = espressif32@^6.5 From 942bc53043d990eeb0ab4cc4d7cd41209e144d75 Mon Sep 17 00:00:00 2001 From: Yurii Date: Sun, 24 Mar 2024 19:28:26 +0300 Subject: [PATCH 2/5] chore: bump version --- platformio.ini | 2 +- src/defines.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 145297d..3f6b841 100644 --- a/platformio.ini +++ b/platformio.ini @@ -51,7 +51,7 @@ monitor_speed = 115200 monitor_filters = direct board_build.flash_mode = dio board_build.filesystem = littlefs -version = 1.4.0-rc.17 +version = 1.4.0-rc.18 ; Defaults [esp8266_defaults] diff --git a/src/defines.h b/src/defines.h index 14cd74b..1c21537 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,5 +1,5 @@ #define PROJECT_NAME "OpenTherm Gateway" -#define PROJECT_VERSION "1.4.0-rc.17" +#define PROJECT_VERSION "1.4.0-rc.18" #define PROJECT_REPO "https://github.com/Laxilef/OTGateway" #define EMERGENCY_TIME_TRESHOLD 120000 From 41cca76bfadd406e719832fea075b172c69a6466 Mon Sep 17 00:00:00 2001 From: Yurii Date: Sun, 24 Mar 2024 20:38:02 +0300 Subject: [PATCH 3/5] chore: update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4edf667..4225a2a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![logo](/assets/logo.svg)
- [![GitHub version](https://img.shields.io/github/release/Laxilef/OTGateway.svg)](https://github.com/Laxilef/OTGateway/releases) + [![GitHub version](https://img.shields.io/github/release/Laxilef/OTGateway.svg?include_prereleases)](https://github.com/Laxilef/OTGateway/releases) [![GitHub download](https://img.shields.io/github/downloads/Laxilef/OTGateway/total.svg)](https://github.com/Laxilef/OTGateway/releases/latest) [![License](https://img.shields.io/github/license/Laxilef/OTGateway.svg)](LICENSE.txt) [![Telegram](https://img.shields.io/badge/Telegram-Channel-33A8E3)](https://t.me/otgateway) From f544f01caac22bb9ba6f10a326db9eb651e006b8 Mon Sep 17 00:00:00 2001 From: Yurii Date: Sat, 30 Mar 2024 00:04:51 +0300 Subject: [PATCH 4/5] feat: polling of exhaust gas temperature (#42) and heating return temperature; added new sensors to HA --- src/HaHelper.h | 46 +++++++++++++++++++++++++++++++++++++++++++++ src/MqttTask.h | 2 ++ src/OpenThermTask.h | 36 +++++++++++++++++++++++++++++++++++ src/Settings.h | 2 ++ src/utils.h | 2 ++ 5 files changed, 88 insertions(+) diff --git a/src/HaHelper.h b/src/HaHelper.h index 4a54d38..1d105ef 100644 --- a/src/HaHelper.h +++ b/src/HaHelper.h @@ -1136,6 +1136,29 @@ public: return this->publish(this->getTopic(FPSTR(HA_ENTITY_SENSOR), F("heating_temp")).c_str(), doc); } + bool publishSensorHeatingReturnTemp(bool enabledByDefault = true) { + JsonDocument doc; + doc[FPSTR(HA_AVAILABILITY)][0][FPSTR(HA_TOPIC)] = this->getDeviceTopic(F("status")); + doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_TOPIC)] = this->getDeviceTopic(F("state")); + doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.states.otStatus, 'online', 'offline') }}"); + doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); + doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; + doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectId(F("heating_return_temp")); + doc[FPSTR(HA_OBJECT_ID)] = this->getObjectId(F("heating_return_temp")); + doc[FPSTR(HA_ENTITY_CATEGORY)] = F("diagnostic"); + doc[FPSTR(HA_DEVICE_CLASS)] = F("temperature"); + doc[FPSTR(HA_STATE_CLASS)] = F("measurement"); + doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("°C"); + doc[FPSTR(HA_NAME)] = F("Heating return temperature"); + doc[FPSTR(HA_ICON)] = F("mdi:radiator"); + doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic(F("state")); + doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.temperatures.heatingReturn|float(0)|round(2) }}"); + doc[FPSTR(HA_EXPIRE_AFTER)] = 120; + doc.shrinkToFit(); + + return this->publish(this->getTopic(FPSTR(HA_ENTITY_SENSOR), F("heating_return_temp")).c_str(), doc); + } + bool publishSensorDhwTemp(bool enabledByDefault = true) { JsonDocument doc; doc[FPSTR(HA_AVAILABILITY)][0][FPSTR(HA_TOPIC)] = this->getDeviceTopic(F("status")); @@ -1159,6 +1182,29 @@ public: return this->publish(this->getTopic(FPSTR(HA_ENTITY_SENSOR), F("dhw_temp")).c_str(), doc); } + bool publishSensorExhaustTemp(bool enabledByDefault = true) { + JsonDocument doc; + doc[FPSTR(HA_AVAILABILITY)][0][FPSTR(HA_TOPIC)] = this->getDeviceTopic(F("status")); + doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_TOPIC)] = this->getDeviceTopic(F("state")); + doc[FPSTR(HA_AVAILABILITY)][1][FPSTR(HA_VALUE_TEMPLATE)] = F("{{ iif(value_json.states.otStatus, 'online', 'offline') }}"); + doc[FPSTR(HA_AVAILABILITY_MODE)] = F("all"); + doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault; + doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectId(F("exhaust_temp")); + doc[FPSTR(HA_OBJECT_ID)] = this->getObjectId(F("exhaust_temp")); + doc[FPSTR(HA_ENTITY_CATEGORY)] = F("diagnostic"); + doc[FPSTR(HA_DEVICE_CLASS)] = F("temperature"); + doc[FPSTR(HA_STATE_CLASS)] = F("measurement"); + doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("°C"); + doc[FPSTR(HA_NAME)] = F("Exhaust temperature"); + doc[FPSTR(HA_ICON)] = F("mdi:smoke"); + doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic(F("state")); + doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.temperatures.exhaust|float(0)|round(2) }}"); + doc[FPSTR(HA_EXPIRE_AFTER)] = 120; + doc.shrinkToFit(); + + return this->publish(this->getTopic(FPSTR(HA_ENTITY_SENSOR), F("exhaust_temp")).c_str(), doc); + } + bool publishClimateHeating(byte minTemp = 20, byte maxTemp = 90, byte currentTempSource = HaHelper::TEMP_SOURCE_HEATING, bool enabledByDefault = true) { JsonDocument doc; diff --git a/src/MqttTask.h b/src/MqttTask.h index 0b7f5d9..4e4f954 100644 --- a/src/MqttTask.h +++ b/src/MqttTask.h @@ -370,6 +370,8 @@ protected: // temperatures this->haHelper->publishNumberIndoorTemp(); this->haHelper->publishSensorHeatingTemp(); + this->haHelper->publishSensorHeatingReturnTemp(false); + this->haHelper->publishSensorExhaustTemp(false); // buttons this->haHelper->publishButtonRestart(false); diff --git a/src/OpenThermTask.h b/src/OpenThermTask.h index f24a19e..84e8287 100644 --- a/src/OpenThermTask.h +++ b/src/OpenThermTask.h @@ -293,6 +293,12 @@ protected: // Get current heating temp updateHeatingTemp(); + // Get heating return temp + updateHeatingReturnTemp(); + + // Get exhaust temp + updateExhaustTemp(); + // Fault reset action if (vars.actions.resetFault) { @@ -655,6 +661,21 @@ protected: return true; } + bool updateExhaustTemp() { + unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( + OpenThermRequestType::READ_DATA, + OpenThermMessageID::Texhaust, + 0 + )); + + if (!CustomOpenTherm::isValidResponse(response)) { + return false; + } + + vars.temperatures.exhaust = CustomOpenTherm::getFloat(response); + return true; + } + bool updateHeatingTemp() { unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( OpenThermMessageType::READ_DATA, @@ -675,6 +696,21 @@ protected: return true; } + bool updateHeatingReturnTemp() { + unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( + OpenThermMessageType::READ_DATA, + OpenThermMessageID::Tret, + 0 + )); + + if (!CustomOpenTherm::isValidResponse(response)) { + return false; + } + + vars.temperatures.heatingReturn = CustomOpenTherm::getFloat(response); + return true; + } + bool updateDhwTemp() { unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest( diff --git a/src/Settings.h b/src/Settings.h index 6576040..e24b1db 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -153,7 +153,9 @@ struct Variables { float indoor = 0.0f; float outdoor = 0.0f; float heating = 0.0f; + float heatingReturn = 0.0f; float dhw = 0.0f; + float exhaust = 0.0f; } temperatures; struct { diff --git a/src/utils.h b/src/utils.h index c17c6ed..c72c90b 100644 --- a/src/utils.h +++ b/src/utils.h @@ -998,7 +998,9 @@ void varsToJson(const Variables& src, JsonVariant dst) { dst["temperatures"]["indoor"] = roundd(src.temperatures.indoor, 2); dst["temperatures"]["outdoor"] = roundd(src.temperatures.outdoor, 2); dst["temperatures"]["heating"] = roundd(src.temperatures.heating, 2); + dst["temperatures"]["heatingReturn"] = roundd(src.temperatures.heatingReturn, 2); dst["temperatures"]["dhw"] = roundd(src.temperatures.dhw, 2); + dst["temperatures"]["exhaust"] = roundd(src.temperatures.exhaust, 2); dst["parameters"]["heatingEnabled"] = src.parameters.heatingEnabled; dst["parameters"]["heatingMinTemp"] = src.parameters.heatingMinTemp; From 39a29042e10a70bd47e5e36db9d313bb5b27d3c0 Mon Sep 17 00:00:00 2001 From: Yurii Date: Sun, 31 Mar 2024 00:37:18 +0300 Subject: [PATCH 5/5] fix: set max temp (ID57) as setpoint heating temp --- src/OpenThermTask.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/OpenThermTask.h b/src/OpenThermTask.h index 84e8287..62462fb 100644 --- a/src/OpenThermTask.h +++ b/src/OpenThermTask.h @@ -253,9 +253,6 @@ protected: fsSettings.update(); } - // Force set max heating temp - setMaxHeatingTemp(settings.heating.maxTemp); - // Get outdoor temp (if necessary) if (settings.sensors.outdoor.type == SensorType::BOILER) { updateOutsideTemp(); @@ -361,7 +358,7 @@ protected: Log.sinfoln(FPSTR(L_OT_HEATING), F("Set temp = %u"), vars.parameters.heatingSetpoint); // Set heating temp - if (this->instance->setHeatingCh1Temp(vars.parameters.heatingSetpoint)) { + if (this->instance->setHeatingCh1Temp(vars.parameters.heatingSetpoint) || this->setMaxHeatingTemp(vars.parameters.heatingSetpoint)) { currentHeatingTemp = vars.parameters.heatingSetpoint; this->heatingSetTempTime = millis();