mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add test for #2351
This commit is contained in:
@@ -2750,6 +2750,11 @@ bool Boiler::set_ww_circulation_pump(const char * value, const int8_t id) {
|
||||
write_command(EMS_TYPE_UBAParameterWW, 6, v ? 0xFF : 0x00, EMS_TYPE_UBAParameterWW);
|
||||
}
|
||||
|
||||
#ifdef EMSESP_TEST
|
||||
// set wwCircPump_ , for test "api4" in test.cpp
|
||||
wwCircPump_ = v ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -960,6 +960,48 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (command == "api4") {
|
||||
shell.printfln("Testing API writing values...");
|
||||
EMSESP::system_.bool_format(BOOL_FORMAT_ONOFF_STR);
|
||||
// EMSESP::system_.bool_format(BOOL_FORMAT_ONOFF_STR_CAP);
|
||||
|
||||
// load devices
|
||||
test("boiler");
|
||||
test("thermostat");
|
||||
|
||||
ok = true;
|
||||
AsyncWebServerRequest request;
|
||||
JsonDocument doc;
|
||||
JsonVariant json;
|
||||
request.method(HTTP_POST);
|
||||
|
||||
shell.invoke_command("call boiler circpump/value"); // initial state is off
|
||||
|
||||
// call boiler circpump on
|
||||
char data1[] = "{\"device\":\"boiler\", \"cmd\":\"circpump\",\"value\":\"on\"}";
|
||||
deserializeJson(doc, data1);
|
||||
request.url("/api");
|
||||
EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
|
||||
shell.invoke_command("call boiler circpump/value");
|
||||
|
||||
// switch to german
|
||||
EMSESP::system_.locale("de");
|
||||
|
||||
// call boiler circpump off, but using value in DE
|
||||
char data2[] = "{\"device\":\"boiler\", \"cmd\":\"circpump\",\"value\":\"aus\"}";
|
||||
deserializeJson(doc, data2);
|
||||
request.url("/api");
|
||||
EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
|
||||
shell.invoke_command("call boiler circpump/value");
|
||||
|
||||
// call boiler circpump on, but using value in DE
|
||||
char data3[] = "{\"device\":\"boiler\", \"cmd\":\"circpump\",\"value\":\"an\"}";
|
||||
deserializeJson(doc, data3);
|
||||
request.url("/api");
|
||||
EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
|
||||
shell.invoke_command("call boiler circpump/value");
|
||||
}
|
||||
|
||||
if (command == "api3") {
|
||||
shell.printfln("Testing API getting values from system");
|
||||
EMSESP::system_.bool_format(BOOL_FORMAT_TRUEFALSE); // BOOL_FORMAT_TRUEFALSE_STR
|
||||
@@ -1016,10 +1058,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
// request.url("/api");
|
||||
// EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
|
||||
|
||||
char data2[] = "{\"action\":\"getCustomSupport\", \"param\":\"hello\"}";
|
||||
deserializeJson(doc, data2);
|
||||
request.url("/rest/action");
|
||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
// char data2[] = "{\"action\":\"getCustomSupport\", \"param\":\"hello\"}";
|
||||
// deserializeJson(doc, data2);
|
||||
// request.url("/rest/action");
|
||||
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||
|
||||
// char data3[] = "{\"action\":\"export\", \"param\":\"schedule\"}";
|
||||
// deserializeJson(doc, data3);
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace emsesp {
|
||||
// #define EMSESP_DEBUG_DEFAULT "render"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api3"
|
||||
#define EMSESP_DEBUG_DEFAULT "api4"
|
||||
// #define EMSESP_DEBUG_DEFAULT "crash"
|
||||
// #define EMSESP_DEBUG_DEFAULT "dv"
|
||||
// #define EMSESP_DEBUG_DEFAULT "lastcode"
|
||||
|
||||
Reference in New Issue
Block a user