From 788efb126684df7555662ca33984b66800e8d890 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 19 Sep 2024 17:28:30 +0200 Subject: [PATCH 1/4] CTRL-C, not CTRL-L --- src/emsesp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index d998ad852..22ebe2b1b 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1709,7 +1709,8 @@ void EMSESP::loop() { if (c != -1) { show_prompt = true; } - if (c == '\x03' || c == '\x0C') { + // https://daleswanson.org/ascii.htm#:~:text=0 + if (c == '\x03') { start_serial_console(); } } From 8762f9c64a5803d56218a8c4ef16e260b9d88aa6 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 19 Sep 2024 18:37:21 +0200 Subject: [PATCH 2/4] updated text on how to run the unit tests --- platformio.ini | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 44306203e..bad56e7d2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -239,9 +239,10 @@ lib_ldf_mode = off lib_ignore = Module EMS-ESP-Modules ; unit tests -; pio run -e native-test -t exec -; works on Linux, Windows, and MacOS -; to update the test results, compile with -DEMSESP_UNITY_CREATE, run and capture the output and then paste this into the test_api.cpp file +; The code is in test/test_api.h/cpp +; to run use `pio run -e native-test -t exec`. All tests should PASS. +; to update the test results, compile with -DEMSESP_UNITY_CREATE by uncommenting the line below +; then run and capture the output between "START - CUT HERE" and "END - CUT HERE" into the test_api.h file [env:native-test] platform = native test_build_src = true From e0130638c3383626e7f63a3efdae3246a37ac8de Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 19 Sep 2024 18:37:33 +0200 Subject: [PATCH 3/4] updated test results for 3.7.0 --- test/test_api/test_api.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_api/test_api.h b/test/test_api/test_api.h index 4cfd9e8b1..fcfdc134a 100644 --- a/test/test_api/test_api.h +++ b/test/test_api/test_api.h @@ -158,7 +158,7 @@ void test_19() { auto expected_response = "[{\"system\":{\"version\":\"dev\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " "Unknown\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false," - "\"disableSleep\":false,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," + "\"disableSleep\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," "\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTConnects\":1,\"enabled\":true,\"clientID\":\"ems-esp\",\"keepAlive\":60,\"cleanSession\":false," "\"entityFormat\":1,\"base\":\"ems-esp\",\"discoveryPrefix\":\"homeassistant\",\"discoveryType\":0,\"nestedFormat\":1,\"haEnabled\":true,\"mqttQos\":0," "\"mqttRetain\":false,\"publishTimeHeartbeat\":60,\"publishTimeBoiler\":10,\"publishTimeThermostat\":10,\"publishTimeSolar\":10,\"publishTimeMixer\":" @@ -169,7 +169,7 @@ void test_19() { "\"busRxLineQuality\":100,\"busTxLineQuality\":100},\"settings\":{\"boardProfile\":\"S32\",\"locale\":\"en\",\"txMode\":8,\"emsBusID\":11," "\"showerTimer\":false,\"showerMinDuration\":180,\"showerAlert\":false,\"hideLed\":false,\"noTokenApi\":false,\"readonlyMode\":false,\"fahrenheit\":" "false,\"dallasParasite\":false,\"boolFormat\":1,\"boolDashboard\":1,\"enumFormat\":1,\"analogEnabled\":true,\"telnetEnabled\":true," - "\"maxWebLogBuffer\":50,\"webLogBuffer\":0,\"modbusEnabled\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " + "\"maxWebLogBuffer\":25,\"webLogBuffer\":0,\"modbusEnabled\":false,\"forceHeatingOff\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " "Name!!\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":37,\"handlersReceived\":\"0x18\"," "\"handlersFetched\":\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x2E " "0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15," @@ -181,7 +181,7 @@ void test_20() { auto expected_response = "[{\"system\":{\"version\":\"dev\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " "Unknown\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false," - "\"disableSleep\":false,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," + "\"disableSleep\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," "\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTConnects\":1,\"enabled\":true,\"clientID\":\"ems-esp\",\"keepAlive\":60,\"cleanSession\":false," "\"entityFormat\":1,\"base\":\"ems-esp\",\"discoveryPrefix\":\"homeassistant\",\"discoveryType\":0,\"nestedFormat\":1,\"haEnabled\":true,\"mqttQos\":0," "\"mqttRetain\":false,\"publishTimeHeartbeat\":60,\"publishTimeBoiler\":10,\"publishTimeThermostat\":10,\"publishTimeSolar\":10,\"publishTimeMixer\":" @@ -192,7 +192,7 @@ void test_20() { "\"busRxLineQuality\":100,\"busTxLineQuality\":100},\"settings\":{\"boardProfile\":\"S32\",\"locale\":\"en\",\"txMode\":8,\"emsBusID\":11," "\"showerTimer\":false,\"showerMinDuration\":180,\"showerAlert\":false,\"hideLed\":false,\"noTokenApi\":false,\"readonlyMode\":false,\"fahrenheit\":" "false,\"dallasParasite\":false,\"boolFormat\":1,\"boolDashboard\":1,\"enumFormat\":1,\"analogEnabled\":true,\"telnetEnabled\":true," - "\"maxWebLogBuffer\":50,\"webLogBuffer\":0,\"modbusEnabled\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " + "\"maxWebLogBuffer\":25,\"webLogBuffer\":0,\"modbusEnabled\":false,\"forceHeatingOff\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " "Name!!\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":37,\"handlersReceived\":\"0x18\"," "\"handlersFetched\":\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x2E " "0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15," @@ -213,7 +213,7 @@ void test_22() { void test_23() { auto expected_response = "[{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":\"-23\",\"TxPowerSetting\":\"0\",\"staticIP\":\"false\"," - "\"lowBandwidth\":\"false\",\"disableSleep\":\"false\",\"enableMDNS\":\"true\",\"enableCORS\":\"false\"}]"; + "\"lowBandwidth\":\"false\",\"disableSleep\":\"true\",\"enableMDNS\":\"true\",\"enableCORS\":\"false\"}]"; TEST_ASSERT_EQUAL_STRING(expected_response, call_url("api/system/network/values")); } From 5b1493b94044b7961caba45502b73ca40200e8b1 Mon Sep 17 00:00:00 2001 From: proddy Date: Thu, 19 Sep 2024 18:38:36 +0200 Subject: [PATCH 4/4] incorporated Michael's changes https://github.com/emsesp/EMS-ESP32/pull/2027 --- src/command.cpp | 5 +++-- src/console.cpp | 2 +- src/web/WebSchedulerService.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index a8420409b..f9fbe5f7a 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -298,8 +298,9 @@ bool Command::set_attribute(JsonObject output, const char * cmd, const char * at if (attribute == nullptr) { return true; } - if (output[attribute].is()) { - std::string data = output[attribute]; + + if (output[attribute].is()) { + std::string data = output[attribute].as(); output.clear(); output["api_data"] = data; // always as a string return true; diff --git a/src/console.cpp b/src/console.cpp index bdbc8db4c..677fd1986 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -552,7 +552,7 @@ static void setup_commands(std::shared_ptr & commands) { if (return_code == CommandRet::OK) { if (json.size()) { - if (json["api_data"].is()) { + if (json["api_data"].is()) { String data = json["api_data"]; shell.println(data.c_str()); return; diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index f1b3c5812..f4fa0c08d 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -245,7 +245,7 @@ void WebSchedulerService::publish(const bool force) { JsonDocument doc; bool ha_created = ha_registered_; for (const ScheduleItem & scheduleItem : *scheduleItems_) { - if (!scheduleItem.name.empty() && !doc[scheduleItem.name].is()) { + if (!scheduleItem.name.empty() && !doc[scheduleItem.name].is()) { if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) { doc[scheduleItem.name] = scheduleItem.active; } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) {