From 98fb970dac3a52a7712eeb327501a72344cc095f Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 6 Jun 2022 11:19:56 +0200 Subject: [PATCH 1/3] add test for #541 --- src/test/test.cpp | 19 +++++++++++++++++++ src/test/test.h | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/test/test.cpp b/src/test/test.cpp index de793b39a..7410cd07f 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -692,6 +692,25 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59"); } + // https://github.com/emsesp/EMS-ESP32/issues/541 + if (command == "api_wwmode") { + shell.printfln(F("Testing API wwmode")); + Mqtt::ha_enabled(false); + Mqtt::nested_format(1); + run_test("310"); + + AsyncWebServerRequest request; + request.method(HTTP_POST); + DynamicJsonDocument doc(2000); + JsonVariant json; + + char data[] = "{\"value\":\"off\"}"; + deserializeJson(doc, data); + json = doc.as(); + request.url("/api/thermostat/wwmode"); + EMSESP::webAPIService.webAPIService_post(&request, json); + } + if (command == "api") { shell.printfln(F("Testing API with MQTT and REST, standalone")); diff --git a/src/test/test.h b/src/test/test.h index be3bf9cb1..30bc6f307 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -48,8 +48,9 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "2thermostats" // #define EMSESP_DEBUG_DEFAULT "dallas" // #define EMSESP_DEBUG_DEFAULT "analog" -#define EMSESP_DEBUG_DEFAULT "api_values" +// #define EMSESP_DEBUG_DEFAULT "api_values" // #define EMSESP_DEBUG_DEFAULT "mqtt_post" +#define EMSESP_DEBUG_DEFAULT "api_wwmode" class Test { public: From cf4818f09c742d2ccdfc0d084d430aa0f860e025 Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 6 Jun 2022 11:20:09 +0200 Subject: [PATCH 2/3] update packages --- interface/package-lock.json | 42 ++++++++++++++++++------------------- interface/package.json | 6 +++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/interface/package-lock.json b/interface/package-lock.json index 52a41d888..2d1caf15e 100644 --- a/interface/package-lock.json +++ b/interface/package-lock.json @@ -15,8 +15,8 @@ "@mui/material": "^5.8.2", "@table-library/react-table-library": "^3.1.5", "@types/lodash": "^4.14.182", - "@types/node": "^17.0.38", - "@types/react": "^18.0.10", + "@types/node": "^17.0.40", + "@types/react": "^18.0.12", "@types/react-dom": "^18.0.5", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.1.1", @@ -34,7 +34,7 @@ "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typescript": "^4.7.2" + "typescript": "^4.7.3" }, "devDependencies": { "nodemon": "^2.0.16", @@ -3951,9 +3951,9 @@ "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" }, "node_modules/@types/node": { - "version": "17.0.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz", - "integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==" + "version": "17.0.40", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.40.tgz", + "integrity": "sha512-UXdBxNGqTMtm7hCwh9HtncFVLrXoqA3oJW30j6XWp5BH/wu3mVeaxo7cq5benFdBw34HB3XDT2TRPI7rXZ+mDg==" }, "node_modules/@types/parse-json": { "version": "4.0.0", @@ -3986,9 +3986,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "node_modules/@types/react": { - "version": "18.0.10", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.10.tgz", - "integrity": "sha512-dIugadZuIPrRzvIEevIu7A1smqOAjkSMv8qOfwPt9Ve6i6JT/FQcCHyk2qIAxwsQNKZt5/oGR0T4z9h2dXRAkg==", + "version": "18.0.12", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.12.tgz", + "integrity": "sha512-duF1OTASSBQtcigUvhuiTB1Ya3OvSy+xORCiEf20H0P0lzx+/KeVsA99U5UjLXSbyo1DRJDlLKqTeM1ngosqtg==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -16802,9 +16802,9 @@ } }, "node_modules/typescript": { - "version": "4.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.2.tgz", - "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==", + "version": "4.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz", + "integrity": "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -20684,9 +20684,9 @@ "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==" }, "@types/node": { - "version": "17.0.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz", - "integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==" + "version": "17.0.40", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.40.tgz", + "integrity": "sha512-UXdBxNGqTMtm7hCwh9HtncFVLrXoqA3oJW30j6XWp5BH/wu3mVeaxo7cq5benFdBw34HB3XDT2TRPI7rXZ+mDg==" }, "@types/parse-json": { "version": "4.0.0", @@ -20719,9 +20719,9 @@ "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" }, "@types/react": { - "version": "18.0.10", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.10.tgz", - "integrity": "sha512-dIugadZuIPrRzvIEevIu7A1smqOAjkSMv8qOfwPt9Ve6i6JT/FQcCHyk2qIAxwsQNKZt5/oGR0T4z9h2dXRAkg==", + "version": "18.0.12", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.12.tgz", + "integrity": "sha512-duF1OTASSBQtcigUvhuiTB1Ya3OvSy+xORCiEf20H0P0lzx+/KeVsA99U5UjLXSbyo1DRJDlLKqTeM1ngosqtg==", "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -29959,9 +29959,9 @@ } }, "typescript": { - "version": "4.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.2.tgz", - "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==" + "version": "4.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.3.tgz", + "integrity": "sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA==" }, "unbox-primitive": { "version": "1.0.2", diff --git a/interface/package.json b/interface/package.json index e105ba51d..3b43adec8 100644 --- a/interface/package.json +++ b/interface/package.json @@ -11,8 +11,8 @@ "@mui/material": "^5.8.2", "@table-library/react-table-library": "^3.1.5", "@types/lodash": "^4.14.182", - "@types/node": "^17.0.38", - "@types/react": "^18.0.10", + "@types/node": "^17.0.40", + "@types/react": "^18.0.12", "@types/react-dom": "^18.0.5", "@types/react-router-dom": "^5.3.3", "async-validator": "^4.1.1", @@ -30,7 +30,7 @@ "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "sockette": "^2.0.6", - "typescript": "^4.7.2" + "typescript": "^4.7.3" }, "scripts": { "start": "react-app-rewired start", From 64a7108e6d016d8047a4230bc109b4b2ce50237f Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 6 Jun 2022 11:20:16 +0200 Subject: [PATCH 3/3] make it compile standalone --- src/command.cpp | 2 +- src/system.h | 4 +++- src/web/WebStatusService.cpp | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index a169f87db..b4583c5cb 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -276,7 +276,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * } } - // call the function baesed on type + // call the function based on type if (cf->cmdfunction_json_) { return_code = ((cf->cmdfunction_json_)(value, id, output)) ? CommandRet::OK : CommandRet::ERROR; } diff --git a/src/system.h b/src/system.h index aa90fe9e1..a0448df96 100644 --- a/src/system.h +++ b/src/system.h @@ -81,6 +81,7 @@ class System { return syslog_enabled_; } +#ifndef EMSESP_STANDALONE unsigned long syslog_count() { return syslog_.message_count(); } @@ -88,6 +89,7 @@ class System { unsigned long syslog_fails() { return syslog_.message_fails(); } +#endif void led_init(bool refresh); void network_init(bool refresh); @@ -189,7 +191,7 @@ class System { #ifndef EMSESP_STANDALONE return (ethernet_connected() || WiFi.isConnected()); #else - return true; + return true; #endif } diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 7a7aaa4d3..3ff433886 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -187,6 +187,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) { statJson["q"] = WebAPIService::api_count() == 0 ? 100 : 100 - (uint8_t)((100 * WebAPIService::api_fails()) / (WebAPIService::api_count() + WebAPIService::api_fails())); +#ifndef EMSESP_STANDALONE if (EMSESP::system_.syslog_enabled()) { statJson = statsJson.createNestedObject(); statJson["id"] = "Syslog Messages"; @@ -196,6 +197,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) { ? 100 : 100 - (uint8_t)((100 * EMSESP::system_.syslog_fails()) / (EMSESP::system_.syslog_count() + EMSESP::system_.syslog_fails())); } +#endif response->setLength(); request->send(response);