mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
more API tests
This commit is contained in:
@@ -482,8 +482,9 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
// first with nested
|
// first with nested
|
||||||
Mqtt::nested_format(1);
|
Mqtt::nested_format(1);
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
shell.invoke_command("show mqtt");
|
||||||
|
|
||||||
// then without nested
|
// then without nested - single mode
|
||||||
Mqtt::nested_format(2);
|
Mqtt::nested_format(2);
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
@@ -829,6 +830,9 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
if (command == "mqtt") {
|
if (command == "mqtt") {
|
||||||
shell.printfln(F("Testing MQTT..."));
|
shell.printfln(F("Testing MQTT..."));
|
||||||
|
|
||||||
|
Mqtt::ha_enabled(false);
|
||||||
|
Mqtt::enabled(true);
|
||||||
|
|
||||||
// add a boiler
|
// add a boiler
|
||||||
add_device(0x08, 123); // Nefit Trendline
|
add_device(0x08, 123); // Nefit Trendline
|
||||||
|
|
||||||
@@ -841,6 +845,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
uart_telegram("98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03"); // without CRC
|
uart_telegram("98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03"); // without CRC
|
||||||
uart_telegram_withCRC("98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03 13"); // with CRC
|
uart_telegram_withCRC("98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03 13"); // with CRC
|
||||||
|
|
||||||
|
shell.invoke_command("call system publish");
|
||||||
|
shell.invoke_command("show mqtt");
|
||||||
shell.loop_all();
|
shell.loop_all();
|
||||||
|
|
||||||
char boiler_topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char boiler_topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
@@ -853,11 +859,11 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
strcpy(thermostat_topic, "ems-esp/thermostat");
|
strcpy(thermostat_topic, "ems-esp/thermostat");
|
||||||
strcpy(system_topic, "ems-esp/system");
|
strcpy(system_topic, "ems-esp/system");
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming(boiler_topic, ""); // test if ignore empty payloads // invalid format
|
EMSESP::mqtt_.incoming(boiler_topic, ""); // test if ignore empty payloads
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming(boiler_topic, "12345"); // invalid format
|
EMSESP::mqtt_.incoming(boiler_topic, "12345"); // error: invalid format
|
||||||
EMSESP::mqtt_.incoming("bad_topic", "12345"); // no matching topic
|
EMSESP::mqtt_.incoming("bad_topic", "12345"); // error: no matching topic
|
||||||
EMSESP::mqtt_.incoming(boiler_topic, "{\"cmd\":\"garbage\",\"data\":22.52}"); // should report error
|
EMSESP::mqtt_.incoming(boiler_topic, "{\"cmd\":\"garbage\",\"data\":22.52}"); // error: should report error
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming(boiler_topic, "{\"cmd\":\"comfort\",\"data\":\"eco\"}");
|
EMSESP::mqtt_.incoming(boiler_topic, "{\"cmd\":\"comfort\",\"data\":\"eco\"}");
|
||||||
EMSESP::mqtt_.incoming(boiler_topic, "{\"cmd\":\"wwactivated\",\"data\":\"1\"}"); // with quotes
|
EMSESP::mqtt_.incoming(boiler_topic, "{\"cmd\":\"wwactivated\",\"data\":\"1\"}"); // with quotes
|
||||||
@@ -953,16 +959,18 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
run_test("general");
|
run_test("general");
|
||||||
AsyncWebServerRequest request;
|
AsyncWebServerRequest request;
|
||||||
|
|
||||||
request.url("/api/boiler/id");
|
// GET
|
||||||
EMSESP::webAPIService.webAPIService_get(&request);
|
|
||||||
|
|
||||||
request.url("/api/thermostat");
|
request.url("/api/thermostat");
|
||||||
EMSESP::webAPIService.webAPIService_get(&request);
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
|
request.url("/api/thermostat/info");
|
||||||
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
|
|
||||||
|
// these next 2 should fail
|
||||||
|
request.url("/api/boiler/id");
|
||||||
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
request.url("/api/thermostat/hamode");
|
request.url("/api/thermostat/hamode");
|
||||||
EMSESP::webAPIService.webAPIService_get(&request);
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
|
|
||||||
// GET
|
|
||||||
request.method(HTTP_GET);
|
request.method(HTTP_GET);
|
||||||
request.url("/api/thermostat/seltemp");
|
request.url("/api/thermostat/seltemp");
|
||||||
EMSESP::webAPIService.webAPIService_get(&request);
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ namespace emsesp {
|
|||||||
// #define EMSESP_DEBUG_DEFAULT "general"
|
// #define EMSESP_DEBUG_DEFAULT "general"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "boiler"
|
// #define EMSESP_DEBUG_DEFAULT "boiler"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
|
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
|
#define EMSESP_DEBUG_DEFAULT "mqtt_nested"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "ha"
|
// #define EMSESP_DEBUG_DEFAULT "ha"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "board_profile"
|
// #define EMSESP_DEBUG_DEFAULT "board_profile"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "shower_alert"
|
// #define EMSESP_DEBUG_DEFAULT "shower_alert"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "310"
|
// #define EMSESP_DEBUG_DEFAULT "310"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "render"
|
// #define EMSESP_DEBUG_DEFAULT "render"
|
||||||
#define EMSESP_DEBUG_DEFAULT "api"
|
// #define EMSESP_DEBUG_DEFAULT "api"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "crash"
|
// #define EMSESP_DEBUG_DEFAULT "crash"
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
|
|||||||
Reference in New Issue
Block a user