add new 'add' test

This commit is contained in:
proddy
2024-01-11 21:37:40 +01:00
parent 1f81ccb686
commit 94f268a62d
5 changed files with 121 additions and 83 deletions

View File

@@ -128,14 +128,16 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
commands->add_command(ShellContext::MAIN, commands->add_command(ShellContext::MAIN,
CommandFlags::USER, CommandFlags::USER,
string_vector{"test"}, string_vector{"test"},
string_vector{F_(name_optional), F_(data_optional)}, string_vector{F_(name_optional), F_(data_optional), F_(id_optional)},
[=](Shell & shell, const std::vector<std::string> & arguments) { [=](Shell & shell, const std::vector<std::string> & arguments) {
if (arguments.empty()) { if (arguments.empty()) {
Test::run_test(shell, "default"); Test::run_test(shell, "default");
} else if (arguments.size() == 1) { } else if (arguments.size() == 1) {
Test::run_test(shell, arguments.front()); Test::run_test(shell, arguments.front());
} else { } else if (arguments.size() == 2) {
Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str()); Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str());
} else {
Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str(), arguments[2].c_str());
} }
}); });
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{"t"}, [=](Shell & shell, const std::vector<std::string> & arguments) { commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{"t"}, [=](Shell & shell, const std::vector<std::string> & arguments) {

View File

@@ -167,6 +167,10 @@ class Mqtt {
return entity_format_; return entity_format_;
} }
static void entity_format(uint8_t n) {
entity_format_ = n;
}
static uint8_t discovery_type() { static uint8_t discovery_type() {
return discovery_type_; return discovery_type_;
} }

View File

@@ -1467,7 +1467,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
#if defined(EMSESP_TEST) #if defined(EMSESP_TEST)
// run a test, e.g. http://ems-esp/api?device=system&cmd=test&data=boiler // run a test, e.g. http://ems-esp/api?device=system&cmd=test&data=boiler
bool System::command_test(const char * value, const int8_t id) { bool System::command_test(const char * value, const int8_t id) {
return Test::run_test(value, id); return Test::test(value, id);
} }
#endif #endif

View File

@@ -1,7 +1,6 @@
/* /*
* EMS-ESP - https://github.com/emsesp/EMS-ESP * EMS-ESP - https://github.com/emsesp/EMS-ESP
* Copyright 2020-2023 Paul Derbyshire * Copyright 2020-2023 Paul Derbyshire
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -25,12 +24,19 @@ namespace emsesp {
// no shell, called via the API or 'call system test' command // no shell, called via the API or 'call system test' command
// or http://ems-esp/api?device=system&cmd=test&data=boiler // or http://ems-esp/api?device=system&cmd=test&data=boiler
bool Test::run_test(const char * command, int8_t id) { bool Test::test(const std::string & cmd, int8_t id1, int8_t id2) {
if ((command == nullptr) || (strlen(command) == 0)) { if (cmd.empty()) {
return false; return false;
} }
if (strcmp(command, "memory") == 0) { if (cmd == "add") {
Mqtt::entity_format(Mqtt::entityFormat::SINGLE_LONG); // SINGLE_LONG, SINGLE_SHORT, MULTI_SHORT
System::test_set_all_active(true); // include all entities and give them fake values
add_device(id1, id2);
return true;
}
if (cmd == "memory") {
EMSESP::logger().notice("Testing memory by adding lots of devices and entities..."); EMSESP::logger().notice("Testing memory by adding lots of devices and entities...");
System::test_set_all_active(true); // include all entities and give them fake values System::test_set_all_active(true); // include all entities and give them fake values
@@ -43,7 +49,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "general") == 0) { if (cmd == "general") {
EMSESP::logger().info("Testing general. Adding a Boiler and Thermostat"); EMSESP::logger().info("Testing general. Adding a Boiler and Thermostat");
// System::test_set_all_active(true); // uncomment if we want to show all entities and give them fake values // System::test_set_all_active(true); // uncomment if we want to show all entities and give them fake values
@@ -77,7 +83,7 @@ bool Test::run_test(const char * command, int8_t id) {
// //
#ifdef EMSESP_STANDALONE #ifdef EMSESP_STANDALONE
if (strcmp(command, "heat_exchange") == 0) { if (cmd == "heat_exchange") {
EMSESP::logger().info("Testing heating exchange..."); EMSESP::logger().info("Testing heating exchange...");
add_device(0x08, 219); // Greenstar HIU/Logamax kompakt WS170 add_device(0x08, 219); // Greenstar HIU/Logamax kompakt WS170
@@ -89,7 +95,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "2thermostats") == 0) { if (cmd == "2thermostats") {
EMSESP::logger().info("Testing with multiple thermostats..."); EMSESP::logger().info("Testing with multiple thermostats...");
add_device(0x08, 123); // GB072 add_device(0x08, 123); // GB072
@@ -121,7 +127,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "310") == 0) { if (cmd == "310") {
EMSESP::logger().info("Adding a GB072/RC310 combo..."); EMSESP::logger().info("Adding a GB072/RC310 combo...");
add_device(0x08, 123); // GB072 add_device(0x08, 123); // GB072
@@ -148,7 +154,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "gateway") == 0) { if (cmd == "gateway") {
EMSESP::logger().info("Adding a Gateway..."); EMSESP::logger().info("Adding a Gateway...");
// add 0x48 KM200, via a version command // add 0x48 KM200, via a version command
@@ -168,7 +174,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "mixer") == 0) { if (cmd == "mixer") {
EMSESP::logger().info("Adding a mixer..."); EMSESP::logger().info("Adding a mixer...");
// add controller // add controller
@@ -190,7 +196,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "boiler") == 0) { if (cmd == "boiler") {
EMSESP::logger().info("Adding boiler..."); EMSESP::logger().info("Adding boiler...");
add_device(0x08, 123); // Nefit Trendline add_device(0x08, 123); // Nefit Trendline
@@ -207,7 +213,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "thermostat") == 0) { if (cmd == "thermostat") {
EMSESP::logger().info("Adding thermostat..."); EMSESP::logger().info("Adding thermostat...");
add_device(0x10, 192); // FW120 add_device(0x10, 192); // FW120
@@ -220,7 +226,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "solar") == 0) { if (cmd == "solar") {
EMSESP::logger().info("Adding solar..."); EMSESP::logger().info("Adding solar...");
add_device(0x30, 163); // SM100 add_device(0x30, 163); // SM100
@@ -239,7 +245,7 @@ bool Test::run_test(const char * command, int8_t id) {
return true; return true;
} }
if (strcmp(command, "heatpump") == 0) { if (cmd == "heatpump") {
EMSESP::logger().info("Adding heatpump..."); EMSESP::logger().info("Adding heatpump...");
add_device(0x38, 200); // Enviline module add_device(0x38, 200); // Enviline module
@@ -258,11 +264,13 @@ bool Test::run_test(const char * command, int8_t id) {
} }
// These next tests are run from the Consol via the test command, so inherit the Shell // These next tests are run from the Consol via the test command, so inherit the Shell
void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const std::string & data) { void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const std::string & id1_s, const std::string & id2_s) {
shell.add_flags(CommandFlags::ADMIN); // switch to su shell.add_flags(CommandFlags::ADMIN); // switch to su
// init stuff // init stuff
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
Mqtt::entity_format(Mqtt::entityFormat::SINGLE_SHORT); // SINGLE_LONG, SINGLE_SHORT, MULTI_SHORT
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
// EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw mode // EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw mode
@@ -275,11 +283,36 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
command = cmd; command = cmd;
} }
// extract params
int8_t id1 = -1;
int8_t id2 = -1;
if (!id1_s.empty()) {
if (id1_s[0] == '0' && id1_s[1] == 'x') {
id1 = Helpers::hextoint(id1_s.c_str());
} else {
id1 = Helpers::atoint(id1_s.c_str());
}
}
if (!id2_s.empty()) {
id2 = Helpers::atoint(id2_s.c_str());
}
bool ok = false; bool ok = false;
if (command == "add") {
shell.printfln("Testing Adding a device (product_id %d), with all values...", id2);
test("add", id1, id2); // e.g. 8 172
shell.invoke_command("show values");
ok = true;
}
// TODO Fix !
// operating time compressor heating (uptimecompheating: 0 days 3 hours 27 minutes
// concat!!!
if (command == "general") { if (command == "general") {
shell.printfln("Testing adding a boiler, thermostat and sensors..."); shell.printfln("Testing adding a boiler, thermostat and sensors...");
run_test("general"); test("general");
// add sensors // add sensors
emsesp::EMSESP::analogsensor_.test(); emsesp::EMSESP::analogsensor_.test();
@@ -296,14 +329,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// https://github.com/emsesp/EMS-ESP32/issues/869 // https://github.com/emsesp/EMS-ESP32/issues/869
if (command == "memory") { if (command == "memory") {
shell.printfln("Testing memory by adding lots of devices and entities..."); shell.printfln("Testing memory by adding lots of devices and entities...");
run_test("memory"); test("memory");
shell.invoke_command("show values"); shell.invoke_command("show values");
ok = true; ok = true;
} }
if (command == "custom_entities") { if (command == "custom_entities") {
shell.printfln("custom entities..."); shell.printfln("custom entities...");
run_test("general"); test("general");
#ifdef EMSESP_STANDALONE #ifdef EMSESP_STANDALONE
AsyncWebServerRequest request; AsyncWebServerRequest request;
@@ -318,7 +351,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "coldshot") { if (command == "coldshot") {
shell.printfln("Testing coldshot..."); shell.printfln("Testing coldshot...");
run_test("general"); test("general");
#ifdef EMSESP_STANDALONE #ifdef EMSESP_STANDALONE
AsyncWebServerRequest request; AsyncWebServerRequest request;
@@ -370,7 +403,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "modes") { if (command == "modes") {
shell.printfln("Testing thermostat modes..."); shell.printfln("Testing thermostat modes...");
run_test("general"); test("general");
shell.invoke_command("call thermostat mode auto"); shell.invoke_command("call thermostat mode auto");
shell.invoke_command("call thermostat mode Manuell"); // DE shell.invoke_command("call thermostat mode Manuell"); // DE
shell.invoke_command("call thermostat mode 1"); shell.invoke_command("call thermostat mode 1");
@@ -506,13 +539,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "gateway") { if (command == "gateway") {
shell.printfln("Testing Gateway..."); shell.printfln("Testing Gateway...");
run_test("gateway"); test("gateway");
ok = true; ok = true;
} }
if (command == "310") { if (command == "310") {
shell.printfln("Testing RC310..."); shell.printfln("Testing RC310...");
run_test("310"); test("310");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
shell.invoke_command("show values"); shell.invoke_command("show values");
shell.invoke_command("call system publish"); shell.invoke_command("call system publish");
@@ -522,7 +555,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "heat_exchange") { if (command == "heat_exchange") {
shell.printfln("Testing heat exchange..."); shell.printfln("Testing heat exchange...");
run_test("heat_exchange"); test("heat_exchange");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
shell.invoke_command("show values"); shell.invoke_command("show values");
ok = true; ok = true;
@@ -530,7 +563,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "2thermostats") { if (command == "2thermostats") {
shell.printfln("Testing multiple thermostats..."); shell.printfln("Testing multiple thermostats...");
run_test("2thermostats"); test("2thermostats");
shell.invoke_command("show values"); shell.invoke_command("show values");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
ok = true; ok = true;
@@ -542,8 +575,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::enabled(false); // turn off mqtt Mqtt::enabled(false); // turn off mqtt
Mqtt::ha_enabled(false); // turn off ha Mqtt::ha_enabled(false); // turn off ha
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
JsonDocument doc; // some absurd high number JsonDocument doc; // some absurd high number
for (const auto & emsdevice : EMSESP::emsdevices) { for (const auto & emsdevice : EMSESP::emsdevices) {
@@ -596,7 +629,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
Mqtt::nested_format(1); Mqtt::nested_format(1);
run_test("boiler"); test("boiler");
shell.invoke_command("show devices"); shell.invoke_command("show devices");
shell.invoke_command("show values"); shell.invoke_command("show values");
shell.invoke_command("call boiler info"); shell.invoke_command("call boiler info");
@@ -622,7 +655,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "shower_alert") { if (command == "shower_alert") {
shell.printfln("Testing Shower Alert..."); shell.printfln("Testing Shower Alert...");
run_test("boiler"); test("boiler");
// device type, command, data // device type, command, data
Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false"); Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
@@ -650,10 +683,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::nested_format(1); // is nested Mqtt::nested_format(1); // is nested
// Mqtt::nested_format(2); // not nested // Mqtt::nested_format(2); // not nested
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
run_test("solar"); test("solar");
run_test("mixer"); test("mixer");
shell.invoke_command("call system publish"); shell.invoke_command("call system publish");
shell.invoke_command("show mqtt"); shell.invoke_command("show mqtt");
@@ -672,8 +705,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::nested_format(1); Mqtt::nested_format(1);
// Mqtt::send_response(false); // Mqtt::send_response(false);
run_test("boiler"); test("boiler");
// run_test("thermostat"); // test("thermostat");
// 0xC2 // 0xC2
// [emsesp] Boiler(0x08) -> Me(0x0B), UBAErrorMessage3(0xC2), data: 08 AC 00 10 31 48 30 31 15 80 95 0B 0E 10 38 00 7F FF FF FF 08 AC 00 10 09 41 30 // [emsesp] Boiler(0x08) -> Me(0x0B), UBAErrorMessage3(0xC2), data: 08 AC 00 10 31 48 30 31 15 80 95 0B 0E 10 38 00 7F FF FF FF 08 AC 00 10 09 41 30
@@ -692,8 +725,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::nested_format(1); Mqtt::nested_format(1);
// Mqtt::send_response(false); // Mqtt::send_response(false);
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
shell.invoke_command("call boiler wwseltemp"); shell.invoke_command("call boiler wwseltemp");
shell.invoke_command("call system publish"); shell.invoke_command("call system publish");
@@ -745,15 +778,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
} }
if (command == "healthcheck") { if (command == "healthcheck") {
uint8_t n = 0;
if (!data.empty()) {
n = Helpers::atoint(data.c_str());
}
// n=1 = EMSESP::system_.HEALTHCHECK_NO_BUS // n=1 = EMSESP::system_.HEALTHCHECK_NO_BUS
// n=2 = EMSESP::system_.HEALTHCHECK_NO_NETWORK // n=2 = EMSESP::system_.HEALTHCHECK_NO_NETWORK
shell.printfln("Testing healthcheck with %d", n); if (id1 == -1) {
EMSESP::system_.healthcheck(n); id1 = 0;
}
shell.printfln("Testing healthcheck with %d", id1);
EMSESP::system_.healthcheck(id1);
ok = true; ok = true;
} }
@@ -763,7 +794,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
// Mqtt::send_response(false); // Mqtt::send_response(false);
run_test("thermostat"); test("thermostat");
// shell.invoke_command("call thermostat seltemp"); // shell.invoke_command("call thermostat seltemp");
// shell.invoke_command("call system publish"); // shell.invoke_command("call system publish");
@@ -794,7 +825,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
// Mqtt::send_response(false); // Mqtt::send_response(false);
run_test("boiler"); test("boiler");
shell.invoke_command("call boiler wwseltemp"); shell.invoke_command("call boiler wwseltemp");
shell.invoke_command("call system publish"); shell.invoke_command("call system publish");
@@ -819,7 +850,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::ha_enabled(true); Mqtt::ha_enabled(true);
// Mqtt::send_response(false); // Mqtt::send_response(false);
run_test("boiler"); test("boiler");
shell.invoke_command("call boiler wwseltemp"); shell.invoke_command("call boiler wwseltemp");
shell.invoke_command("call system publish"); shell.invoke_command("call system publish");
@@ -842,8 +873,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// EMSESP::bool_format(BOOL_FORMAT_10); // BOOL_FORMAT_10_STR // EMSESP::bool_format(BOOL_FORMAT_10); // BOOL_FORMAT_10_STR
EMSESP::system_.bool_format(BOOL_FORMAT_TRUEFALSE); // BOOL_FORMAT_TRUEFALSE_STR EMSESP::system_.bool_format(BOOL_FORMAT_TRUEFALSE); // BOOL_FORMAT_TRUEFALSE_STR
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
AsyncWebServerRequest request; AsyncWebServerRequest request;
JsonDocument doc; JsonDocument doc;
@@ -875,8 +906,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::system_.bool_format(BOOL_FORMAT_10); // BOOL_FORMAT_10_STR EMSESP::system_.bool_format(BOOL_FORMAT_10); // BOOL_FORMAT_10_STR
// EMSESP::bool_format(BOOL_FORMAT_TRUEFALSE); // BOOL_FORMAT_TRUEFALSE_STR // EMSESP::bool_format(BOOL_FORMAT_TRUEFALSE); // BOOL_FORMAT_TRUEFALSE_STR
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59"); EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
ok = true; ok = true;
@@ -887,15 +918,15 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.printfln("Testing API wwmode"); shell.printfln("Testing API wwmode");
Mqtt::ha_enabled(false); Mqtt::ha_enabled(false);
Mqtt::nested_format(1); Mqtt::nested_format(1);
run_test("310"); test("310");
AsyncWebServerRequest request; AsyncWebServerRequest request;
request.method(HTTP_POST); request.method(HTTP_POST);
JsonDocument doc; JsonDocument doc;
JsonVariant json; JsonVariant json;
char data[] = "{\"value\":\"off\"}"; char odata[] = "{\"value\":\"off\"}";
deserializeJson(doc, data); deserializeJson(doc, odata);
json = doc.as<JsonVariant>(); json = doc.as<JsonVariant>();
request.url("/api/thermostat/wwmode"); request.url("/api/thermostat/wwmode");
EMSESP::webAPIService.webAPIService_post(&request, json); EMSESP::webAPIService.webAPIService_post(&request, json);
@@ -911,8 +942,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::nested_format(1); Mqtt::nested_format(1);
// Mqtt::send_response(true); // Mqtt::send_response(true);
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
AsyncWebServerRequest requestX; AsyncWebServerRequest requestX;
JsonDocument docX; JsonDocument docX;
@@ -1181,10 +1212,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.printfln("Testing nested MQTT"); shell.printfln("Testing nested MQTT");
Mqtt::ha_enabled(false); // turn off HA Discovery to stop the chatter Mqtt::ha_enabled(false); // turn off HA Discovery to stop the chatter
run_test("boiler"); test("boiler");
run_test("thermostat"); test("thermostat");
run_test("solar"); test("solar");
run_test("mixer"); test("mixer");
// first with nested // first with nested
Mqtt::nested_format(1); Mqtt::nested_format(1);
@@ -1201,7 +1232,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "thermostat") { if (command == "thermostat") {
shell.printfln("Testing adding a thermostat FW120..."); shell.printfln("Testing adding a thermostat FW120...");
run_test("thermostat"); test("thermostat");
shell.invoke_command("show values"); shell.invoke_command("show values");
shell.invoke_command("call system publish"); shell.invoke_command("call system publish");
@@ -1229,7 +1260,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "solar") { if (command == "solar") {
shell.printfln("Testing Solar"); shell.printfln("Testing Solar");
run_test("solar"); test("solar");
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on (1)sh uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on (1)sh
EMSESP::show_device_values(shell); EMSESP::show_device_values(shell);
@@ -1243,7 +1274,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "heatpump") { if (command == "heatpump") {
shell.printfln("Testing Heat Pump"); shell.printfln("Testing Heat Pump");
run_test("heatpump"); test("heatpump");
shell.invoke_command("call"); shell.invoke_command("call");
shell.invoke_command("call heatpump info"); shell.invoke_command("call heatpump info");
ok = true; ok = true;
@@ -1698,7 +1729,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
if (command == "mixer") { if (command == "mixer") {
shell.printfln("Testing Mixer..."); shell.printfln("Testing Mixer...");
run_test("mixer"); test("mixer");
// check for error "No telegram type handler found for ID 0x255 (src 0x20)" // check for error "No telegram type handler found for ID 0x255 (src 0x20)"
uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A}); uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A});

View File

@@ -22,6 +22,7 @@
#define EMSESP_TEST_H #define EMSESP_TEST_H
#include "emsesp.h" #include "emsesp.h"
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
namespace emsesp { namespace emsesp {
@@ -60,8 +61,8 @@ namespace emsesp {
class Test { class Test {
public: public:
static void run_test(uuid::console::Shell & shell, const std::string & command, const std::string & data = ""); static void run_test(uuid::console::Shell & shell, const std::string & command, const std::string & id1 = "", const std::string & id2 = "");
static bool run_test(const char * command, int8_t id = 0); static bool test(const std::string & command, int8_t id1 = -1, int8_t id2 = -1);
static void dummy_mqtt_commands(const char * message); static void dummy_mqtt_commands(const char * message);
static void rx_telegram(const std::vector<uint8_t> & data); static void rx_telegram(const std::vector<uint8_t> & data);
static void uart_telegram(const std::vector<uint8_t> & rx_data); static void uart_telegram(const std::vector<uint8_t> & rx_data);