mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-23 08:33:36 +05:00
Compare commits
15 Commits
otc_fix
...
069ba8e864
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
069ba8e864 | ||
|
|
3b038c4bd1 | ||
|
|
56a8574aba | ||
|
|
3adfabdf40 | ||
|
|
a9220d9fa1 | ||
|
|
5a14857f52 | ||
|
|
e487c78921 | ||
|
|
6c3b79bda1 | ||
|
|
09c50d5df8 | ||
|
|
348fab39bb | ||
|
|
f9cb421893 | ||
|
|
1d7f85f462 | ||
|
|
192f4ee18b | ||
|
|
f048d973d3 | ||
|
|
d576969ea4 |
@@ -70,50 +70,89 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool sendBoilerReset() {
|
||||
unsigned int data = 1;
|
||||
data <<= 8;
|
||||
unsigned long response = this->sendRequest(buildRequest(
|
||||
OpenThermMessageType::WRITE_DATA,
|
||||
OpenThermMessageID::RemoteRequest,
|
||||
data
|
||||
));
|
||||
|
||||
return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
|
||||
inline auto sendBoilerReset() {
|
||||
return this->sendRequestCode(1);
|
||||
}
|
||||
|
||||
bool sendServiceReset() {
|
||||
unsigned int data = 10;
|
||||
data <<= 8;
|
||||
unsigned long response = this->sendRequest(buildRequest(
|
||||
OpenThermMessageType::WRITE_DATA,
|
||||
OpenThermMessageID::RemoteRequest,
|
||||
data
|
||||
));
|
||||
|
||||
return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
|
||||
inline auto sendServiceReset() {
|
||||
return this->sendRequestCode(10);
|
||||
}
|
||||
|
||||
bool sendWaterFilling() {
|
||||
unsigned int data = 2;
|
||||
data <<= 8;
|
||||
inline auto sendWaterFilling() {
|
||||
return this->sendRequestCode(2);
|
||||
}
|
||||
|
||||
bool sendRequestCode(const uint8_t requestCode) {
|
||||
unsigned long response = this->sendRequest(buildRequest(
|
||||
OpenThermMessageType::WRITE_DATA,
|
||||
OpenThermMessageID::RemoteRequest,
|
||||
data
|
||||
static_cast<unsigned int>(requestCode) << 8
|
||||
));
|
||||
|
||||
return isValidResponse(response) && isValidResponseId(response, OpenThermMessageID::RemoteRequest);
|
||||
if (!isValidResponse(response) || !isValidResponseId(response, OpenThermMessageID::RemoteRequest)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8_t responseRequestCode = (response & 0xFFFF) >> 8;
|
||||
const uint8_t responseCode = response & 0xFF;
|
||||
if (responseRequestCode != requestCode || responseCode < 128) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// reset
|
||||
this->sendRequest(buildRequest(
|
||||
OpenThermMessageType::WRITE_DATA,
|
||||
OpenThermMessageID::RemoteRequest,
|
||||
0u << 8
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getStr(OpenThermMessageID id, char* buffer, uint16_t length = 50) {
|
||||
if (buffer == nullptr || length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long response;
|
||||
uint8_t index = 0;
|
||||
uint8_t maxIndex = 255;
|
||||
|
||||
while (index <= maxIndex && index < length) {
|
||||
response = this->sendRequest(buildRequest(
|
||||
OpenThermMessageType::READ_DATA,
|
||||
id,
|
||||
static_cast<unsigned int>(index) << 8
|
||||
));
|
||||
|
||||
if (!isValidResponse(response) || !isValidResponseId(response, id)) {
|
||||
break;
|
||||
}
|
||||
|
||||
const uint8_t character = response & 0xFF;
|
||||
if (character == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
maxIndex = (response & 0xFFFF) >> 8;
|
||||
}
|
||||
|
||||
buffer[index++] = static_cast<char>(character);
|
||||
}
|
||||
|
||||
buffer[index] = '\0';
|
||||
return index > 0;
|
||||
}
|
||||
|
||||
static bool isCh2Active(unsigned long response) {
|
||||
return response & 0x20;
|
||||
return response & 0x20;
|
||||
}
|
||||
|
||||
static bool isValidResponseId(unsigned long response, OpenThermMessageID id) {
|
||||
uint8_t responseId = (response >> 16) & 0xFF;
|
||||
const uint8_t responseId = (response >> 16) & 0xFF;
|
||||
|
||||
return (uint8_t)id == responseId;
|
||||
return static_cast<uint8_t>(id) == responseId;
|
||||
}
|
||||
|
||||
static uint8_t getResponseMessageTypeId(unsigned long response) {
|
||||
@@ -124,10 +163,10 @@ public:
|
||||
uint8_t msgType = getResponseMessageTypeId(response);
|
||||
|
||||
switch (msgType) {
|
||||
case (uint8_t) OpenThermMessageType::READ_ACK:
|
||||
case (uint8_t) OpenThermMessageType::WRITE_ACK:
|
||||
case (uint8_t) OpenThermMessageType::DATA_INVALID:
|
||||
case (uint8_t) OpenThermMessageType::UNKNOWN_DATA_ID:
|
||||
case static_cast<uint8_t>(OpenThermMessageType::READ_ACK):
|
||||
case static_cast<uint8_t>(OpenThermMessageType::WRITE_ACK):
|
||||
case static_cast<uint8_t>(OpenThermMessageType::DATA_INVALID):
|
||||
case static_cast<uint8_t>(OpenThermMessageType::UNKNOWN_DATA_ID):
|
||||
return CustomOpenTherm::messageTypeToString(
|
||||
static_cast<OpenThermMessageType>(msgType)
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
class UpgradeHandler : public RequestHandler {
|
||||
class UpgradeHandler : public AsyncWebHandler {
|
||||
public:
|
||||
enum class UpgradeType {
|
||||
FIRMWARE = 0,
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
NO_FILE,
|
||||
SUCCESS,
|
||||
PROHIBITED,
|
||||
ABORTED,
|
||||
SIZE_MISMATCH,
|
||||
ERROR_ON_START,
|
||||
ERROR_ON_WRITE,
|
||||
ERROR_ON_FINISH
|
||||
@@ -22,27 +22,21 @@ public:
|
||||
UpgradeType type;
|
||||
UpgradeStatus status;
|
||||
String error;
|
||||
size_t progress = 0;
|
||||
size_t size = 0;
|
||||
} UpgradeResult;
|
||||
|
||||
typedef std::function<bool(HTTPMethod, const String&)> CanHandleCallback;
|
||||
typedef std::function<bool(const String&)> CanUploadCallback;
|
||||
typedef std::function<bool(UpgradeType)> BeforeUpgradeCallback;
|
||||
typedef std::function<void(const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
|
||||
typedef std::function<bool(AsyncWebServerRequest *request, UpgradeType)> BeforeUpgradeCallback;
|
||||
typedef std::function<void(AsyncWebServerRequest *request, const UpgradeResult&, const UpgradeResult&)> AfterUpgradeCallback;
|
||||
|
||||
UpgradeHandler(const char* uri) {
|
||||
this->uri = uri;
|
||||
}
|
||||
UpgradeHandler(AsyncURIMatcher uri) : uri(uri) {}
|
||||
|
||||
UpgradeHandler* setCanHandleCallback(CanHandleCallback callback = nullptr) {
|
||||
this->canHandleCallback = callback;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
UpgradeHandler* setCanUploadCallback(CanUploadCallback callback = nullptr) {
|
||||
this->canUploadCallback = callback;
|
||||
|
||||
return this;
|
||||
bool canHandle(AsyncWebServerRequest *request) const override final {
|
||||
if (!request->isHTTP()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this->uri.matches(request);
|
||||
}
|
||||
|
||||
UpgradeHandler* setBeforeUpgradeCallback(BeforeUpgradeCallback callback = nullptr) {
|
||||
@@ -57,29 +51,9 @@ public:
|
||||
return this;
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
bool canHandle(WebServer &server, HTTPMethod method, const String &uri) override {
|
||||
return this->canHandle(method, uri);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool canHandle(HTTPMethod method, const String& uri) override {
|
||||
return method == HTTP_POST && uri.equals(this->uri) && (!this->canHandleCallback || this->canHandleCallback(method, uri));
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
bool canUpload(WebServer &server, const String &uri) override {
|
||||
return this->canUpload(uri);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool canUpload(const String& uri) override {
|
||||
return uri.equals(this->uri) && (!this->canUploadCallback || this->canUploadCallback(uri));
|
||||
}
|
||||
|
||||
bool handle(WebServer& server, HTTPMethod method, const String& uri) override {
|
||||
void handleRequest(AsyncWebServerRequest *request) override final {
|
||||
if (this->afterUpgradeCallback) {
|
||||
this->afterUpgradeCallback(this->firmwareResult, this->filesystemResult);
|
||||
this->afterUpgradeCallback(request, this->firmwareResult, this->filesystemResult);
|
||||
}
|
||||
|
||||
this->firmwareResult.status = UpgradeStatus::NONE;
|
||||
@@ -87,129 +61,147 @@ public:
|
||||
|
||||
this->filesystemResult.status = UpgradeStatus::NONE;
|
||||
this->filesystemResult.error.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void upload(WebServer& server, const String& uri, HTTPUpload& upload) override {
|
||||
UpgradeResult* result;
|
||||
if (upload.name.equals(F("firmware"))) {
|
||||
result = &this->firmwareResult;
|
||||
void handleUpload(AsyncWebServerRequest *request, const String &fileName, size_t index, uint8_t *data, size_t dataLength, bool isFinal) override final {
|
||||
UpgradeResult* result = nullptr;
|
||||
|
||||
} else if (upload.name.equals(F("filesystem"))) {
|
||||
result = &this->filesystemResult;
|
||||
|
||||
} else {
|
||||
if (!request->hasParam(asyncsrv::T_name, true, true)) {
|
||||
// Missing content-disposition 'name' parameter
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& pName = request->getParam(asyncsrv::T_name, true, true)->value();
|
||||
if (pName.equals("fw")) {
|
||||
result = &this->firmwareResult;
|
||||
|
||||
if (!index) {
|
||||
result->progress = 0;
|
||||
result->size = request->hasParam("fw_size", true)
|
||||
? request->getParam("fw_size", true)->value().toInt()
|
||||
: 0;
|
||||
}
|
||||
|
||||
} else if (pName.equals("fs")) {
|
||||
result = &this->filesystemResult;
|
||||
|
||||
if (!index) {
|
||||
result->progress = 0;
|
||||
result->size = request->hasParam("fs_size", true)
|
||||
? request->getParam("fs_size", true)->value().toInt()
|
||||
: 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Unknown parameter name
|
||||
return;
|
||||
}
|
||||
|
||||
// check result status
|
||||
if (result->status != UpgradeStatus::NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->beforeUpgradeCallback && !this->beforeUpgradeCallback(result->type)) {
|
||||
if (this->beforeUpgradeCallback && !this->beforeUpgradeCallback(request, result->type)) {
|
||||
result->status = UpgradeStatus::PROHIBITED;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!upload.filename.length()) {
|
||||
if (!fileName.length()) {
|
||||
result->status = UpgradeStatus::NO_FILE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (upload.status == UPLOAD_FILE_START) {
|
||||
if (!index) {
|
||||
// reset
|
||||
if (Update.isRunning()) {
|
||||
Update.end(false);
|
||||
Update.clearError();
|
||||
}
|
||||
|
||||
// try begin
|
||||
bool begin = false;
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
Update.runAsync(true);
|
||||
|
||||
if (result->type == UpgradeType::FIRMWARE) {
|
||||
begin = Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000, U_FLASH);
|
||||
|
||||
} else if (result->type == UpgradeType::FILESYSTEM) {
|
||||
close_all_fs();
|
||||
begin = Update.begin((size_t)FS_end - (size_t)FS_start, U_FS);
|
||||
}
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
if (result->type == UpgradeType::FIRMWARE) {
|
||||
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_FLASH);
|
||||
|
||||
} else if (result->type == UpgradeType::FILESYSTEM) {
|
||||
begin = Update.begin(UPDATE_SIZE_UNKNOWN, U_SPIFFS);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!begin || Update.hasError()) {
|
||||
result->status = UpgradeStatus::ERROR_ON_START;
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
result->error = Update.getErrorString();
|
||||
#else
|
||||
result->error = Update.errorString();
|
||||
#endif
|
||||
|
||||
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on start: %s"), upload.filename.c_str(), result->error.c_str());
|
||||
Log.serrorln(FPSTR(L_PORTAL_OTA), "File '%s', on start: %s", fileName.c_str(), result->error.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', started"), upload.filename.c_str());
|
||||
|
||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), "File '%s', started", fileName.c_str());
|
||||
}
|
||||
|
||||
if (dataLength) {
|
||||
if (Update.write(data, dataLength) != dataLength) {
|
||||
Update.end(false);
|
||||
|
||||
result->status = UpgradeStatus::ERROR_ON_WRITE;
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
result->error = Update.getErrorString();
|
||||
#else
|
||||
result->error = Update.errorString();
|
||||
#endif
|
||||
|
||||
Log.serrorln(
|
||||
FPSTR(L_PORTAL_OTA),
|
||||
F("File '%s', on writing %d bytes: %s"),
|
||||
upload.filename.c_str(), upload.totalSize, result->error.c_str()
|
||||
FPSTR(L_PORTAL_OTA), "File '%s', on write %d bytes, %d of %d bytes",
|
||||
fileName.c_str(),
|
||||
dataLength,
|
||||
result->progress + dataLength,
|
||||
result->size
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s', writed %d bytes"), upload.filename.c_str(), upload.totalSize);
|
||||
return;
|
||||
}
|
||||
|
||||
result->progress += dataLength;
|
||||
Log.sinfoln(
|
||||
FPSTR(L_PORTAL_OTA), "File '%s', write %d bytes, %d of %d bytes",
|
||||
fileName.c_str(),
|
||||
dataLength,
|
||||
result->progress,
|
||||
result->size
|
||||
);
|
||||
}
|
||||
|
||||
} else if (upload.status == UPLOAD_FILE_END) {
|
||||
if (Update.end(true)) {
|
||||
result->status = UpgradeStatus::SUCCESS;
|
||||
if (result->size > 0) {
|
||||
if (result->progress > result->size || (isFinal && result->progress < result->size)) {
|
||||
Update.end(false);
|
||||
result->status = UpgradeStatus::SIZE_MISMATCH;
|
||||
|
||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), F("File '%s': finish"), upload.filename.c_str());
|
||||
|
||||
} else {
|
||||
Log.serrorln(
|
||||
FPSTR(L_PORTAL_OTA), "File '%s', size mismatch: %d of %d bytes",
|
||||
fileName.c_str(),
|
||||
result->progress,
|
||||
result->size
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFinal) {
|
||||
if (!Update.end(true)) {
|
||||
result->status = UpgradeStatus::ERROR_ON_FINISH;
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
result->error = Update.getErrorString();
|
||||
#else
|
||||
result->error = Update.errorString();
|
||||
#endif
|
||||
|
||||
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s', on finish: %s"), upload.filename.c_str(), result->error);
|
||||
Log.serrorln(FPSTR(L_PORTAL_OTA), "File '%s', on finish: %s", fileName.c_str(), result->error);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (upload.status == UPLOAD_FILE_ABORTED) {
|
||||
Update.end(false);
|
||||
result->status = UpgradeStatus::ABORTED;
|
||||
|
||||
Log.serrorln(FPSTR(L_PORTAL_OTA), F("File '%s': aborted"), upload.filename.c_str());
|
||||
result->status = UpgradeStatus::SUCCESS;
|
||||
Log.sinfoln(FPSTR(L_PORTAL_OTA), "File '%s': finish", fileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool isRequestHandlerTrivial() const override final {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
CanHandleCallback canHandleCallback;
|
||||
CanUploadCallback canUploadCallback;
|
||||
BeforeUpgradeCallback beforeUpgradeCallback;
|
||||
AfterUpgradeCallback afterUpgradeCallback;
|
||||
const char* uri = nullptr;
|
||||
AsyncURIMatcher uri;
|
||||
|
||||
UpgradeResult firmwareResult{UpgradeType::FIRMWARE, UpgradeStatus::NONE};
|
||||
UpgradeResult filesystemResult{UpgradeType::FILESYSTEM, UpgradeStatus::NONE};
|
||||
|
||||
@@ -17,16 +17,20 @@ core_dir = .pio
|
||||
version = 1.6.0
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
ESP32Async/AsyncTCP
|
||||
;ESP32Async/ESPAsyncWebServer
|
||||
https://github.com/ESP32Async/ESPAsyncWebServer#main
|
||||
mathieucarbou/MycilaWebSerial@^8.2.0
|
||||
bblanchon/ArduinoJson@^7.4.2
|
||||
;ihormelnyk/OpenTherm Library@^1.1.5
|
||||
https://github.com/Laxilef/opentherm_library#esp32_timer
|
||||
arduino-libraries/ArduinoMqttClient@^0.1.8
|
||||
lennarthennigs/ESP Telnet@^2.2.3
|
||||
gyverlibs/FileData@^1.0.3
|
||||
gyverlibs/GyverPID@^3.3.2
|
||||
gyverlibs/GyverBlinker@^1.1.1
|
||||
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
|
||||
laxilef/TinyLogger@^1.1.1
|
||||
;laxilef/TinyLogger@^1.1.1
|
||||
https://github.com/Laxilef/TinyLogger#custom_handlers
|
||||
build_type = ${secrets.build_type}
|
||||
build_flags =
|
||||
-mtext-section-literals
|
||||
@@ -34,10 +38,13 @@ build_flags =
|
||||
;-D DEBUG_ESP_CORE -D DEBUG_ESP_WIFI -D DEBUG_ESP_HTTP_SERVER -D DEBUG_ESP_PORT=Serial
|
||||
-D BUILD_VERSION='"${this.version}"'
|
||||
-D BUILD_ENV='"$PIOENV"'
|
||||
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
|
||||
-D ARDUINOJSON_USE_DOUBLE=0
|
||||
-D ARDUINOJSON_USE_LONG_LONG=0
|
||||
-D TINYLOGGER_GLOBAL
|
||||
-D DEFAULT_SERIAL_ENABLED=${secrets.serial_enabled}
|
||||
-D DEFAULT_SERIAL_BAUD=${secrets.serial_baud}
|
||||
-D DEFAULT_TELNET_ENABLED=${secrets.telnet_enabled}
|
||||
-D DEFAULT_TELNET_PORT=${secrets.telnet_port}
|
||||
-D DEFAULT_WEBSERIAL_ENABLED=${secrets.webserial_enabled}
|
||||
-D DEFAULT_LOG_LEVEL=${secrets.log_level}
|
||||
-D DEFAULT_HOSTNAME='"${secrets.hostname}"'
|
||||
-D DEFAULT_AP_SSID='"${secrets.ap_ssid}"'
|
||||
@@ -92,13 +99,13 @@ check_flags = ${env.check_flags}
|
||||
;platform_packages =
|
||||
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
|
||||
; framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip
|
||||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip
|
||||
platform_packages = ${env.platform_packages}
|
||||
board_build.partitions = esp32_partitions.csv
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
laxilef/ESP32Scheduler@^1.0.1
|
||||
nimble_lib = h2zero/NimBLE-Arduino@2.3.7
|
||||
nimble_lib = https://github.com/h2zero/NimBLE-Arduino
|
||||
lib_ignore =
|
||||
extra_scripts =
|
||||
post:tools/esp32.py
|
||||
|
||||
@@ -3,8 +3,7 @@ build_type = release
|
||||
|
||||
serial_enabled = true
|
||||
serial_baud = 115200
|
||||
telnet_enabled = true
|
||||
telnet_port = 23
|
||||
webserial_enabled = true
|
||||
log_level = 5
|
||||
hostname = opentherm
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ extern NetworkMgr* network;
|
||||
extern MqttTask* tMqtt;
|
||||
extern OpenThermTask* tOt;
|
||||
extern FileData fsNetworkSettings, fsSettings, fsSensorsSettings;
|
||||
extern ESPTelnetStream* telnetStream;
|
||||
|
||||
|
||||
class MainTask : public Task {
|
||||
@@ -40,7 +39,6 @@ protected:
|
||||
PumpStartReason extPumpStartReason = PumpStartReason::NONE;
|
||||
unsigned long externalPumpStartTime = 0;
|
||||
bool ntpStarted = false;
|
||||
bool telnetStarted = false;
|
||||
bool emergencyDetected = false;
|
||||
unsigned long emergencyFlipTime = 0;
|
||||
bool freezeDetected = false;
|
||||
@@ -106,9 +104,9 @@ protected:
|
||||
vars.network.connected = network->isConnected();
|
||||
vars.network.rssi = network->isConnected() ? WiFi.RSSI() : 0;
|
||||
|
||||
if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) {
|
||||
if (settings.system.logLevel >= TinyLoggerLevel::SILENT && settings.system.logLevel <= TinyLoggerLevel::VERBOSE) {
|
||||
if (Log.getLevel() != settings.system.logLevel) {
|
||||
Log.setLevel(static_cast<TinyLogger::Level>(settings.system.logLevel));
|
||||
Log.setLevel(static_cast<TinyLoggerLevel>(settings.system.logLevel));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,11 +121,6 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->telnetStarted && telnetStream != nullptr) {
|
||||
telnetStream->begin(23, false);
|
||||
this->telnetStarted = true;
|
||||
}
|
||||
|
||||
if (settings.mqtt.enabled && !tMqtt->isEnabled()) {
|
||||
tMqtt->enable();
|
||||
|
||||
@@ -142,11 +135,6 @@ protected:
|
||||
this->ntpStarted = false;
|
||||
}
|
||||
|
||||
if (this->telnetStarted) {
|
||||
telnetStream->stop();
|
||||
this->telnetStarted = false;
|
||||
}
|
||||
|
||||
if (tMqtt->isEnabled()) {
|
||||
tMqtt->disable();
|
||||
}
|
||||
@@ -160,23 +148,10 @@ protected:
|
||||
}
|
||||
this->ledStatus();
|
||||
|
||||
// telnet
|
||||
if (this->telnetStarted) {
|
||||
this->yield();
|
||||
telnetStream->loop();
|
||||
this->yield();
|
||||
}
|
||||
|
||||
|
||||
// anti memory leak
|
||||
for (Stream* stream : Log.getStreams()) {
|
||||
while (stream->available() > 0) {
|
||||
stream->read();
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::optimistic_yield(1000);
|
||||
#endif
|
||||
}
|
||||
while (Serial.available() > 0) {
|
||||
Serial.read();
|
||||
}
|
||||
|
||||
// heap info
|
||||
@@ -215,7 +190,7 @@ protected:
|
||||
vars.states.restarting = true;
|
||||
}
|
||||
|
||||
if (settings.system.logLevel < TinyLogger::Level::VERBOSE) {
|
||||
if (settings.system.logLevel < TinyLoggerLevel::VERBOSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,7 +294,7 @@ protected:
|
||||
emergencyFlags |= 0b00000010;
|
||||
}
|
||||
|
||||
if (settings.opentherm.options.nativeHeatingControl) {
|
||||
if (settings.opentherm.options.nativeOTC) {
|
||||
emergencyFlags |= 0b00000100;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.system.logLevel >= TinyLogger::Level::TRACE) {
|
||||
if (settings.system.logLevel >= TinyLoggerLevel::TRACE) {
|
||||
Log.strace(FPSTR(L_MQTT_MSG), F("Topic: %s\r\n> "), topic.c_str());
|
||||
if (Log.lock()) {
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
|
||||
@@ -171,7 +171,7 @@ protected:
|
||||
vars.master.heating.enabled = this->isReady()
|
||||
&& settings.heating.enabled
|
||||
&& vars.cascadeControl.input
|
||||
&& (!vars.master.heating.blocking || settings.heating.hysteresis.action != HysteresisAction::DISABLE_HEATING)
|
||||
&& !vars.master.heating.blocking
|
||||
&& !vars.master.heating.overheat;
|
||||
|
||||
// DHW settings
|
||||
@@ -186,7 +186,9 @@ protected:
|
||||
|| (settings.opentherm.options.dhwToCh2 && settings.opentherm.options.dhwSupport && settings.dhw.enabled);
|
||||
|
||||
if (settings.opentherm.options.heatingToCh2) {
|
||||
vars.master.ch2.targetTemp = vars.master.heating.setpointTemp;
|
||||
vars.master.ch2.targetTemp = !settings.opentherm.options.nativeOTC
|
||||
? vars.master.heating.setpointTemp
|
||||
: vars.master.heating.targetTemp;
|
||||
|
||||
} else if (settings.opentherm.options.dhwToCh2) {
|
||||
vars.master.ch2.targetTemp = vars.master.dhw.targetTemp;
|
||||
@@ -218,7 +220,7 @@ protected:
|
||||
vars.master.heating.enabled,
|
||||
vars.master.dhw.enabled,
|
||||
settings.opentherm.options.coolingSupport,
|
||||
settings.opentherm.options.nativeHeatingControl,
|
||||
settings.opentherm.options.nativeOTC,
|
||||
vars.master.ch2.enabled,
|
||||
summerWinterMode,
|
||||
dhwBlocking,
|
||||
@@ -305,6 +307,7 @@ protected:
|
||||
Sensors::setConnectionStatusByType(Sensors::Type::OT_DHW_BURNER_HOURS, false);
|
||||
Sensors::setConnectionStatusByType(Sensors::Type::OT_HEATING_PUMP_HOURS, false);
|
||||
Sensors::setConnectionStatusByType(Sensors::Type::OT_DHW_PUMP_HOURS, false);
|
||||
Sensors::setConnectionStatusByType(Sensors::Type::OT_COOLING_HOURS, false);
|
||||
|
||||
this->initialized = false;
|
||||
this->disconnectedTime = millis();
|
||||
@@ -677,6 +680,21 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// Update cooling hours
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_COOLING_HOURS, true)) {
|
||||
if (this->updateCoolingHours()) {
|
||||
Log.snoticeln(FPSTR(L_OT), F("Received cooling hours: %hu"), vars.slave.stats.coolingHours);
|
||||
|
||||
Sensors::setValueByType(
|
||||
Sensors::Type::OT_COOLING_HOURS, vars.slave.stats.coolingHours,
|
||||
Sensors::ValueType::PRIMARY, true, true
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT), F("Failed receive cooling hours"));
|
||||
}
|
||||
}
|
||||
|
||||
// Auto fault reset
|
||||
if (settings.opentherm.options.autoFaultReset && vars.slave.fault.active && !vars.actions.resetFault) {
|
||||
vars.actions.resetFault = true;
|
||||
@@ -792,7 +810,7 @@ protected:
|
||||
bool result = this->updateDhwTemp();
|
||||
|
||||
if (result) {
|
||||
float convertedDhwTemp = convertTemp(
|
||||
const float convertedDhwTemp = convertTemp(
|
||||
vars.slave.dhw.currentTemp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -816,7 +834,7 @@ protected:
|
||||
// Update DHW temp 2
|
||||
if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_TEMP2, true)) {
|
||||
if (this->updateDhwTemp2()) {
|
||||
float convertedDhwTemp2 = convertTemp(
|
||||
const float convertedDhwTemp2 = convertTemp(
|
||||
vars.slave.dhw.currentTemp2,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -840,7 +858,7 @@ protected:
|
||||
// Update DHW flow rate
|
||||
if (settings.opentherm.options.dhwSupport && Sensors::getAmountByType(Sensors::Type::OT_DHW_FLOW_RATE, true)) {
|
||||
if (this->updateDhwFlowRate()) {
|
||||
float convertedDhwFlowRate = convertVolume(
|
||||
const float convertedDhwFlowRate = convertVolume(
|
||||
vars.slave.dhw.flowRate,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -864,7 +882,7 @@ protected:
|
||||
// Update heating temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_TEMP, true)) {
|
||||
if (this->updateHeatingTemp()) {
|
||||
float convertedHeatingTemp = convertTemp(
|
||||
const float convertedHeatingTemp = convertTemp(
|
||||
vars.slave.heating.currentTemp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -888,7 +906,7 @@ protected:
|
||||
// Update heating return temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_HEATING_RETURN_TEMP, true)) {
|
||||
if (this->updateHeatingReturnTemp()) {
|
||||
float convertedHeatingReturnTemp = convertTemp(
|
||||
const float convertedHeatingReturnTemp = convertTemp(
|
||||
vars.slave.heating.returnTemp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -911,9 +929,9 @@ protected:
|
||||
|
||||
// Update CH2 temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_CH2_TEMP, true)) {
|
||||
if (vars.master.ch2.enabled && !settings.opentherm.options.nativeHeatingControl) {
|
||||
if (vars.master.ch2.enabled && !settings.opentherm.options.nativeOTC) {
|
||||
if (this->updateCh2Temp()) {
|
||||
float convertedCh2Temp = convertTemp(
|
||||
const float convertedCh2Temp = convertTemp(
|
||||
vars.slave.ch2.currentTemp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -938,7 +956,7 @@ protected:
|
||||
// Update exhaust temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_EXHAUST_TEMP, true)) {
|
||||
if (this->updateExhaustTemp()) {
|
||||
float convertedExhaustTemp = convertTemp(
|
||||
const float convertedExhaustTemp = convertTemp(
|
||||
vars.slave.exhaust.temp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -962,7 +980,7 @@ protected:
|
||||
// Update heat exchanger temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_HEAT_EXCHANGER_TEMP, true)) {
|
||||
if (this->updateHeatExchangerTemp()) {
|
||||
float convertedHeatExchTemp = convertTemp(
|
||||
const float convertedHeatExchTemp = convertTemp(
|
||||
vars.slave.heatExchangerTemp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -986,7 +1004,7 @@ protected:
|
||||
// Update outdoor temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_OUTDOOR_TEMP, true)) {
|
||||
if (this->updateOutdoorTemp()) {
|
||||
float convertedOutdoorTemp = convertTemp(
|
||||
const float convertedOutdoorTemp = convertTemp(
|
||||
vars.slave.heating.outdoorTemp,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -1010,7 +1028,7 @@ protected:
|
||||
// Update solar storage temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_STORAGE_TEMP, true)) {
|
||||
if (this->updateSolarStorageTemp()) {
|
||||
float convertedSolarStorageTemp = convertTemp(
|
||||
const float convertedSolarStorageTemp = convertTemp(
|
||||
vars.slave.solar.storage,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -1034,7 +1052,7 @@ protected:
|
||||
// Update solar collector temp
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_SOLAR_COLLECTOR_TEMP, true)) {
|
||||
if (this->updateSolarCollectorTemp()) {
|
||||
float convertedSolarCollectorTemp = convertTemp(
|
||||
const float convertedSolarCollectorTemp = convertTemp(
|
||||
vars.slave.solar.collector,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -1080,7 +1098,7 @@ protected:
|
||||
// Update pressure
|
||||
if (Sensors::getAmountByType(Sensors::Type::OT_PRESSURE, true)) {
|
||||
if (this->updatePressure()) {
|
||||
float convertedPressure = convertPressure(
|
||||
const float convertedPressure = convertPressure(
|
||||
vars.slave.pressure,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
@@ -1186,9 +1204,12 @@ protected:
|
||||
|
||||
// Update DHW temp
|
||||
if (vars.master.dhw.enabled) {
|
||||
// Target dhw temp
|
||||
const float& targetTemp = vars.master.dhw.targetTemp;
|
||||
|
||||
// Converted target dhw temp
|
||||
float convertedTemp = convertTemp(
|
||||
vars.master.dhw.targetTemp,
|
||||
const float convertedTemp = convertTemp(
|
||||
targetTemp,
|
||||
settings.system.unitSystem,
|
||||
settings.opentherm.unitSystem
|
||||
);
|
||||
@@ -1200,7 +1221,7 @@ protected:
|
||||
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_DHW), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.dhw.targetTemp, convertedTemp, vars.slave.dhw.targetTemp
|
||||
targetTemp, convertedTemp, vars.slave.dhw.targetTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
@@ -1209,16 +1230,19 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// Set indoor temp for Native heating control/Always set indoor temp
|
||||
if (settings.opentherm.options.nativeHeatingControl || settings.opentherm.options.alwaysSetIndoorTemp) {
|
||||
// Send indoor temp if AlwaysSendIndoorTemp option is enabled.
|
||||
if (settings.opentherm.options.nativeOTC || settings.opentherm.options.alwaysSendIndoorTemp) {
|
||||
// Current indoor temp
|
||||
const float& indoorTemp = vars.master.heating.indoorTemp;
|
||||
|
||||
// Converted current indoor temp
|
||||
float convertedTemp = convertTemp(vars.master.heating.indoorTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
|
||||
const float convertedTemp = convertTemp(indoorTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
|
||||
|
||||
// Set current indoor temp
|
||||
if (this->setRoomTemp(convertedTemp)) {
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_HEATING), F("Set current indoor temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.heating.indoorTemp, convertedTemp, vars.slave.heating.indoorTemp
|
||||
indoorTemp, convertedTemp, vars.slave.heating.indoorTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
@@ -1230,7 +1254,7 @@ protected:
|
||||
if (this->setRoomTempCh2(convertedTemp)) {
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_HEATING), F("Set current CH2 indoor temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.heating.indoorTemp, convertedTemp, vars.slave.ch2.indoorTemp
|
||||
indoorTemp, convertedTemp, vars.slave.ch2.indoorTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
@@ -1239,11 +1263,17 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// NativeOTC
|
||||
if (settings.opentherm.options.nativeOTC) {
|
||||
// Target indoor temp
|
||||
const float& targetTemp = vars.master.heating.targetTemp;
|
||||
|
||||
// Native heating control
|
||||
if (settings.opentherm.options.nativeHeatingControl) {
|
||||
// Converted target indoor temp
|
||||
float convertedTemp = convertTemp(vars.master.heating.targetTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
|
||||
const float convertedTemp = convertTemp(
|
||||
targetTemp,
|
||||
settings.system.unitSystem,
|
||||
settings.opentherm.unitSystem
|
||||
);
|
||||
|
||||
// Set target indoor temp
|
||||
if (this->needSetHeatingTemp(convertedTemp)) {
|
||||
@@ -1252,7 +1282,7 @@ protected:
|
||||
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_HEATING), F("Set target indoor temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.heating.targetTemp, convertedTemp, vars.slave.heating.targetTemp
|
||||
targetTemp, convertedTemp, vars.slave.heating.targetTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
@@ -1267,7 +1297,7 @@ protected:
|
||||
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_HEATING), F("Set target CH2 indoor temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.heating.targetTemp, convertedTemp, vars.slave.ch2.targetTemp
|
||||
targetTemp, convertedTemp, vars.slave.ch2.targetTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
@@ -1276,10 +1306,22 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// Normal heating control
|
||||
if (!settings.opentherm.options.nativeHeatingControl && vars.master.heating.enabled) {
|
||||
// Set heating temp
|
||||
{
|
||||
// Target heating temp
|
||||
float targetTemp = 0.0f;
|
||||
if (vars.master.heating.enabled) {
|
||||
targetTemp = !settings.opentherm.options.nativeOTC
|
||||
? vars.master.heating.setpointTemp
|
||||
: vars.master.heating.targetTemp;
|
||||
}
|
||||
|
||||
// Converted target heating temp
|
||||
float convertedTemp = convertTemp(vars.master.heating.setpointTemp, settings.system.unitSystem, settings.opentherm.unitSystem);
|
||||
const float convertedTemp = convertTemp(
|
||||
targetTemp,
|
||||
settings.system.unitSystem,
|
||||
settings.opentherm.unitSystem
|
||||
);
|
||||
|
||||
if (this->needSetHeatingTemp(convertedTemp)) {
|
||||
// Set max heating temp
|
||||
@@ -1287,13 +1329,13 @@ protected:
|
||||
if (this->setMaxHeatingTemp(convertedTemp)) {
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_HEATING), F("Set max heating temp: %.2f (converted: %.2f)"),
|
||||
vars.master.heating.setpointTemp, convertedTemp
|
||||
targetTemp, convertedTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.swarningln(
|
||||
FPSTR(L_OT_HEATING), F("Failed set max heating temp: %.2f (converted: %.2f)"),
|
||||
vars.master.heating.setpointTemp, convertedTemp
|
||||
targetTemp, convertedTemp
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1304,7 +1346,7 @@ protected:
|
||||
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_HEATING), F("Set target temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.heating.setpointTemp, convertedTemp, vars.slave.heating.targetTemp
|
||||
targetTemp, convertedTemp, vars.slave.heating.targetTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
@@ -1314,27 +1356,30 @@ protected:
|
||||
}
|
||||
|
||||
// Set CH2 temp
|
||||
if (!settings.opentherm.options.nativeHeatingControl && vars.master.ch2.enabled) {
|
||||
if (settings.opentherm.options.heatingToCh2 || settings.opentherm.options.dhwToCh2) {
|
||||
// Converted target CH2 temp
|
||||
float convertedTemp = convertTemp(
|
||||
vars.master.ch2.targetTemp,
|
||||
settings.system.unitSystem,
|
||||
settings.opentherm.unitSystem
|
||||
);
|
||||
if (settings.opentherm.options.heatingToCh2 || settings.opentherm.options.dhwToCh2) {
|
||||
// Target CH2 heating temp
|
||||
const float targetTemp = vars.master.ch2.enabled
|
||||
? vars.master.ch2.targetTemp
|
||||
: 0.0f;
|
||||
|
||||
if (this->needSetCh2Temp(convertedTemp)) {
|
||||
if (this->setCh2Temp(convertedTemp)) {
|
||||
this->ch2SetTempTime = millis();
|
||||
// Converted target CH2 temp
|
||||
const float convertedTemp = convertTemp(
|
||||
targetTemp,
|
||||
settings.system.unitSystem,
|
||||
settings.opentherm.unitSystem
|
||||
);
|
||||
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_CH2), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
vars.master.ch2.targetTemp, convertedTemp, vars.slave.ch2.targetTemp
|
||||
);
|
||||
if (this->needSetCh2Temp(convertedTemp)) {
|
||||
if (this->setCh2Temp(convertedTemp)) {
|
||||
this->ch2SetTempTime = millis();
|
||||
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT_CH2), F("Failed set temp"));
|
||||
}
|
||||
Log.sinfoln(
|
||||
FPSTR(L_OT_CH2), F("Set temp: %.2f (converted: %.2f, response: %.2f)"),
|
||||
targetTemp, convertedTemp, vars.slave.ch2.targetTemp
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT_CH2), F("Failed set temp"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1342,7 +1387,7 @@ protected:
|
||||
|
||||
// Heating overheat control
|
||||
if (settings.heating.overheatProtection.highTemp > 0 && settings.heating.overheatProtection.lowTemp > 0) {
|
||||
float highTemp = convertTemp(
|
||||
const float highTemp = convertTemp(
|
||||
max({
|
||||
vars.slave.heating.currentTemp,
|
||||
vars.slave.heating.returnTemp,
|
||||
@@ -1379,7 +1424,7 @@ protected:
|
||||
|
||||
// DHW overheat control
|
||||
if (settings.dhw.overheatProtection.highTemp > 0 && settings.dhw.overheatProtection.lowTemp > 0) {
|
||||
float highTemp = convertTemp(
|
||||
const float highTemp = convertTemp(
|
||||
max({
|
||||
vars.slave.heating.currentTemp,
|
||||
vars.slave.heating.returnTemp,
|
||||
@@ -1473,6 +1518,19 @@ protected:
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT), F("Failed set master config"));
|
||||
}
|
||||
|
||||
/*char buf[100];
|
||||
if (this->instance->getStr(OpenThermMessageID::Brand, buf, sizeof(buf) - 1)) {
|
||||
Log.snoticeln(FPSTR(L_OT), F("Slave brand: %s"), buf);
|
||||
}
|
||||
|
||||
if (this->instance->getStr(OpenThermMessageID::BrandVersion, buf, sizeof(buf) - 1)) {
|
||||
Log.snoticeln(FPSTR(L_OT), F("Slave brand version: %s"), buf);
|
||||
}
|
||||
|
||||
if (this->instance->getStr(OpenThermMessageID::BrandSerialNumber, buf, sizeof(buf) - 1)) {
|
||||
Log.snoticeln(FPSTR(L_OT), F("Slave brand s/n: %s"), buf);
|
||||
}*/
|
||||
}
|
||||
|
||||
bool isReady() {
|
||||
@@ -1650,7 +1708,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
bool setRoomTemp(float temperature) {
|
||||
bool setRoomTemp(const float temperature) {
|
||||
const unsigned int request = CustomOpenTherm::temperatureToData(temperature);
|
||||
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
|
||||
OpenThermMessageType::WRITE_DATA,
|
||||
@@ -1670,7 +1728,7 @@ protected:
|
||||
return CustomOpenTherm::getUInt(response) == request;
|
||||
}
|
||||
|
||||
bool setRoomTempCh2(float temperature) {
|
||||
bool setRoomTempCh2(const float temperature) {
|
||||
const unsigned int request = CustomOpenTherm::temperatureToData(temperature);
|
||||
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
|
||||
OpenThermMessageType::WRITE_DATA,
|
||||
@@ -2172,6 +2230,25 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool updateCoolingHours() {
|
||||
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
|
||||
OpenThermRequestType::READ_DATA,
|
||||
OpenThermMessageID::CoolingOperationHours,
|
||||
0
|
||||
));
|
||||
|
||||
if (!CustomOpenTherm::isValidResponse(response)) {
|
||||
return false;
|
||||
|
||||
} else if (!CustomOpenTherm::isValidResponseId(response, OpenThermMessageID::CoolingOperationHours)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vars.slave.stats.coolingHours = CustomOpenTherm::getUInt(response);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool updateModulationLevel() {
|
||||
const unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
|
||||
OpenThermRequestType::READ_DATA,
|
||||
@@ -2186,7 +2263,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = CustomOpenTherm::getFloat(response);
|
||||
const float value = CustomOpenTherm::getFloat(response);
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -2210,7 +2287,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = CustomOpenTherm::getFloat(response);
|
||||
const float value = CustomOpenTherm::getFloat(response);
|
||||
if (value <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -2234,7 +2311,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = CustomOpenTherm::getFloat(response);
|
||||
const float value = CustomOpenTherm::getFloat(response);
|
||||
if (value <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -2288,7 +2365,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = CustomOpenTherm::getFloat(response);
|
||||
const float value = CustomOpenTherm::getFloat(response);
|
||||
if (value <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -2352,7 +2429,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = (float) CustomOpenTherm::getInt(response);
|
||||
const float value = (float) CustomOpenTherm::getInt(response);
|
||||
if (!isValidTemp(value, settings.opentherm.unitSystem, -40, 500)) {
|
||||
return false;
|
||||
}
|
||||
@@ -2376,7 +2453,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = (float) CustomOpenTherm::getInt(response);
|
||||
const float value = (float) CustomOpenTherm::getInt(response);
|
||||
if (value <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -2477,7 +2554,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
float value = CustomOpenTherm::getFloat(response);
|
||||
const float value = CustomOpenTherm::getFloat(response);
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
855
src/PortalTask.h
855
src/PortalTask.h
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@ protected:
|
||||
this->indoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::INDOOR_TEMP);
|
||||
//this->outdoorSensorsConnected = Sensors::existsConnectedSensorsByPurpose(Sensors::Purpose::OUTDOOR_TEMP);
|
||||
|
||||
if (settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl) {
|
||||
if (settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeOTC) {
|
||||
vars.master.heating.indoorTempControl = true;
|
||||
vars.master.heating.minTemp = THERMOSTAT_INDOOR_MIN_TEMP;
|
||||
vars.master.heating.maxTemp = THERMOSTAT_INDOOR_MAX_TEMP;
|
||||
@@ -57,23 +57,12 @@ protected:
|
||||
this->turbo();
|
||||
this->hysteresis();
|
||||
|
||||
if (vars.master.heating.blocking && settings.heating.hysteresis.action == HysteresisAction::SET_ZERO_TARGET) {
|
||||
vars.master.heating.targetTemp = 0.0f;
|
||||
vars.master.heating.setpointTemp = 0.0f;
|
||||
|
||||
// tick if PID enabled
|
||||
if (settings.pid.enabled) {
|
||||
this->getHeatingSetpointTemp();
|
||||
}
|
||||
|
||||
} else {
|
||||
vars.master.heating.targetTemp = settings.heating.target;
|
||||
vars.master.heating.setpointTemp = roundf(constrain(
|
||||
this->getHeatingSetpointTemp(),
|
||||
this->getHeatingMinSetpointTemp(),
|
||||
this->getHeatingMaxSetpointTemp()
|
||||
), 0);
|
||||
}
|
||||
vars.master.heating.targetTemp = settings.heating.target;
|
||||
vars.master.heating.setpointTemp = roundf(constrain(
|
||||
this->getHeatingSetpointTemp(),
|
||||
this->getHeatingMinSetpointTemp(),
|
||||
this->getHeatingMaxSetpointTemp()
|
||||
), 0);
|
||||
|
||||
Sensors::setValueByType(
|
||||
Sensors::Type::HEATING_SETPOINT_TEMP, vars.master.heating.setpointTemp,
|
||||
@@ -102,7 +91,7 @@ protected:
|
||||
void hysteresis() {
|
||||
bool useHyst = false;
|
||||
if (settings.heating.hysteresis.enabled && this->indoorSensorsConnected) {
|
||||
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeHeatingControl;
|
||||
useHyst = settings.equitherm.enabled || settings.pid.enabled || settings.opentherm.options.nativeOTC;
|
||||
}
|
||||
|
||||
if (useHyst) {
|
||||
@@ -119,13 +108,13 @@ protected:
|
||||
}
|
||||
|
||||
inline float getHeatingMinSetpointTemp() {
|
||||
return settings.opentherm.options.nativeHeatingControl
|
||||
return settings.opentherm.options.nativeOTC
|
||||
? vars.master.heating.minTemp
|
||||
: settings.heating.minTemp;
|
||||
}
|
||||
|
||||
inline float getHeatingMaxSetpointTemp() {
|
||||
return settings.opentherm.options.nativeHeatingControl
|
||||
return settings.opentherm.options.nativeOTC
|
||||
? vars.master.heating.maxTemp
|
||||
: settings.heating.maxTemp;
|
||||
}
|
||||
@@ -146,7 +135,7 @@ protected:
|
||||
if (vars.emergency.state) {
|
||||
return settings.emergency.target;
|
||||
|
||||
} else if (settings.opentherm.options.nativeHeatingControl) {
|
||||
} else if (settings.opentherm.options.nativeOTC) {
|
||||
return settings.heating.target;
|
||||
|
||||
} else if (!settings.equitherm.enabled && !settings.pid.enabled) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
OT_DHW_BURNER_HOURS = 24,
|
||||
OT_HEATING_PUMP_HOURS = 25,
|
||||
OT_DHW_PUMP_HOURS = 26,
|
||||
OT_COOLING_HOURS = 27,
|
||||
|
||||
NTC_10K_TEMP = 50,
|
||||
DALLAS_TEMP = 51,
|
||||
|
||||
@@ -32,9 +32,8 @@ struct Settings {
|
||||
} serial;
|
||||
|
||||
struct {
|
||||
bool enabled = DEFAULT_TELNET_ENABLED;
|
||||
unsigned short port = DEFAULT_TELNET_PORT;
|
||||
} telnet;
|
||||
bool enabled = DEFAULT_WEBSERIAL_ENABLED;
|
||||
} webSerial;
|
||||
|
||||
struct {
|
||||
char server[49] = "pool.ntp.org";
|
||||
@@ -78,8 +77,8 @@ struct Settings {
|
||||
bool autoFaultReset = false;
|
||||
bool autoDiagReset = false;
|
||||
bool setDateAndTime = false;
|
||||
bool alwaysSetIndoorTemp = true;
|
||||
bool nativeHeatingControl = false;
|
||||
bool alwaysSendIndoorTemp = true;
|
||||
bool nativeOTC = false;
|
||||
bool immergasFix = false;
|
||||
} options;
|
||||
} opentherm;
|
||||
@@ -389,6 +388,7 @@ struct Variables {
|
||||
uint16_t dhwBurnerStarts = 0;
|
||||
uint16_t heatingPumpStarts = 0;
|
||||
uint16_t dhwPumpStarts = 0;
|
||||
uint16_t coolingHours = 0;
|
||||
uint16_t burnerHours = 0;
|
||||
uint16_t dhwBurnerHours = 0;
|
||||
uint16_t heatingPumpHours = 0;
|
||||
|
||||
@@ -42,12 +42,8 @@
|
||||
#define DEFAULT_SERIAL_BAUD 115200
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_TELNET_ENABLED
|
||||
#define DEFAULT_TELNET_ENABLED true
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_TELNET_PORT
|
||||
#define DEFAULT_TELNET_PORT 23
|
||||
#ifndef DEFAULT_WEBSERIAL_ENABLED
|
||||
#define DEFAULT_WEBSERIAL_ENABLED true
|
||||
#endif
|
||||
|
||||
#ifndef USE_BLE
|
||||
@@ -75,7 +71,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_LOG_LEVEL
|
||||
#define DEFAULT_LOG_LEVEL TinyLogger::Level::VERBOSE
|
||||
#define DEFAULT_LOG_LEVEL TinyLoggerLevel::VERBOSE
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_STATUS_LED_GPIO
|
||||
|
||||
31
src/main.cpp
31
src/main.cpp
@@ -1,11 +1,8 @@
|
||||
#define ARDUINOJSON_USE_DOUBLE 0
|
||||
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <FileData.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ESPTelnetStream.h>
|
||||
#include <MycilaWebSerial.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "strings.h"
|
||||
@@ -37,7 +34,7 @@
|
||||
using namespace NetworkUtils;
|
||||
|
||||
// Vars
|
||||
ESPTelnetStream* telnetStream = nullptr;
|
||||
WebSerial* webSerial = nullptr;
|
||||
NetworkMgr* network = nullptr;
|
||||
Sensors::Result sensorsResults[SENSORS_AMOUNT];
|
||||
|
||||
@@ -61,7 +58,7 @@ void setup() {
|
||||
Sensors::results = sensorsResults;
|
||||
LittleFS.begin();
|
||||
|
||||
Log.setLevel(TinyLogger::Level::VERBOSE);
|
||||
Log.setLevel(TinyLoggerLevel::VERBOSE);
|
||||
Log.setServiceTemplate("\033[1m[%s]\033[22m");
|
||||
Log.setLevelTemplate("\033[1m[%s]\033[22m");
|
||||
Log.setMsgPrefix("\033[m ");
|
||||
@@ -79,7 +76,7 @@ void setup() {
|
||||
#if ARDUINO_USB_MODE
|
||||
Serial.setTxBufferSize(512);
|
||||
#endif
|
||||
Log.addStream(&Serial);
|
||||
Log.addHandler(&Serial);
|
||||
Log.print("\n\n\r");
|
||||
|
||||
//
|
||||
@@ -163,24 +160,24 @@ void setup() {
|
||||
// Logs settings
|
||||
if (!settings.system.serial.enabled) {
|
||||
Serial.end();
|
||||
Log.clearStreams();
|
||||
Log.clearHandlers();
|
||||
|
||||
} else if (settings.system.serial.baudrate != 115200) {
|
||||
Serial.end();
|
||||
Log.clearStreams();
|
||||
Log.clearHandlers();
|
||||
|
||||
Serial.begin(settings.system.serial.baudrate);
|
||||
Log.addStream(&Serial);
|
||||
Log.addHandler(&Serial);
|
||||
}
|
||||
|
||||
if (settings.system.telnet.enabled) {
|
||||
telnetStream = new ESPTelnetStream;
|
||||
telnetStream->setKeepAliveInterval(500);
|
||||
Log.addStream(telnetStream);
|
||||
if (settings.system.webSerial.enabled) {
|
||||
webSerial = new WebSerial();
|
||||
webSerial->setBuffer(100);
|
||||
Log.addHandler(webSerial);
|
||||
}
|
||||
|
||||
if (settings.system.logLevel >= TinyLogger::Level::SILENT && settings.system.logLevel <= TinyLogger::Level::VERBOSE) {
|
||||
Log.setLevel(static_cast<TinyLogger::Level>(settings.system.logLevel));
|
||||
if (settings.system.logLevel >= TinyLoggerLevel::SILENT && settings.system.logLevel <= TinyLoggerLevel::VERBOSE) {
|
||||
Log.setLevel(static_cast<TinyLoggerLevel>(settings.system.logLevel));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -216,7 +213,7 @@ void setup() {
|
||||
tRegulator = new RegulatorTask(true, 10000);
|
||||
Scheduler.start(tRegulator);
|
||||
|
||||
tPortal = new PortalTask(true, 0);
|
||||
tPortal = new PortalTask(true, 10);
|
||||
Scheduler.start(tPortal);
|
||||
|
||||
tMain = new MainTask(true, 100);
|
||||
|
||||
@@ -38,7 +38,6 @@ const char S_ACTION[] PROGMEM = "action";
|
||||
const char S_ACTIONS[] PROGMEM = "actions";
|
||||
const char S_ACTIVE[] PROGMEM = "active";
|
||||
const char S_ADDRESS[] PROGMEM = "address";
|
||||
const char S_ALWAYS_SET_INDOOR_TEMP[] PROGMEM = "alwaysSetIndoorTemp";
|
||||
const char S_ANTI_STUCK_INTERVAL[] PROGMEM = "antiStuckInterval";
|
||||
const char S_ANTI_STUCK_TIME[] PROGMEM = "antiStuckTime";
|
||||
const char S_AP[] PROGMEM = "ap";
|
||||
@@ -111,6 +110,7 @@ const char S_HYSTERESIS[] PROGMEM = "hysteresis";
|
||||
const char S_ID[] PROGMEM = "id";
|
||||
const char S_IGNORE_DIAG_STATE[] PROGMEM = "ignoreDiagState";
|
||||
const char S_IMMERGAS_FIX[] PROGMEM = "immergasFix";
|
||||
const char S_ALWAYS_SEND_INDOOR_TEMP[] PROGMEM = "alwaysSendIndoorTemp";
|
||||
const char S_INDOOR_TEMP[] PROGMEM = "indoorTemp";
|
||||
const char S_INDOOR_TEMP_CONTROL[] PROGMEM = "indoorTempControl";
|
||||
const char S_IN_GPIO[] PROGMEM = "inGpio";
|
||||
@@ -142,7 +142,7 @@ const char S_MODEL[] PROGMEM = "model";
|
||||
const char S_MODULATION[] PROGMEM = "modulation";
|
||||
const char S_MQTT[] PROGMEM = "mqtt";
|
||||
const char S_NAME[] PROGMEM = "name";
|
||||
const char S_NATIVE_HEATING_CONTROL[] PROGMEM = "nativeHeatingControl";
|
||||
const char S_NATIVE_OTC[] PROGMEM = "nativeOTC";
|
||||
const char S_NETWORK[] PROGMEM = "network";
|
||||
const char S_NTP[] PROGMEM = "ntp";
|
||||
const char S_OFFSET[] PROGMEM = "offset";
|
||||
@@ -165,6 +165,7 @@ const char S_POWER[] PROGMEM = "power";
|
||||
const char S_PREFIX[] PROGMEM = "prefix";
|
||||
const char S_PROTOCOL_VERSION[] PROGMEM = "protocolVersion";
|
||||
const char S_PURPOSE[] PROGMEM = "purpose";
|
||||
const char S_PSRAM[] PROGMEM = "psram";
|
||||
const char S_P_FACTOR[] PROGMEM = "p_factor";
|
||||
const char S_P_MULTIPLIER[] PROGMEM = "p_multiplier";
|
||||
const char S_REAL_SIZE[] PROGMEM = "realSize";
|
||||
@@ -201,7 +202,6 @@ const char S_SYSTEM[] PROGMEM = "system";
|
||||
const char S_TARGET[] PROGMEM = "target";
|
||||
const char S_TARGET_DIFF_FACTOR[] PROGMEM = "targetDiffFactor";
|
||||
const char S_TARGET_TEMP[] PROGMEM = "targetTemp";
|
||||
const char S_TELNET[] PROGMEM = "telnet";
|
||||
const char S_TEMPERATURE[] PROGMEM = "temperature";
|
||||
const char S_THRESHOLD_HIGH[] PROGMEM = "thresholdHigh";
|
||||
const char S_THRESHOLD_LOW[] PROGMEM = "thresholdLow";
|
||||
@@ -219,3 +219,4 @@ const char S_USE_DHCP[] PROGMEM = "useDhcp";
|
||||
const char S_USER[] PROGMEM = "user";
|
||||
const char S_VALUE[] PROGMEM = "value";
|
||||
const char S_VERSION[] PROGMEM = "version";
|
||||
const char S_WEBSERIAL[] PROGMEM = "webSerial";
|
||||
57
src/utils.h
57
src/utils.h
@@ -425,9 +425,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
serial[FPSTR(S_ENABLED)] = src.system.serial.enabled;
|
||||
serial[FPSTR(S_BAUDRATE)] = src.system.serial.baudrate;
|
||||
|
||||
auto telnet = system[FPSTR(S_TELNET)].to<JsonObject>();
|
||||
telnet[FPSTR(S_ENABLED)] = src.system.telnet.enabled;
|
||||
telnet[FPSTR(S_PORT)] = src.system.telnet.port;
|
||||
auto webSerial = system[FPSTR(S_WEBSERIAL)].to<JsonObject>();
|
||||
webSerial[FPSTR(S_ENABLED)] = src.system.webSerial.enabled;
|
||||
|
||||
auto ntp = system[FPSTR(S_NTP)].to<JsonObject>();
|
||||
ntp[FPSTR(S_SERVER)] = src.system.ntp.server;
|
||||
@@ -468,9 +467,10 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
otOptions[FPSTR(S_AUTO_FAULT_RESET)] = src.opentherm.options.autoFaultReset;
|
||||
otOptions[FPSTR(S_AUTO_DIAG_RESET)] = src.opentherm.options.autoDiagReset;
|
||||
otOptions[FPSTR(S_SET_DATE_AND_TIME)] = src.opentherm.options.setDateAndTime;
|
||||
otOptions[FPSTR(S_ALWAYS_SET_INDOOR_TEMP)] = src.opentherm.options.alwaysSetIndoorTemp;
|
||||
otOptions[FPSTR(S_NATIVE_HEATING_CONTROL)] = src.opentherm.options.nativeHeatingControl;
|
||||
otOptions[FPSTR(S_ALWAYS_SEND_INDOOR_TEMP)] = src.opentherm.options.alwaysSendIndoorTemp;
|
||||
otOptions[FPSTR(S_NATIVE_OTC)] = src.opentherm.options.nativeOTC;
|
||||
otOptions[FPSTR(S_IMMERGAS_FIX)] = src.opentherm.options.immergasFix;
|
||||
|
||||
|
||||
auto mqtt = dst[FPSTR(S_MQTT)].to<JsonObject>();
|
||||
mqtt[FPSTR(S_ENABLED)] = src.mqtt.enabled;
|
||||
@@ -580,7 +580,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
if (!src[FPSTR(S_SYSTEM)][FPSTR(S_LOG_LEVEL)].isNull()) {
|
||||
uint8_t value = src[FPSTR(S_SYSTEM)][FPSTR(S_LOG_LEVEL)].as<uint8_t>();
|
||||
|
||||
if (value != dst.system.logLevel && value >= TinyLogger::Level::SILENT && value <= TinyLogger::Level::VERBOSE) {
|
||||
if (value != dst.system.logLevel && value >= TinyLoggerLevel::SILENT && value <= TinyLoggerLevel::VERBOSE) {
|
||||
dst.system.logLevel = value;
|
||||
changed = true;
|
||||
}
|
||||
@@ -606,20 +606,11 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_ENABLED)].as<bool>();
|
||||
if (src[FPSTR(S_SYSTEM)][FPSTR(S_WEBSERIAL)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_SYSTEM)][FPSTR(S_WEBSERIAL)][FPSTR(S_ENABLED)].as<bool>();
|
||||
|
||||
if (value != dst.system.telnet.enabled) {
|
||||
dst.system.telnet.enabled = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_PORT)].isNull()) {
|
||||
unsigned short value = src[FPSTR(S_SYSTEM)][FPSTR(S_TELNET)][FPSTR(S_PORT)].as<unsigned short>();
|
||||
|
||||
if (value > 0 && value <= 65535 && value != dst.system.telnet.port) {
|
||||
dst.system.telnet.port = value;
|
||||
if (value != dst.system.webSerial.enabled) {
|
||||
dst.system.webSerial.enabled = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -1004,20 +995,20 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_ALWAYS_SET_INDOOR_TEMP)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_ALWAYS_SET_INDOOR_TEMP)].as<bool>();
|
||||
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_ALWAYS_SEND_INDOOR_TEMP)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_ALWAYS_SEND_INDOOR_TEMP)].as<bool>();
|
||||
|
||||
if (value != dst.opentherm.options.alwaysSetIndoorTemp) {
|
||||
dst.opentherm.options.alwaysSetIndoorTemp = value;
|
||||
if (value != dst.opentherm.options.alwaysSendIndoorTemp) {
|
||||
dst.opentherm.options.alwaysSendIndoorTemp = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_HEATING_CONTROL)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_HEATING_CONTROL)].as<bool>();
|
||||
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_OTC)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_NATIVE_OTC)].as<bool>();
|
||||
|
||||
if (value != dst.opentherm.options.nativeHeatingControl) {
|
||||
dst.opentherm.options.nativeHeatingControl = value;
|
||||
if (value != dst.opentherm.options.nativeOTC) {
|
||||
dst.opentherm.options.nativeOTC = value;
|
||||
|
||||
if (value) {
|
||||
dst.equitherm.enabled = false;
|
||||
@@ -1037,7 +1028,6 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mqtt
|
||||
if (src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_MQTT)][FPSTR(S_ENABLED)].as<bool>();
|
||||
@@ -1128,7 +1118,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
if (src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_EQUITHERM)][FPSTR(S_ENABLED)].as<bool>();
|
||||
|
||||
if (!dst.opentherm.options.nativeHeatingControl) {
|
||||
if (!dst.opentherm.options.nativeOTC) {
|
||||
if (value != dst.equitherm.enabled) {
|
||||
dst.equitherm.enabled = value;
|
||||
changed = true;
|
||||
@@ -1181,7 +1171,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
if (src[FPSTR(S_PID)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_PID)][FPSTR(S_ENABLED)].as<bool>();
|
||||
|
||||
if (!dst.opentherm.options.nativeHeatingControl) {
|
||||
if (!dst.opentherm.options.nativeOTC) {
|
||||
if (value != dst.pid.enabled) {
|
||||
dst.pid.enabled = value;
|
||||
changed = true;
|
||||
@@ -1714,7 +1704,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
// force check emergency target
|
||||
{
|
||||
float value = !src[FPSTR(S_EMERGENCY)][FPSTR(S_TARGET)].isNull() ? src[FPSTR(S_EMERGENCY)][FPSTR(S_TARGET)].as<float>() : dst.emergency.target;
|
||||
bool noRegulators = !dst.opentherm.options.nativeHeatingControl;
|
||||
bool noRegulators = !dst.opentherm.options.nativeOTC;
|
||||
bool valid = isValidTemp(
|
||||
value,
|
||||
dst.system.unitSystem,
|
||||
@@ -1739,7 +1729,7 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
|
||||
// force check heating target
|
||||
{
|
||||
bool indoorTempControl = dst.equitherm.enabled || dst.pid.enabled || dst.opentherm.options.nativeHeatingControl;
|
||||
bool indoorTempControl = dst.equitherm.enabled || dst.pid.enabled || dst.opentherm.options.nativeOTC;
|
||||
float minTemp = indoorTempControl ? THERMOSTAT_INDOOR_MIN_TEMP : dst.heating.minTemp;
|
||||
float maxTemp = indoorTempControl ? THERMOSTAT_INDOOR_MAX_TEMP : dst.heating.maxTemp;
|
||||
|
||||
@@ -1932,6 +1922,7 @@ bool jsonToSensorSettings(const uint8_t sensorId, const JsonVariantConst src, Se
|
||||
case static_cast<uint8_t>(Sensors::Type::OT_DHW_BURNER_HOURS):
|
||||
case static_cast<uint8_t>(Sensors::Type::OT_HEATING_PUMP_HOURS):
|
||||
case static_cast<uint8_t>(Sensors::Type::OT_DHW_PUMP_HOURS):
|
||||
case static_cast<uint8_t>(Sensors::Type::OT_COOLING_HOURS):
|
||||
|
||||
case static_cast<uint8_t>(Sensors::Type::NTC_10K_TEMP):
|
||||
case static_cast<uint8_t>(Sensors::Type::DALLAS_TEMP):
|
||||
@@ -2131,7 +2122,7 @@ void varsToJson(const Variables& src, JsonVariant dst) {
|
||||
slave[FPSTR(S_FLAGS)] = src.slave.flags;
|
||||
slave[FPSTR(S_TYPE)] = src.slave.type;
|
||||
slave[FPSTR(S_APP_VERSION)] = src.slave.appVersion;
|
||||
slave[FPSTR(S_PROTOCOL_VERSION)] = src.slave.appVersion;
|
||||
slave[FPSTR(S_PROTOCOL_VERSION)] = src.slave.protocolVersion;
|
||||
slave[FPSTR(S_CONNECTED)] = src.slave.connected;
|
||||
slave[FPSTR(S_FLAME)] = src.slave.flame;
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@
|
||||
"otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)",
|
||||
"otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)",
|
||||
"otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)",
|
||||
"otCoolingHours": "OpenTherm, number of cooling hours",
|
||||
|
||||
"ntcTemp": "NTC 传感器",
|
||||
"dallasTemp": "DALLAS 传感器",
|
||||
@@ -341,12 +342,8 @@
|
||||
"enable": "启用串口",
|
||||
"baud": "串口波特率"
|
||||
},
|
||||
"telnet": {
|
||||
"enable": "启用 Telnet",
|
||||
"port": {
|
||||
"title": "Telnet 端口",
|
||||
"note": "默认值:23"
|
||||
}
|
||||
"webSerial": {
|
||||
"enable": "启用 WebSerial"
|
||||
},
|
||||
"ntp": {
|
||||
"server": "NTP服务器",
|
||||
@@ -457,12 +454,13 @@
|
||||
"autoFaultReset": "自动报警复位 <small>(不推荐!)</small>",
|
||||
"autoDiagReset": "自动诊断复位 <small>(不推荐!)</small>",
|
||||
"setDateAndTime": "同步设置锅炉日期与时间",
|
||||
"immergasFix": "针对Immergas锅炉的兼容性修复"
|
||||
"immergasFix": "针对Immergas锅炉的兼容性修复",
|
||||
"alwaysSendIndoorTemp": "向锅炉发送当前室内温度"
|
||||
},
|
||||
|
||||
"nativeHeating": {
|
||||
"title": "原生锅炉供暖控制",
|
||||
"note": "<u>注意:</u> 仅适用于锅炉需接收目标室温并自主调节载热介质温度的场景,与固件中的PID及Equithermq气候补偿功能不兼容。"
|
||||
"nativeOTC": {
|
||||
"title": "原生热载体温度计算模式",
|
||||
"note": "仅在锅炉处于 OTC 模式时<u>才</u>工作:需要并接受目标室内温度,并基于内置曲线模式自行调节热载体温度。与 PID 和 Equitherm 不兼容。"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@
|
||||
"otDhwBurnerHours": "OpenTherm, number of burner operating hours (DHW)",
|
||||
"otHeatingPumpHours": "OpenTherm, number of pump operating hours (heating)",
|
||||
"otDhwPumpHours": "OpenTherm, number of pump operating hours (DHW)",
|
||||
"otCoolingHours": "OpenTherm, number of cooling hours",
|
||||
|
||||
"ntcTemp": "NTC sensor",
|
||||
"dallasTemp": "DALLAS sensor",
|
||||
@@ -341,12 +342,8 @@
|
||||
"enable": "Enabled Serial port",
|
||||
"baud": "Serial port baud rate"
|
||||
},
|
||||
"telnet": {
|
||||
"enable": "Enabled Telnet",
|
||||
"port": {
|
||||
"title": "Telnet port",
|
||||
"note": "Default: 23"
|
||||
}
|
||||
"webSerial": {
|
||||
"enable": "Enabled WebSerial"
|
||||
},
|
||||
"ntp": {
|
||||
"server": "NTP server",
|
||||
@@ -457,13 +454,13 @@
|
||||
"autoFaultReset": "Auto fault reset <small>(not recommended!)</small>",
|
||||
"autoDiagReset": "Auto diag reset <small>(not recommended!)</small>",
|
||||
"setDateAndTime": "Set date & time on boiler",
|
||||
"alwaysSetIndoorTemp": "Always set indoor temperature",
|
||||
"immergasFix": "Fix for Immergas boilers"
|
||||
"immergasFix": "Fix for Immergas boilers",
|
||||
"alwaysSendIndoorTemp": "Send current indoor temp to boiler"
|
||||
},
|
||||
|
||||
"nativeHeating": {
|
||||
"title": "Native heating control (boiler)",
|
||||
"note": "Works <u>ONLY</u> if the boiler requires the desired room temperature and regulates the temperature of the coolant itself. Not compatible with PID and Equitherm regulators in firmware."
|
||||
"nativeOTC": {
|
||||
"title": "Native OTC mode",
|
||||
"note": "Works <u>ONLY</u> if the boiler is in OTC mode: requires and accepts the target indoor temperature and self-regulates the heat carrier temperature based on the built-in curves mode. Incompatible with PID and Equitherm."
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@
|
||||
"otDhwBurnerHours": "OpenTherm, numero di ore di funzionamento del bruciatore (ACS)",
|
||||
"otHeatingPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (riscaldamento)",
|
||||
"otDhwPumpHours": "OpenTherm, numero di ore di funzionamento della pompa (ACS)",
|
||||
"otCoolingHours": "OpenTherm, numero di ore di funzionamento della cooling",
|
||||
|
||||
"ntcTemp": "Sensore NTC",
|
||||
"dallasTemp": "Sensore DALLAS",
|
||||
@@ -341,12 +342,8 @@
|
||||
"enable": "Porta seriale attivata",
|
||||
"baud": "Porta seriale baud rate"
|
||||
},
|
||||
"telnet": {
|
||||
"enable": "Telnet attivato",
|
||||
"port": {
|
||||
"title": "Porta Telnet",
|
||||
"note": "Default: 23"
|
||||
}
|
||||
"webSerial": {
|
||||
"enable": "WebSerial attivato"
|
||||
},
|
||||
"ntp": {
|
||||
"server": "NTP server",
|
||||
@@ -457,12 +454,13 @@
|
||||
"autoFaultReset": "Ripristino automatico degli errori <small>(sconsigliato!)</small>",
|
||||
"autoDiagReset": "Ripristino diagnostico automatica <small>(sconsigliato!)</small>",
|
||||
"setDateAndTime": "Imposta data e ora sulla caldaia",
|
||||
"immergasFix": "Fix per caldiaie Immergas"
|
||||
"immergasFix": "Fix per caldiaie Immergas",
|
||||
"alwaysSendIndoorTemp": "Invia la temp attuale interna alla caldaia"
|
||||
},
|
||||
|
||||
"nativeHeating": {
|
||||
"title": "Controllo del riscaldamento nativo (caldaia)",
|
||||
"note": "Lavora <u>SOLO</u> se la caldaia richiede la temperatura ambiente desiderata e regola autonomamente la temperatura del fluido. Non compatiblile con regolazioni PID e Equitherm del sistema."
|
||||
"nativeOTC": {
|
||||
"title": "Modalità nativa di calcolo della temperatura del vettore termico",
|
||||
"note": "Funziona <u>SOLO</u> se la caldaia è in modalità OTC: richiede e accetta la temperatura interna target e regola autonomamente la temperatura del vettore termico basata sulla modalità curve integrata. Incompatibile con PID e Equitherm."
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -222,6 +222,8 @@
|
||||
"otDhwBurnerHours": "OpenTherm, aantal branderuren (warm water)",
|
||||
"otHeatingPumpHours": "OpenTherm, aantal pompuren (verwarming)",
|
||||
"otDhwPumpHours": "OpenTherm, aantal pompuren (warm water)",
|
||||
"otCoolingHours": "OpenTherm, aantal cooling",
|
||||
|
||||
"ntcTemp": "NTC-sensor",
|
||||
"dallasTemp": "DALLAS-sensor",
|
||||
"bluetooth": "BLE-sensor",
|
||||
@@ -313,12 +315,8 @@
|
||||
"enable": "Seriële poort ingeschakeld",
|
||||
"baud": "Baudrate seriële poort"
|
||||
},
|
||||
"telnet": {
|
||||
"enable": "Telnet ingeschakeld",
|
||||
"port": {
|
||||
"title": "Telnet-poort",
|
||||
"note": "Standaard: 23"
|
||||
}
|
||||
"webSerial": {
|
||||
"enable": "WebSerial ingeschakeld"
|
||||
},
|
||||
"ntp": {
|
||||
"server": "NTP-server",
|
||||
@@ -422,11 +420,13 @@
|
||||
"autoFaultReset": "Automatische storingsreset <small>(niet aanbevolen!)</small>",
|
||||
"autoDiagReset": "Automatische diagnosereset <small>(niet aanbevolen!)</small>",
|
||||
"setDateAndTime": "Stel datum & tijd in op ketel",
|
||||
"immergasFix": "Fix voor Immergas-ketels"
|
||||
"immergasFix": "Fix voor Immergas-ketels",
|
||||
"alwaysSendIndoorTemp": "Stuur huidige binnentemp naar ketel"
|
||||
},
|
||||
"nativeHeating": {
|
||||
"title": "Natuurlijke verwarmingsregeling (ketel)",
|
||||
"note": "Werkt <u>ALLEEN</u> als de ketel de gewenste kamertemperatuur vereist en zelf de temperatuur van de warmtedrager regelt. Niet compatibel met PID- en Equitherm-regelaars in de firmware."
|
||||
|
||||
"nativeOTC": {
|
||||
"title": "Native warmtedrager temperatuur berekeningsmodus",
|
||||
"note": "Werkt <u>ALLEEN</u> als de ketel in OTC-modus is: vereist en accepteert de doel binnentemperatuur en regelt zelf de warmtedrager temperatuur op basis van de ingebouwde curves modus. Incompatibel met PID en Equitherm."
|
||||
}
|
||||
},
|
||||
"mqtt": {
|
||||
|
||||
@@ -243,6 +243,7 @@
|
||||
"otDhwBurnerHours": "OpenTherm, кол-во часов работы горелки (ГВС)",
|
||||
"otHeatingPumpHours": "OpenTherm, кол-во часов работы насоса (отопление)",
|
||||
"otDhwPumpHours": "OpenTherm, кол-во часов работы насоса (ГВС)",
|
||||
"otCoolingHours": "OpenTherm, кол-во часов работы охлаждения",
|
||||
|
||||
"ntcTemp": "NTC датчик",
|
||||
"dallasTemp": "DALLAS датчик",
|
||||
@@ -341,12 +342,8 @@
|
||||
"enable": "Вкл. Serial порт",
|
||||
"baud": "Скорость Serial порта"
|
||||
},
|
||||
"telnet": {
|
||||
"enable": "Вкл. Telnet",
|
||||
"port": {
|
||||
"title": "Telnet порт",
|
||||
"note": "По умолчанию: 23"
|
||||
}
|
||||
"webSerial": {
|
||||
"enable": "Вкл. WebSerial"
|
||||
},
|
||||
"ntp": {
|
||||
"server": "NTP сервер",
|
||||
@@ -457,12 +454,13 @@
|
||||
"autoFaultReset": "Автоматический сброс ошибок <small>(не рекомендуется!)</small>",
|
||||
"autoDiagReset": "Автоматический сброс диагностики <small>(не рекомендуется!)</small>",
|
||||
"setDateAndTime": "Устанавливать время и дату на котле",
|
||||
"immergasFix": "Фикс для котлов Immergas"
|
||||
"immergasFix": "Фикс для котлов Immergas",
|
||||
"alwaysSendIndoorTemp": "Передавать текущую темп. в помещении котлу"
|
||||
},
|
||||
|
||||
"nativeHeating": {
|
||||
"title": "Передать управление отоплением котлу",
|
||||
"note": "Работает <u>ТОЛЬКО</u> если котел требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА."
|
||||
"nativeOTC": {
|
||||
"title": "Нативный режим OTC (расчёт температуры теплоносителя)",
|
||||
"note": "Работает <u>ТОЛЬКО</u> если котел в режиме OTC: требует и принимает целевую температуру в помещении и сам регулирует температуру теплоносителя на основе встроенного режима кривых. Несовместимо с ПИД и ПЗА."
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -491,6 +491,9 @@
|
||||
if (modified) {
|
||||
parameters.method = "POST";
|
||||
parameters.body = JSON.stringify(newSettings);
|
||||
parameters.headers = {
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
}
|
||||
|
||||
const response = await fetch("/api/settings", parameters);
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
<option value="24" data-i18n>sensors.types.otDhwBurnerHours</option>
|
||||
<option value="25" data-i18n>sensors.types.otHeatingPumpHours</option>
|
||||
<option value="26" data-i18n>sensors.types.otDhwPumpHours</option>
|
||||
<option value="27" data-i18n>sensors.types.otCoolingHours</option>
|
||||
|
||||
<option value="50" data-i18n>sensors.types.ntcTemp</option>
|
||||
<option value="51" data-i18n>sensors.types.dallasTemp</option>
|
||||
|
||||
@@ -126,8 +126,8 @@
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="system[telnet][enabled]" value="true">
|
||||
<span data-i18n>settings.system.telnet.enable</span>
|
||||
<input type="checkbox" name="system[webSerial][enabled]" value="true">
|
||||
<span data-i18n>settings.system.webSerial.enable</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
@@ -156,12 +156,6 @@
|
||||
<option value="115200">115200</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>settings.system.telnet.port.title</span>
|
||||
<input type="number" inputmode="numeric" name="system[telnet][port]" min="1" max="65535" step="1" required>
|
||||
<small data-i18n>settings.system.telnet.port.note</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<mark data-i18n>settings.note.restart</mark>
|
||||
@@ -688,21 +682,21 @@
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="opentherm[options][alwaysSetIndoorTemp]" value="true">
|
||||
<span data-i18n>settings.ot.options.alwaysSetIndoorTemp</span>
|
||||
<input type="checkbox" name="opentherm[options][immergasFix]" value="true">
|
||||
<span data-i18n>settings.ot.options.immergasFix</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="opentherm[options][immergasFix]" value="true">
|
||||
<span data-i18n>settings.ot.options.immergasFix</span>
|
||||
<input type="checkbox" name="opentherm[options][alwaysSendIndoorTemp]" value="true">
|
||||
<span data-i18n>settings.ot.options.alwaysSendIndoorTemp</span>
|
||||
</label>
|
||||
|
||||
<hr />
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="opentherm[options][nativeHeatingControl]" value="true">
|
||||
<span data-i18n>settings.ot.nativeHeating.title</span><br />
|
||||
<small data-i18n>settings.ot.nativeHeating.note</small>
|
||||
<input type="checkbox" name="opentherm[options][nativeOTC]" value="true">
|
||||
<span data-i18n>settings.ot.nativeOTC.title</span><br />
|
||||
<small data-i18n>settings.ot.nativeOTC.note</small>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -1083,8 +1077,7 @@
|
||||
setSelectValue("[name='system[logLevel]']", data.system.logLevel);
|
||||
setCheckboxValue("[name='system[serial][enabled]']", data.system.serial.enabled);
|
||||
setSelectValue("[name='system[serial][baudrate]']", data.system.serial.baudrate);
|
||||
setCheckboxValue("[name='system[telnet][enabled]']", data.system.telnet.enabled);
|
||||
setInputValue("[name='system[telnet][port]']", data.system.telnet.port);
|
||||
setCheckboxValue("[name='system[webSerial][enabled]']", data.system.webSerial.enabled);
|
||||
setInputValue("[name='system[ntp][server]']", data.system.ntp.server);
|
||||
setInputValue("[name='system[ntp][timezone]']", data.system.ntp.timezone);
|
||||
setRadioValue("[name='system[unitSystem]']", data.system.unitSystem);
|
||||
@@ -1122,9 +1115,9 @@
|
||||
setCheckboxValue("[name='opentherm[options][autoFaultReset]']", data.opentherm.options.autoFaultReset);
|
||||
setCheckboxValue("[name='opentherm[options][autoDiagReset]']", data.opentherm.options.autoDiagReset);
|
||||
setCheckboxValue("[name='opentherm[options][setDateAndTime]']", data.opentherm.options.setDateAndTime);
|
||||
setCheckboxValue("[name='opentherm[options][alwaysSetIndoorTemp]']", data.opentherm.options.alwaysSetIndoorTemp);
|
||||
setCheckboxValue("[name='opentherm[options][nativeHeatingControl]']", data.opentherm.options.nativeHeatingControl);
|
||||
setCheckboxValue("[name='opentherm[options][nativeOTC]']", data.opentherm.options.nativeOTC);
|
||||
setCheckboxValue("[name='opentherm[options][immergasFix]']", data.opentherm.options.immergasFix);
|
||||
setCheckboxValue("[name='opentherm[options][alwaysSendIndoorTemp]']", data.opentherm.options.alwaysSendIndoorTemp);
|
||||
setBusy('#ot-settings-busy', '#ot-settings', false);
|
||||
|
||||
// MQTT
|
||||
@@ -1212,7 +1205,7 @@
|
||||
setBusy('#dhw-settings-busy', '#dhw-settings', false);
|
||||
|
||||
// Emergency mode
|
||||
if (data.opentherm.options.nativeHeatingControl) {
|
||||
if (data.opentherm.options.nativeOTC) {
|
||||
setInputValue("[name='emergency[target]']", data.emergency.target, {
|
||||
"min": data.system.unitSystem == 0 ? 5 : 41,
|
||||
"max": data.system.unitSystem == 0 ? 40 : 104
|
||||
|
||||
@@ -62,19 +62,19 @@
|
||||
|
||||
<form action="/api/upgrade" id="upgrade">
|
||||
<fieldset class="primary">
|
||||
<label for="firmware-file">
|
||||
<label>
|
||||
<span data-i18n>upgrade.fw</span>:
|
||||
<div class="grid">
|
||||
<input type="file" name="firmware" id="firmware-file" accept=".bin">
|
||||
<button type="button" class="upgrade-firmware-result hidden" disabled></button>
|
||||
<input type="file" name="fw" accept=".bin">
|
||||
<button type="button" class="fwResult hidden" disabled></button>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label for="filesystem-file">
|
||||
<label>
|
||||
<span data-i18n>upgrade.fs</span>:
|
||||
<div class="grid">
|
||||
<input type="file" name="filesystem" id="filesystem-file" accept=".bin">
|
||||
<button type="button" class="upgrade-filesystem-result hidden" disabled></button>
|
||||
<input type="file" name="fs" accept=".bin">
|
||||
<button type="button" class="fsResult hidden" disabled></button>
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
@@ -108,7 +108,123 @@
|
||||
lang.build();
|
||||
|
||||
setupRestoreBackupForm('#restore');
|
||||
setupUpgradeForm('#upgrade');
|
||||
|
||||
const upgradeForm = document.querySelector('#upgrade');
|
||||
if (upgradeForm) {
|
||||
upgradeForm.reset();
|
||||
const statusToText = (status) => {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return "None";
|
||||
case 1:
|
||||
return "No file";
|
||||
case 2:
|
||||
return "Success";
|
||||
case 3:
|
||||
return "Prohibited";
|
||||
case 4:
|
||||
return "Size mismatch";
|
||||
case 5:
|
||||
return "Error on start";
|
||||
case 6:
|
||||
return "Error on write";
|
||||
case 7:
|
||||
return "Error on finish";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
};
|
||||
|
||||
upgradeForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
hide('.fwResult');
|
||||
hide('.fsResult');
|
||||
|
||||
let button = upgradeForm.querySelector('button[type="submit"]');
|
||||
button.textContent = i18n('button.uploading');
|
||||
button.setAttribute('disabled', true);
|
||||
button.setAttribute('aria-busy', true);
|
||||
|
||||
try {
|
||||
let fd = new FormData();
|
||||
|
||||
const fw = upgradeForm.querySelector("[name='fw']").files;
|
||||
if (fw.length > 0) {
|
||||
fd.append("fw_size", fw[0].size);
|
||||
fd.append("fw", fw[0]);
|
||||
}
|
||||
|
||||
const fs = upgradeForm.querySelector("[name='fs']").files;
|
||||
if (fs.length > 0) {
|
||||
fd.append("fs_size", fs[0].size);
|
||||
fd.append("fs", fs[0]);
|
||||
}
|
||||
|
||||
let response = await fetch(upgradeForm.action, {
|
||||
method: "POST",
|
||||
cache: "no-cache",
|
||||
credentials: "include",
|
||||
body: fd
|
||||
});
|
||||
|
||||
if (response.status != 202 && response.status != 406) {
|
||||
throw new Error('Response not valid');
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
let resItem = upgradeForm.querySelector('.fwResult');
|
||||
if (resItem && result.firmware.status > 1) {
|
||||
resItem.textContent = statusToText(result.firmware.status);
|
||||
resItem.classList.remove('hidden');
|
||||
|
||||
if (result.firmware.status == 2) {
|
||||
resItem.classList.remove('failed');
|
||||
resItem.classList.add('success');
|
||||
} else {
|
||||
resItem.classList.remove('success');
|
||||
resItem.classList.add('failed');
|
||||
|
||||
if (result.firmware.error != "") {
|
||||
resItem.textContent += `: ${result.firmware.error}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resItem = upgradeForm.querySelector('.fsResult');
|
||||
if (resItem && result.filesystem.status > 1) {
|
||||
resItem.textContent = statusToText(result.filesystem.status);
|
||||
resItem.classList.remove('hidden');
|
||||
|
||||
if (result.filesystem.status == 2) {
|
||||
resItem.classList.remove('failed');
|
||||
resItem.classList.add('success');
|
||||
} else {
|
||||
resItem.classList.remove('success');
|
||||
resItem.classList.add('failed');
|
||||
|
||||
if (result.filesystem.error != "") {
|
||||
resItem.textContent += `: ${result.filesystem.error}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
button.textContent = i18n('button.error');
|
||||
button.classList.add('failed');
|
||||
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
button.removeAttribute('aria-busy');
|
||||
button.removeAttribute('disabled');
|
||||
button.classList.remove('success', 'failed');
|
||||
button.textContent = i18n(button.dataset.i18n);
|
||||
upgradeForm.reset();
|
||||
}, 10000);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -318,19 +318,25 @@ const setupRestoreBackupForm = (formSelector) => {
|
||||
console.log("Backup: ", data);
|
||||
|
||||
if (data.settings != undefined) {
|
||||
let response = await fetch(url, {
|
||||
method: "POST",
|
||||
cache: "no-cache",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({"settings": data.settings})
|
||||
});
|
||||
for (var key in data.settings) {
|
||||
let response = await fetch(url, {
|
||||
method: "POST",
|
||||
cache: "no-cache",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
"settings": {
|
||||
[key]: data.settings[key]
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
onFailed();
|
||||
return;
|
||||
if (!response.ok) {
|
||||
onFailed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user