Skip to content

Commit

Permalink
add test for analogsensors
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Feb 22, 2025
1 parent ab80c82 commit 0171031
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.printfln("Testing adding Analog sensor");
Mqtt::ha_enabled(true);
// Mqtt::ha_enabled(false);

Mqtt::nested_format(1);
// Mqtt::nested_format(0);

// Mqtt::send_response(false);

// load some EMS data
Expand All @@ -885,6 +883,23 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
request.url("/api/analogsensor/36");
EMSESP::webAPIService.webAPIService(&request);

// test setting a value
request.method(HTTP_POST);
JsonDocument doc;

char data[] = "{\"value\":10,\"id\":33}";
deserializeJson(doc, data);
request.url("/api/analogsensor/setvalue");
EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
shell.invoke_command("call analogsensor test_analogsensor4");

char data2[] = "{\"value\":11}";
deserializeJson(doc, data2);
request.url("/api/analogsensor/test_analogsensor4");
EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());

shell.invoke_command("call analogsensor test_analogsensor4");

// test renaming it
// bool update(uint8_t id, const std::string & name, int16_t offset, float factor, uint8_t uom, uint8_t type);
// EMSESP::analogsensor_.update(36, "test_analog1_new", 2, 0.7, 17, 1);
Expand Down Expand Up @@ -1071,6 +1086,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// EMSESP::webAPIService.webAPIService(&request);
// request.url("/api/thermostat/hc1");
// EMSESP::webAPIService.webAPIService(&request);
// request.url("/api/boiler/comfort/value");
// EMSESP::webAPIService.webAPIService(&request);

// POST COMMANDS
request.method(HTTP_POST);
Expand Down

0 comments on commit 0171031

Please sign in to comment.