mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
Merge branch 'dev'
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
# The response will be shown in the right panel
|
||||
|
||||
# @host = http://ems-esp.local
|
||||
@host = http://192.168.1.225
|
||||
@host_dev = http://10.10.10.175
|
||||
@host = http://192.168.1.223
|
||||
@host_dev = http://192.168.1.65
|
||||
@host_standalone = http://localhost:3080
|
||||
@host_standalone2 = http://localhost:3082
|
||||
|
||||
@@ -17,6 +17,17 @@ GET {{host}}/api/system/info
|
||||
|
||||
GET {{host}}/api/thermostat/seltemp
|
||||
|
||||
###
|
||||
|
||||
POST {{host}}/api/system/message
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : "system/settings/locale"
|
||||
}
|
||||
|
||||
|
||||
###
|
||||
|
||||
POST {{host}}/api/thermostat/seltemp
|
||||
@@ -74,12 +85,98 @@ Authorization: Bearer {{token}}
|
||||
|
||||
GET {{host}}/api/boiler/commands
|
||||
|
||||
###
|
||||
|
||||
POST {{host}}/api/custom/test_custom
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : 22.0
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
GET {{host}}/api/custom/test_custom
|
||||
|
||||
#
|
||||
# Test on dev
|
||||
# Tests on dev
|
||||
#
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/system/message
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : "'hello world'"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/system/message
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : "system/settings/locale"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/system/message
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : "custom/test_custom"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/thermostat/seltemp
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : 21.0
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/system/txpause
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : "on"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/system/txpause
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"value" : "off"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
GET {{host_dev}}/api/system/settings/txMode/value
|
||||
|
||||
###
|
||||
|
||||
GET {{host_dev}}/api/system/settings/locale/value
|
||||
|
||||
###
|
||||
|
||||
POST {{host_dev}}/api/system/settings/locale/value
|
||||
|
||||
###
|
||||
|
||||
GET {{host_dev}}/api/system/info
|
||||
|
||||
###
|
||||
|
||||
69
test/test_api/api_test.js
Normal file
69
test/test_api/api_test.js
Normal file
@@ -0,0 +1,69 @@
|
||||
// npm install axios
|
||||
// node api_test.js
|
||||
const axios = require('axios');
|
||||
|
||||
async function testAPI(ip = "ems-esp.local", apiPath = "system", loopCount = 1, delayMs = 1000) {
|
||||
const baseUrl = `http://${ip}`;
|
||||
const url = `${baseUrl}/${apiPath}`;
|
||||
const results = [];
|
||||
const testStartTime = Date.now();
|
||||
|
||||
for (let i = 0; i < loopCount; i++) {
|
||||
let logMessage = '';
|
||||
if (loopCount > 1) {
|
||||
const totalElapsed = ((Date.now() - testStartTime) / 1000).toFixed(1);
|
||||
logMessage = `[${totalElapsed}s] Request: ${i + 1}/${loopCount},`;
|
||||
}
|
||||
|
||||
try {
|
||||
const startTime = Date.now();
|
||||
const response = await axios.get(url, {
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
logMessage += (logMessage ? ' ' : '') + `URL: ${url}, Status: ${response.status}`;
|
||||
} catch (error) {
|
||||
console.error('Error:', error.message);
|
||||
// if (error.response) {
|
||||
// console.error('Response status:', error.response.status);
|
||||
// console.error('Response data:', error.response.data);
|
||||
// }
|
||||
throw error;
|
||||
}
|
||||
|
||||
// if successful make another request to the /api/system/info endpoint to fetch the freeMem
|
||||
const response = await axios.get(`${baseUrl}/api/system/info`);
|
||||
const freeMem = response.data?.freeMem || response.data?.system?.freeMem;
|
||||
if (freeMem !== undefined) {
|
||||
logMessage += `, freeMem: ${freeMem}`;
|
||||
} else {
|
||||
logMessage += 'freeMem not found in response';
|
||||
}
|
||||
console.log(logMessage);
|
||||
|
||||
// Delay before next request (except for the last one)
|
||||
if (i < loopCount - 1) {
|
||||
await new Promise(resolve => setTimeout(resolve, delayMs));
|
||||
}
|
||||
}
|
||||
|
||||
return loopCount === 1 ? results[0] : results;
|
||||
}
|
||||
|
||||
// Run the test
|
||||
// Examples:
|
||||
// testAPI("192.168.1.65", "api/system") - single call
|
||||
// testAPI("192.168.1.65", "api/system", 5) - 5 calls with 1000ms delay
|
||||
// testAPI("192.168.1.65", "api/system", 10, 2000) - 10 calls with 2000ms delay
|
||||
// testAPI("192.168.1.65", "status", 20000, 5)
|
||||
testAPI("192.168.1.65", "api/custom/test_custom", 1000, 5)
|
||||
.then(() => {
|
||||
console.log('Test completed successfully');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Test failed:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -4,7 +4,7 @@
|
||||
# Command line test for the API
|
||||
#
|
||||
|
||||
emsesp_url="http://192.168.1.225"
|
||||
emsesp_url="http://192.168.1.223"
|
||||
|
||||
# get the token from the Security page. This is the token for the admin user, unless changed it'll always be the same
|
||||
emsesp_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg"
|
||||
@@ -22,6 +22,15 @@ curl -X POST \
|
||||
|
||||
echo "\n"
|
||||
|
||||
# This example will use the message command to get the locale (en)
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"value":"system/settings/locale"}' \
|
||||
${emsesp_url}/api/system/message
|
||||
|
||||
echo "\n"
|
||||
|
||||
# This example will export all values to a json file, including custom entities, sensors and schedules
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer ${emsesp_token}" \
|
||||
@@ -34,7 +43,7 @@ echo "\n"
|
||||
# This example is how to call a service in Home Assistant via the API
|
||||
# Which can be added to an EMS-EPS schedule
|
||||
|
||||
ha_url="http://192.168.1.42:8123"
|
||||
ha_url="http://192.168.1.86:8123"
|
||||
ha_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIwMzMyZjU1MjhlZmM0NGIyOTgyMjIxNThiODU1NDkyNSIsImlhdCI6MTcyMTMwNDg2NSwiZXhwIjoyMDM2NjY0ODY1fQ.Q-Y7E_i7clH3ff4Ma-OMmhZfbN7aMi_CahKwmoar"
|
||||
|
||||
curl -X POST \
|
||||
|
||||
5
test/test_api/package.json
Normal file
5
test/test_api/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.13.2"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* EMS-ESP - https://github.com/emsesp/EMS-ESP
|
||||
* Copyright 2020-2024 emsesp.org - proddy, MichaelDvP
|
||||
* Copyright 2020-2025 emsesp.org - proddy, MichaelDvP
|
||||
*
|
||||
* 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
|
||||
@@ -16,14 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// tip: use https://jsondiff.com/ to compare the expected and actual responses.
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <unity.h>
|
||||
|
||||
#include <emsesp.h>
|
||||
|
||||
#include "ESPAsyncWebServer.h"
|
||||
#include "web/WebAPIService.h"
|
||||
#include "test_shuntingYard.hpp"
|
||||
#include "test_shuntingYard.h"
|
||||
|
||||
using namespace emsesp;
|
||||
|
||||
@@ -37,8 +38,8 @@ WebAPIService * webAPIService;
|
||||
EMSESP application;
|
||||
FS dummyFS;
|
||||
|
||||
std::shared_ptr<emsesp::EMSESPConsole> shell;
|
||||
char output_buffer[4096];
|
||||
std::shared_ptr<EMSESPConsole> shell;
|
||||
char output_buffer[4096];
|
||||
|
||||
class TestStream : public Stream {
|
||||
public:
|
||||
@@ -280,6 +281,80 @@ void manual_test6() {
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/setvalue", data));
|
||||
}
|
||||
|
||||
void manual_test7() {
|
||||
auto expected_response = "[{}]"; // empty is good
|
||||
char data[] = "{\"value\":9}";
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_ram", data));
|
||||
}
|
||||
|
||||
void manual_test8() {
|
||||
const char * response = call_url("/api/boiler/metrics");
|
||||
|
||||
TEST_ASSERT_NOT_NULL(response);
|
||||
TEST_ASSERT_TRUE(strlen(response) > 0);
|
||||
|
||||
TEST_ASSERT_TRUE(strstr(response, "# HELP") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, "# TYPE") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, "emsesp_") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, " gauge") != nullptr);
|
||||
|
||||
if (strstr(response, ", enum, (") != nullptr) {
|
||||
TEST_ASSERT_TRUE(strstr(response, ", enum, (") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, ")") != nullptr);
|
||||
}
|
||||
TEST_ASSERT_TRUE(strstr(response, "emsesp_tapwateractive") != nullptr || strstr(response, "emsesp_selflowtemp") != nullptr
|
||||
|| strstr(response, "emsesp_curflowtemp") != nullptr);
|
||||
}
|
||||
|
||||
void manual_test9() {
|
||||
const char * response = call_url("/api/thermostat/metrics");
|
||||
|
||||
TEST_ASSERT_NOT_NULL(response);
|
||||
TEST_ASSERT_TRUE(strlen(response) > 0);
|
||||
|
||||
TEST_ASSERT_TRUE(strstr(response, "# HELP") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, "# TYPE") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, "emsesp_") != nullptr);
|
||||
|
||||
if (strstr(response, ", enum, (") != nullptr) {
|
||||
TEST_ASSERT_TRUE(strstr(response, ", enum, (") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, ")") != nullptr);
|
||||
}
|
||||
if (strstr(response, "circuit=") != nullptr) {
|
||||
TEST_ASSERT_TRUE(strstr(response, "{circuit=") != nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void manual_test10() {
|
||||
const char * response = call_url("/api/system/metrics");
|
||||
|
||||
TEST_ASSERT_NOT_NULL(response);
|
||||
TEST_ASSERT_TRUE(strlen(response) > 0);
|
||||
|
||||
TEST_ASSERT_TRUE(strstr(response, "# HELP") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, "# TYPE") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, "emsesp_") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, " gauge") != nullptr);
|
||||
|
||||
if (strstr(response, ", enum, (") != nullptr) {
|
||||
TEST_ASSERT_TRUE(strstr(response, ", enum, (") != nullptr);
|
||||
TEST_ASSERT_TRUE(strstr(response, ")") != nullptr);
|
||||
}
|
||||
// Check for some expected system metrics
|
||||
TEST_ASSERT_TRUE(strstr(response, "emsesp_system_") != nullptr || strstr(response, "emsesp_network_") != nullptr
|
||||
|| strstr(response, "emsesp_api_") != nullptr);
|
||||
|
||||
// Check for _info metrics if present
|
||||
if (strstr(response, "_info") != nullptr) {
|
||||
TEST_ASSERT_TRUE(strstr(response, "_info{") != nullptr || strstr(response, "_info ") != nullptr);
|
||||
}
|
||||
|
||||
// Check for device metrics if devices are present
|
||||
if (strstr(response, "device") != nullptr) {
|
||||
TEST_ASSERT_TRUE(strstr(response, "emsesp_device_") != nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void run_manual_tests() {
|
||||
RUN_TEST(manual_test1);
|
||||
@@ -288,6 +363,10 @@ void run_manual_tests() {
|
||||
RUN_TEST(manual_test4);
|
||||
RUN_TEST(manual_test5);
|
||||
RUN_TEST(manual_test6);
|
||||
RUN_TEST(manual_test7);
|
||||
RUN_TEST(manual_test8);
|
||||
RUN_TEST(manual_test9);
|
||||
RUN_TEST(manual_test10);
|
||||
}
|
||||
|
||||
const char * run_console_command(const char * command) {
|
||||
@@ -345,6 +424,7 @@ void create_tests() {
|
||||
capture("/api/boiler/values");
|
||||
capture("/api/boiler/info");
|
||||
// capture("/api/boiler/entities"); // skipping since payload is too large
|
||||
capture("/api/boiler/metrics");
|
||||
capture("/api/boiler/comfort");
|
||||
capture("/api/boiler/comfort/value");
|
||||
capture("/api/boiler/comfort/fullname");
|
||||
@@ -356,20 +436,24 @@ void create_tests() {
|
||||
// thermostat
|
||||
capture("/api/thermostat");
|
||||
capture("/api/thermostat/hc1/values");
|
||||
capture("/api/thermostat/metrics");
|
||||
capture("/api/thermostat/hc1/seltemp");
|
||||
capture("/api/thermostat/hc2/seltemp");
|
||||
|
||||
// custom
|
||||
capture("/api/custom");
|
||||
capture("/api/custom/info");
|
||||
capture("/api/custom/seltemp");
|
||||
capture("/api/custom/test_seltemp");
|
||||
capture("/api/custom/test_seltemp/value");
|
||||
capture("/api/custom/test_custom");
|
||||
|
||||
// system
|
||||
capture("/api/system");
|
||||
capture("/api/system/info");
|
||||
capture("/api/system/metrics");
|
||||
capture("/api/system/settings/locale");
|
||||
capture("/api/system/fetch");
|
||||
capture("api/system/network/values");
|
||||
capture("/api/system/network/values");
|
||||
|
||||
// scheduler
|
||||
capture("/api/scheduler");
|
||||
@@ -389,7 +473,10 @@ void create_tests() {
|
||||
capture("/api/analogsensor/test_analogsensor1");
|
||||
capture("/api/analogsensor/test_analogsensor1/offset");
|
||||
|
||||
// these tests should all fail...
|
||||
//
|
||||
// these next tests should all fail...
|
||||
//
|
||||
|
||||
capture("/api/boiler2");
|
||||
capture("/api/boiler/bad/value");
|
||||
capture("/api/boiler/comfort/valu");
|
||||
@@ -405,8 +492,8 @@ void create_tests() {
|
||||
capture("/api/scheduler/test_scheduler2/val2");
|
||||
|
||||
// custom
|
||||
capture("/api/custom/seltemp2");
|
||||
capture("/api/custom/seltemp/val");
|
||||
capture("/api/custom/test_seltemp2");
|
||||
capture("/api/custom/test_seltemp/val");
|
||||
|
||||
// temperaturesensor
|
||||
capture("/api/temperaturesensor/test_sensor20");
|
||||
@@ -437,15 +524,17 @@ int main() {
|
||||
|
||||
application.start(); // calls begin()
|
||||
|
||||
EMSESP::webCustomEntityService.test(); // custom entities
|
||||
EMSESP::webCustomizationService.test(); // set customizations - this will overwrite any settings in the FS
|
||||
EMSESP::temperaturesensor_.test(); // add temperature sensors
|
||||
EMSESP::webSchedulerService.test(); // run scheduler tests, and conditions
|
||||
// populate with data, like custom entities, fake temp sensors and scheduler items
|
||||
EMSESP::webCustomEntityService.load_test_data(); // custom entities
|
||||
EMSESP::webCustomizationService.load_test_data(); // set customizations - this will overwrite any settings in the FS
|
||||
EMSESP::temperaturesensor_.load_test_data(); // add temperature sensors
|
||||
EMSESP::webSchedulerService.load_test_data(); // run scheduler tests, and conditions
|
||||
|
||||
add_devices(); // add devices
|
||||
|
||||
#if defined(EMSESP_UNITY_CREATE)
|
||||
create_tests();
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
//
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
// **************************************************************************************************
|
||||
//
|
||||
// Compile with -DEMSESP_UNITY_CREATE to generate the test functions, copy the output and paste below.
|
||||
//
|
||||
// TODO convert output to JSON and compare, showing differences
|
||||
//
|
||||
// You can also manually compare the differences using https://www.diffchecker.com/text-compare/
|
||||
//
|
||||
// **************************************************************************************************
|
||||
|
||||
// ---------- START - CUT HERE ----------
|
||||
|
||||
void test_1() {
|
||||
auto expected_response =
|
||||
"[{\"reset\":\"\",\"heatingoff\":\"off\",\"heatingactive\":\"off\",\"tapwateractive\":\"on\",\"selflowtemp\":0,\"curflowtemp\":60.2,\"rettemp\":48.1,"
|
||||
"\"syspress\":1.4,\"burngas\":\"on\",\"burngas2\":\"off\",\"flamecurr\":37.4,\"fanwork\":\"on\",\"ignwork\":\"off\",\"oilpreheat\":\"off\","
|
||||
"\"heatingpump\":\"on\",\"selburnpow\":115,\"curburnpow\":61,\"ubauptime\":3940268,\"servicecode\":\"=H\",\"servicecodenumber\":201,\"nompower\":0,"
|
||||
"\"nrgtotal\":0.0,\"nrgheat\":0.0,\"dhw\":{\"seltemp\":52,\"comfort\":\"hot\",\"flowtempoffset\":40,\"circpump\":\"off\",\"chargetype\":\"3-way "
|
||||
"valve\",\"hyston\":-5,\"hystoff\":0,\"disinfectiontemp\":70,\"circmode\":\"off\",\"circ\":\"off\",\"storagetemp1\":53.8,\"activated\":\"on\","
|
||||
"\"3wayvalve\":\"on\",\"nrg\":0.0}}]";
|
||||
"[{\"reset\":\"\",\"chimneysweeper\":\"\",\"heatingoff\":\"off\",\"heatingactive\":\"off\",\"tapwateractive\":\"on\",\"selflowtemp\":0,\"curflowtemp\":"
|
||||
"60.2,\"rettemp\":48.1,\"syspress\":1.4,\"burngas\":\"on\",\"burngas2\":\"off\",\"flamecurr\":37.4,\"fanwork\":\"on\",\"ignwork\":\"off\","
|
||||
"\"oilpreheat\":\"off\",\"heatingpump\":\"on\",\"selburnpow\":115,\"curburnpow\":61,\"ubauptime\":3940268,\"servicecode\":\"=H\",\"servicecodenumber\":"
|
||||
"201,\"nompower\":0,\"nrgtotal\":0.0,\"nrgheat\":0.0,\"dhw\":{\"seltemp\":52,\"comfort\":\"hot\",\"flowtempoffset\":40,\"chargeoptimization\":\"off\","
|
||||
"\"circpump\":\"off\",\"chargetype\":\"3-way "
|
||||
"valve\",\"hyston\":-5,\"disinfectiontemp\":70,\"circmode\":\"off\",\"circ\":\"off\",\"storagetemp1\":53.8,\"activated\":\"on\",\"3wayvalve\":\"on\","
|
||||
"\"chargepump\":\"off\",\"nrg\":0.0}}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler"));
|
||||
}
|
||||
|
||||
@@ -26,12 +17,13 @@ void test_2() {
|
||||
"[{\"info\":\"list all values (verbose)\",\"values\":\"list all values\",\"commands\":\"list all commands\",\"entities\":\"list all "
|
||||
"entities\",\"boil2hystoff\":\"hysteresis stage 2 off temperature\",\"boil2hyston\":\"hysteresis stage 2 on temperature\",\"boilhystoff\":\"hysteresis "
|
||||
"off temperature\",\"boilhyston\":\"hysteresis on temperature\",\"burnmaxpower\":\"burner max power\",\"burnminperiod\":\"burner min "
|
||||
"period\",\"burnminpower\":\"burner min power\",\"coldshot\":\"send a cold shot of water\",\"curvebase\":\"heatingcurve "
|
||||
"base\",\"curveend\":\"heatingcurve end\",\"curveon\":\"heatingcurve on\",\"dhw[n].activated\":\"activated\",\"dhw[n].chargeoptimization\":\"charge "
|
||||
"optimization\",\"dhw[n].circ\":\"circulation active\",\"dhw[n].circmode\":\"circulation pump mode\",\"dhw[n].circpump\":\"circulation pump "
|
||||
"available\",\"dhw[n].comfort\":\"comfort\",\"dhw[n].comfort1\":\"comfort "
|
||||
"mode\",\"dhw[n].disinfecting\":\"disinfecting\",\"dhw[n].disinfectiontemp\":\"disinfection temperature\",\"dhw[n].flowtempoffset\":\"flow temperature "
|
||||
"offset\",\"dhw[n].hystoff\":\"hysteresis off temperature\",\"dhw[n].hyston\":\"hysteresis on temperature\",\"dhw[n].maxpower\":\"max "
|
||||
"period\",\"burnminpower\":\"burner min power\",\"chimneysweeper\":\"chimney sweeper\",\"coldshot\":\"send a cold shot of "
|
||||
"water\",\"curvebase\":\"heatingcurve base\",\"curveend\":\"heatingcurve end\",\"curveon\":\"heatingcurve "
|
||||
"on\",\"dhw[n].activated\":\"activated\",\"dhw[n].chargeoptimization\":\"charge optimization\",\"dhw[n].circ\":\"circulation "
|
||||
"active\",\"dhw[n].circmode\":\"circulation pump mode\",\"dhw[n].circpump\":\"circulation pump "
|
||||
"available\",\"dhw[n].comfort\":\"comfort\",\"dhw[n].comfort1\":\"comfort mode\",\"dhw[n].dhwprio\":\"dhw "
|
||||
"priority\",\"dhw[n].disinfecting\":\"disinfecting\",\"dhw[n].disinfectiontemp\":\"disinfection temperature\",\"dhw[n].flowtempoffset\":\"flow "
|
||||
"temperature offset\",\"dhw[n].hystoff\":\"hysteresis off temperature\",\"dhw[n].hyston\":\"hysteresis on temperature\",\"dhw[n].maxpower\":\"max "
|
||||
"power\",\"dhw[n].maxtemp\":\"maximum temperature\",\"dhw[n].nrg\":\"energy\",\"dhw[n].onetime\":\"one time charging\",\"dhw[n].seltemp\":\"selected "
|
||||
"temperature\",\"dhw[n].seltemplow\":\"selected lower temperature\",\"dhw[n].seltempsingle\":\"single charge "
|
||||
"temperature\",\"dhw[n].tapactivated\":\"turn on/off\",\"dhw[n].tempecoplus\":\"selected eco+ temperature\",\"emergencyops\":\"emergency "
|
||||
@@ -47,28 +39,30 @@ void test_2() {
|
||||
|
||||
void test_3() {
|
||||
auto expected_response =
|
||||
"[{\"reset\":\"\",\"heatingoff\":\"off\",\"heatingactive\":\"off\",\"tapwateractive\":\"on\",\"selflowtemp\":0,\"curflowtemp\":60.2,\"rettemp\":48.1,"
|
||||
"\"syspress\":1.4,\"burngas\":\"on\",\"burngas2\":\"off\",\"flamecurr\":37.4,\"fanwork\":\"on\",\"ignwork\":\"off\",\"oilpreheat\":\"off\","
|
||||
"\"heatingpump\":\"on\",\"selburnpow\":115,\"curburnpow\":61,\"ubauptime\":3940268,\"servicecode\":\"=H\",\"servicecodenumber\":201,\"nompower\":0,"
|
||||
"\"nrgtotal\":0.0,\"nrgheat\":0.0,\"dhw\":{\"seltemp\":52,\"comfort\":\"hot\",\"flowtempoffset\":40,\"circpump\":\"off\",\"chargetype\":\"3-way "
|
||||
"valve\",\"hyston\":-5,\"hystoff\":0,\"disinfectiontemp\":70,\"circmode\":\"off\",\"circ\":\"off\",\"storagetemp1\":53.8,\"activated\":\"on\","
|
||||
"\"3wayvalve\":\"on\",\"nrg\":0.0}}]";
|
||||
"[{\"reset\":\"\",\"chimneysweeper\":\"\",\"heatingoff\":\"off\",\"heatingactive\":\"off\",\"tapwateractive\":\"on\",\"selflowtemp\":0,\"curflowtemp\":"
|
||||
"60.2,\"rettemp\":48.1,\"syspress\":1.4,\"burngas\":\"on\",\"burngas2\":\"off\",\"flamecurr\":37.4,\"fanwork\":\"on\",\"ignwork\":\"off\","
|
||||
"\"oilpreheat\":\"off\",\"heatingpump\":\"on\",\"selburnpow\":115,\"curburnpow\":61,\"ubauptime\":3940268,\"servicecode\":\"=H\",\"servicecodenumber\":"
|
||||
"201,\"nompower\":0,\"nrgtotal\":0.0,\"nrgheat\":0.0,\"dhw\":{\"seltemp\":52,\"comfort\":\"hot\",\"flowtempoffset\":40,\"chargeoptimization\":\"off\","
|
||||
"\"circpump\":\"off\",\"chargetype\":\"3-way "
|
||||
"valve\",\"hyston\":-5,\"disinfectiontemp\":70,\"circmode\":\"off\",\"circ\":\"off\",\"storagetemp1\":53.8,\"activated\":\"on\",\"3wayvalve\":\"on\","
|
||||
"\"chargepump\":\"off\",\"nrg\":0.0}}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/values"));
|
||||
}
|
||||
|
||||
void test_4() {
|
||||
auto expected_response =
|
||||
"[{\"reset (reset)\":\"\",\"force heating off (heatingoff)\":\"off\",\"is my heating on? (heatingactive)\":\"off\",\"tapwater active "
|
||||
"(tapwateractive)\":\"on\",\"selected flow temperature (selflowtemp)\":0,\"current flow temperature (curflowtemp)\":60.2,\"return temperature "
|
||||
"(rettemp)\":48.1,\"system pressure (syspress)\":1.4,\"gas (burngas)\":\"on\",\"gas stage 2 (burngas2)\":\"off\",\"flame current "
|
||||
"(flamecurr)\":37.4,\"fan (fanwork)\":\"on\",\"ignition (ignwork)\":\"off\",\"oil preheating (oilpreheat)\":\"off\",\"heating pump "
|
||||
"(heatingpump)\":\"on\",\"burner selected max power (selburnpow)\":115,\"burner current power (curburnpow)\":61,\"total UBA operating time "
|
||||
"(ubauptime)\":\"2736 days 7 hours 8 minutes\",\"service code (servicecode)\":\"=H\",\"service code number (servicecodenumber)\":201,\"dhw selected "
|
||||
"temperature (seltemp)\":52,\"dhw comfort (comfort)\":\"hot\",\"dhw flow temperature offset (flowtempoffset)\":40,\"dhw circulation pump available "
|
||||
"(circpump)\":\"off\",\"dhw charging type (chargetype)\":\"3-way valve\",\"dhw hysteresis on temperature (hyston)\":-5,\"dhw hysteresis off "
|
||||
"temperature (hystoff)\":0,\"dhw disinfection temperature (disinfectiontemp)\":70,\"dhw circulation pump mode (circmode)\":\"off\",\"dhw circulation "
|
||||
"active (circ)\":\"off\",\"dhw storage intern temperature (storagetemp1)\":53.8,\"dhw activated (activated)\":\"on\",\"dhw 3-way valve active "
|
||||
"(3wayvalve)\":\"on\",\"nominal Power (nompower)\":0,\"total energy (nrgtotal)\":0.0,\"energy heating (nrgheat)\":0.0,\"dhw energy (nrg)\":0.0}]";
|
||||
"[{\"reset (reset)\":\"\",\"chimney sweeper (chimneysweeper)\":\"\",\"force heating off (heatingoff)\":\"off\",\"is my heating on? "
|
||||
"(heatingactive)\":\"off\",\"tapwater active (tapwateractive)\":\"on\",\"selected flow temperature (selflowtemp)\":0,\"current flow temperature "
|
||||
"(curflowtemp)\":60.2,\"return temperature (rettemp)\":48.1,\"system pressure (syspress)\":1.4,\"gas (burngas)\":\"on\",\"gas stage 2 "
|
||||
"(burngas2)\":\"off\",\"flame current (flamecurr)\":37.4,\"fan (fanwork)\":\"on\",\"ignition (ignwork)\":\"off\",\"oil preheating "
|
||||
"(oilpreheat)\":\"off\",\"heating pump (heatingpump)\":\"on\",\"burner selected max power (selburnpow)\":115,\"burner current power "
|
||||
"(curburnpow)\":61,\"total UBA operating time (ubauptime)\":\"2736 days 7 hours 8 minutes\",\"service code (servicecode)\":\"=H\",\"service code "
|
||||
"number (servicecodenumber)\":201,\"dhw selected temperature (seltemp)\":52,\"dhw comfort (comfort)\":\"hot\",\"dhw flow temperature offset "
|
||||
"(flowtempoffset)\":40,\"dhw charge optimization (chargeoptimization)\":\"off\",\"dhw circulation pump available (circpump)\":\"off\",\"dhw charging "
|
||||
"type (chargetype)\":\"3-way valve\",\"dhw hysteresis on temperature (hyston)\":-5,\"dhw disinfection temperature (disinfectiontemp)\":70,\"dhw "
|
||||
"circulation pump mode (circmode)\":\"off\",\"dhw circulation active (circ)\":\"off\",\"dhw storage intern temperature (storagetemp1)\":53.8,\"dhw "
|
||||
"activated (activated)\":\"on\",\"dhw 3-way valve active (3wayvalve)\":\"on\",\"dhw charge pump (chargepump)\":\"off\",\"nominal Power "
|
||||
"(nompower)\":0,\"total energy (nrgtotal)\":0.0,\"energy heating (nrgheat)\":0.0,\"dhw energy (nrg)\":0.0}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/info"));
|
||||
}
|
||||
|
||||
@@ -93,7 +87,6 @@ void test_8() {
|
||||
auto expected_response = "[{\"name\":\"outdoortemp\",\"fullname\":\"outside "
|
||||
"temperature\",\"circuit\":\"\",\"type\":\"number\",\"uom\":\"°C\",\"state_class\":\"measurement\",\"device_class\":"
|
||||
"\"temperature\",\"readable\":true,\"writeable\":false,\"visible\":true}]";
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/outdoortemp"));
|
||||
}
|
||||
|
||||
@@ -140,236 +133,255 @@ void test_15() {
|
||||
}
|
||||
|
||||
void test_16() {
|
||||
auto expected_response = "[{\"test_custom\":0.00,\"test_read_only\":0.00,\"test_ram\":\"14\",\"seltemp\":\"14\"}]";
|
||||
auto expected_response = "[{\"test_custom\":0.00,\"test_read_only\":70.00,\"test_ram\":\"14\",\"test_seltemp\":\"14\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom"));
|
||||
}
|
||||
|
||||
void test_17() {
|
||||
auto expected_response = "[{\"test_custom\":0.00,\"test_read_only\":0.00,\"test_ram\":\"14\",\"seltemp\":\"14\"}]";
|
||||
auto expected_response = "[{\"test_custom\":0.00,\"test_read_only\":70.00,\"test_ram\":\"14\",\"test_seltemp\":\"14\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/info"));
|
||||
}
|
||||
|
||||
void test_18() {
|
||||
auto expected_response = "[{\"name\":\"seltemp\",\"fullname\":\"seltemp\",\"storage\":\"ram\",\"type\":\"number\",\"readable\":true,\"writeable\":true,"
|
||||
"\"visible\":true,\"value\":\"14\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/seltemp"));
|
||||
auto expected_response = "[{\"name\":\"test_seltemp\",\"fullname\":\"test_seltemp\",\"storage\":\"ram\",\"type\":\"number\",\"readable\":true,"
|
||||
"\"writeable\":true,\"visible\":true,\"ent_cat\":\"diagnostic\",\"value\":\"14\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_seltemp"));
|
||||
}
|
||||
|
||||
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\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0,"
|
||||
"\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTReconnects\":0,\"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\":"
|
||||
"10,\"publishTimeWater\":0,\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,\"publish2command\":false,\"sendResponse\":false},"
|
||||
"\"syslog\":{\"enabled\":false},\"sensor\":{\"temperatureSensors\":2,\"temperatureSensorReads\":0,\"temperatureSensorFails\":0,\"analogSensors\":4,"
|
||||
"\"analogSensorReads\":0,\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{\"busStatus\":\"connected\",\"busProtocol\":"
|
||||
"\"Buderus\",\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,\"busReadsFailed\":0,\"busWritesFailed\":0,"
|
||||
"\"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\":25,\"modbusEnabled\":false,\"forceHeatingOff\":false,\"developerMode\":false},\"devices\":[{\"type\":"
|
||||
"\"boiler\",\"name\":\"My Custom "
|
||||
"Boiler\",\"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,"
|
||||
"\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 "
|
||||
"0x0168\"},{\"type\":\"temperaturesensor\",\"name\":\"temperaturesensor\",\"entities\":2},{\"type\":\"analogsensor\",\"name\":\"analogsensor\","
|
||||
"\"entities\":4},{\"type\":\"scheduler\",\"name\":\"scheduler\",\"entities\":2},{\"type\":\"custom\",\"name\":\"custom\",\"entities\":4}]}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system"));
|
||||
auto expected_response = "[{\"api_data\":\"14\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_seltemp/value"));
|
||||
}
|
||||
|
||||
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\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0,"
|
||||
"\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTReconnects\":0,\"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\":"
|
||||
"10,\"publishTimeWater\":0,\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,\"publish2command\":false,\"sendResponse\":false},"
|
||||
"\"syslog\":{\"enabled\":false},\"sensor\":{\"temperatureSensors\":2,\"temperatureSensorReads\":0,\"temperatureSensorFails\":0,\"analogSensors\":4,"
|
||||
"\"analogSensorReads\":0,\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{\"busStatus\":\"connected\",\"busProtocol\":"
|
||||
"\"Buderus\",\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,\"busReadsFailed\":0,\"busWritesFailed\":0,"
|
||||
"\"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\":25,\"modbusEnabled\":false,\"forceHeatingOff\":false,\"developerMode\":false},\"devices\":[{\"type\":"
|
||||
"\"boiler\",\"name\":\"My Custom "
|
||||
"Boiler\",\"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,"
|
||||
"\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 "
|
||||
"0x0168\"},{\"type\":\"temperaturesensor\",\"name\":\"temperaturesensor\",\"entities\":2},{\"type\":\"analogsensor\",\"name\":\"analogsensor\","
|
||||
"\"entities\":4},{\"type\":\"scheduler\",\"name\":\"scheduler\",\"entities\":2},{\"type\":\"custom\",\"name\":\"custom\",\"entities\":4}]}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/info"));
|
||||
auto expected_response = "[{\"name\":\"test_custom\",\"fullname\":\"test_custom\",\"storage\":\"ems\",\"type\":\"number\",\"readable\":true,\"writeable\":"
|
||||
"true,\"visible\":true,\"device_id\":\"0x08\",\"type_id\":\"0x18\",\"offset\":0,\"factor\":1,\"ent_cat\":\"diagnostic\",\"uom\":"
|
||||
"\"°C\",\"state_class\":\"measurement\",\"device_class\":\"temperature\",\"value\":0.00}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_custom"));
|
||||
}
|
||||
|
||||
void test_21() {
|
||||
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\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{\"NTPstatus\":\"disconnected\",\"enabled\":true,\"server\":\"pool.ntp.org\","
|
||||
"\"tzLabel\":\"Europe/"
|
||||
"London\",\"NTPStatus\":\"disconnected\"},\"ap\":{\"provisionMode\":\"always\",\"ssid\":\"ems-esp\"},\"mqtt\":{\"MQTTStatus\":\"disconnected\","
|
||||
"\"MQTTPublishes\":0,\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTReconnects\":0,\"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\":10,\"publishTimeWater\":0,\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,"
|
||||
"\"publish2command\":false,\"sendResponse\":false},\"syslog\":{\"enabled\":false},\"sensor\":{\"temperatureSensors\":3,\"temperatureSensorReads\":0,"
|
||||
"\"temperatureSensorFails\":0,\"analogSensors\":5,\"analogSensorReads\":0,\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{"
|
||||
"\"busStatus\":\"connected\",\"busProtocol\":\"Buderus\",\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,"
|
||||
"\"busReadsFailed\":0,\"busWritesFailed\":0,\"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\":25,\"modbusEnabled\":false,\"forceHeatingOff\":false,\"developerMode\":false},\"devices\":[{\"type\":"
|
||||
"\"boiler\",\"name\":\"My Custom "
|
||||
"Boiler\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":39,\"handlersReceived\":\"0x18\","
|
||||
"\"handlersFetched\":\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0xC6 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x02E0 "
|
||||
"0x2E "
|
||||
"0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15,"
|
||||
"\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 "
|
||||
"0x0168\"},{\"type\":\"temperaturesensor\",\"name\":\"temperaturesensor\",\"entities\":3},{\"type\":\"analogsensor\",\"name\":\"analogsensor\","
|
||||
"\"entities\":5},{\"type\":\"scheduler\",\"name\":\"scheduler\",\"entities\":2},{\"type\":\"custom\",\"name\":\"custom\",\"entities\":4}]}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system"));
|
||||
}
|
||||
|
||||
void test_22() {
|
||||
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\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{\"NTPstatus\":\"disconnected\",\"enabled\":true,\"server\":\"pool.ntp.org\","
|
||||
"\"tzLabel\":\"Europe/"
|
||||
"London\",\"NTPStatus\":\"disconnected\"},\"ap\":{\"provisionMode\":\"always\",\"ssid\":\"ems-esp\"},\"mqtt\":{\"MQTTStatus\":\"disconnected\","
|
||||
"\"MQTTPublishes\":0,\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTReconnects\":0,\"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\":10,\"publishTimeWater\":0,\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,"
|
||||
"\"publish2command\":false,\"sendResponse\":false},\"syslog\":{\"enabled\":false},\"sensor\":{\"temperatureSensors\":3,\"temperatureSensorReads\":0,"
|
||||
"\"temperatureSensorFails\":0,\"analogSensors\":5,\"analogSensorReads\":0,\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{"
|
||||
"\"busStatus\":\"connected\",\"busProtocol\":\"Buderus\",\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,"
|
||||
"\"busReadsFailed\":0,\"busWritesFailed\":0,\"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\":25,\"modbusEnabled\":false,\"forceHeatingOff\":false,\"developerMode\":false},\"devices\":[{\"type\":"
|
||||
"\"boiler\",\"name\":\"My Custom "
|
||||
"Boiler\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":39,\"handlersReceived\":\"0x18\","
|
||||
"\"handlersFetched\":\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0xC6 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x02E0 "
|
||||
"0x2E "
|
||||
"0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15,"
|
||||
"\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 "
|
||||
"0x0168\"},{\"type\":\"temperaturesensor\",\"name\":\"temperaturesensor\",\"entities\":3},{\"type\":\"analogsensor\",\"name\":\"analogsensor\","
|
||||
"\"entities\":5},{\"type\":\"scheduler\",\"name\":\"scheduler\",\"entities\":2},{\"type\":\"custom\",\"name\":\"custom\",\"entities\":4}]}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/info"));
|
||||
}
|
||||
|
||||
void test_23() {
|
||||
auto expected_response =
|
||||
"[{\"name\":\"locale\",\"circuit\":\"settings\",\"readable\":true,\"writeable\":false,\"visible\":true,\"value\":\"en\",\"type\":\"string\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings/locale"));
|
||||
}
|
||||
|
||||
void test_22() {
|
||||
void test_24() {
|
||||
auto expected_response = "[{}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/fetch"));
|
||||
}
|
||||
|
||||
void test_23() {
|
||||
void test_25() {
|
||||
auto expected_response = "[{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":\"-23\",\"TxPowerSetting\":\"0\",\"staticIP\":\"false\","
|
||||
"\"lowBandwidth\":\"false\",\"disableSleep\":\"true\",\"enableMDNS\":\"true\",\"enableCORS\":\"false\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("api/system/network/values"));
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/network/values"));
|
||||
}
|
||||
|
||||
void test_24() {
|
||||
void test_26() {
|
||||
auto expected_response = "[{\"test_scheduler\":\"on\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler"));
|
||||
}
|
||||
|
||||
void test_25() {
|
||||
void test_27() {
|
||||
auto expected_response = "[{\"test_scheduler\":\"on\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/info"));
|
||||
}
|
||||
|
||||
void test_26() {
|
||||
void test_28() {
|
||||
auto expected_response = "[{\"name\":\"test_scheduler\",\"fullname\":\"test_scheduler\",\"type\":\"boolean\",\"value\":\"on\",\"time\":\"12:00\","
|
||||
"\"command\":\"system/fetch\",\"cmd_data\":\"10\",\"readable\":true,\"writeable\":true,\"visible\":true}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler"));
|
||||
}
|
||||
|
||||
void test_27() {
|
||||
auto expected_response = "[{\"test_tempsensor1\":12.3,\"test_tempsensor2\":45.6}]";
|
||||
void test_29() {
|
||||
auto expected_response = "[{\"test_tempsensor1\":12.3,\"test_tempsensor2\":45.6,\"gateway_temperature\":28.1}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor"));
|
||||
}
|
||||
|
||||
void test_28() {
|
||||
auto expected_response = "[{\"test_tempsensor1\":12.3,\"test_tempsensor2\":45.6}]";
|
||||
void test_30() {
|
||||
auto expected_response = "[{\"test_tempsensor1\":12.3,\"test_tempsensor2\":45.6,\"gateway_temperature\":28.1}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/info"));
|
||||
}
|
||||
|
||||
void test_29() {
|
||||
void test_31() {
|
||||
auto expected_response = "[{\"id\":\"0B_0C0D_0E0F_1011\",\"name\":\"test_tempsensor2\",\"fullname\":\"test_tempsensor2\",\"value\":45.6,\"type\":"
|
||||
"\"number\",\"uom\":\"°C\",\"readable\":true,\"writeable\":false,\"visible\":true}]";
|
||||
"\"number\",\"uom\":\"°C\",\"readable\":true,\"writeable\":false,\"visible\":true,\"is_system\":false}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_tempsensor2"));
|
||||
}
|
||||
|
||||
void test_30() {
|
||||
void test_32() {
|
||||
auto expected_response = "[{\"id\":\"0B_0C0D_0E0F_1011\",\"name\":\"test_tempsensor2\",\"fullname\":\"test_tempsensor2\",\"value\":45.6,\"type\":"
|
||||
"\"number\",\"uom\":\"°C\",\"readable\":true,\"writeable\":false,\"visible\":true}]";
|
||||
"\"number\",\"uom\":\"°C\",\"readable\":true,\"writeable\":false,\"visible\":true,\"is_system\":false}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/0B_0C0D_0E0F_1011"));
|
||||
}
|
||||
|
||||
void test_31() {
|
||||
void test_33() {
|
||||
auto expected_response = "[{\"api_data\":\"45.6\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_tempsensor2/value"));
|
||||
}
|
||||
|
||||
void test_32() {
|
||||
auto expected_response = "[{\"test_analogsensor1\":0,\"test_analogsensor2\":1,\"test_analogsensor3\":0,\"test_analogsensor4\":0}]";
|
||||
void test_34() {
|
||||
auto expected_response = "[{\"test_analogsensor1\":0,\"test_analogsensor2\":1,\"test_analogsensor3\":0,\"test_analogsensor4\":0,\"test_analogsensor5\":0}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor"));
|
||||
}
|
||||
|
||||
void test_33() {
|
||||
auto expected_response = "[{\"test_analogsensor1\":0,\"test_analogsensor2\":1,\"test_analogsensor3\":0,\"test_analogsensor4\":0}]";
|
||||
void test_35() {
|
||||
auto expected_response = "[{\"test_analogsensor1\":0,\"test_analogsensor2\":1,\"test_analogsensor3\":0,\"test_analogsensor4\":0,\"test_analogsensor5\":0}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/info"));
|
||||
}
|
||||
|
||||
void test_34() {
|
||||
auto expected_response = "[{\"name\":\"test_analogsensor1\",\"fullname\":\"test_analogsensor1\",\"gpio\":36,\"type\":\"number\",\"analog\":\"adc\","
|
||||
"\"value\":0,\"readable\":true,\"writeable\":false,\"visible\":true,\"offset\":0,\"factor\":0.1,\"uom\":\"mV\"}]";
|
||||
void test_36() {
|
||||
auto expected_response =
|
||||
"[{\"name\":\"test_analogsensor1\",\"fullname\":\"test_analogsensor1\",\"gpio\":36,\"type\":\"number\",\"analog\":\"adc\",\"value\":0,\"readable\":"
|
||||
"true,\"writeable\":false,\"visible\":true,\"is_system\":false,\"offset\":0,\"factor\":0.2,\"uom\":\"mV\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analogsensor1"));
|
||||
}
|
||||
|
||||
void test_35() {
|
||||
void test_37() {
|
||||
auto expected_response = "[{\"api_data\":\"0\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analogsensor1/offset"));
|
||||
}
|
||||
|
||||
void test_36() {
|
||||
void test_38() {
|
||||
auto expected_response = "[{\"message\":\"unknown device boiler2\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler2"));
|
||||
}
|
||||
|
||||
void test_37() {
|
||||
void test_39() {
|
||||
auto expected_response = "[{}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/bad/value"));
|
||||
}
|
||||
|
||||
void test_38() {
|
||||
void test_40() {
|
||||
auto expected_response = "[{\"message\":\"no attribute 'valu' in comfort\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/comfort/valu"));
|
||||
}
|
||||
|
||||
void test_39() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'settings' in system\"}]";
|
||||
void test_41() {
|
||||
auto expected_response = "[{\"message\":\"no 'settings' in system\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings/locale2"));
|
||||
}
|
||||
|
||||
void test_40() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'settings2' in system\"}]";
|
||||
void test_42() {
|
||||
auto expected_response = "[{\"message\":\"no 'settings2' in system\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings2"));
|
||||
}
|
||||
|
||||
void test_41() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'settings2' in system\"}]";
|
||||
void test_43() {
|
||||
auto expected_response = "[{\"message\":\"no 'settings2' in system\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings2/locale2"));
|
||||
}
|
||||
|
||||
void test_42() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'test_scheduler2' in scheduler\"}]";
|
||||
void test_44() {
|
||||
auto expected_response = "[{\"message\":\"no 'test_scheduler2' in scheduler\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler2"));
|
||||
}
|
||||
|
||||
void test_43() {
|
||||
void test_45() {
|
||||
auto expected_response = "[{\"message\":\"no attribute 'val' in test_scheduler\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler/val"));
|
||||
}
|
||||
|
||||
void test_44() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'test_scheduler2' in scheduler\"}]";
|
||||
void test_46() {
|
||||
auto expected_response = "[{\"message\":\"no 'test_scheduler2' in scheduler\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler2/val2"));
|
||||
}
|
||||
|
||||
void test_45() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'seltemp2' in custom\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/seltemp2"));
|
||||
}
|
||||
|
||||
void test_46() {
|
||||
auto expected_response = "[{\"message\":\"no attribute 'val' in seltemp\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/seltemp/val"));
|
||||
}
|
||||
|
||||
void test_47() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'test_sensor20' in temperaturesensor\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_sensor20"));
|
||||
auto expected_response = "[{\"message\":\"no 'test_seltemp2' in custom\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_seltemp2"));
|
||||
}
|
||||
|
||||
void test_48() {
|
||||
auto expected_response = "[{\"message\":\"no entity '0b_0c0d_0e0f_xxxx' in temperaturesensor\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/0B_0C0D_0E0F_XXXX"));
|
||||
auto expected_response = "[{\"message\":\"Command test_seltemp failed (Error)\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/test_seltemp/val"));
|
||||
}
|
||||
|
||||
void test_49() {
|
||||
auto expected_response = "[{\"message\":\"no 'test_sensor20' in temperaturesensor\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_sensor20"));
|
||||
}
|
||||
|
||||
void test_50() {
|
||||
auto expected_response = "[{\"message\":\"no '0b_0c0d_0e0f_xxxx' in temperaturesensor\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/0B_0C0D_0E0F_XXXX"));
|
||||
}
|
||||
|
||||
void test_51() {
|
||||
auto expected_response = "[{\"message\":\"no attribute 'bad' in test_tempsensor2\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_tempsensor2/bad"));
|
||||
}
|
||||
|
||||
void test_50() {
|
||||
void test_52() {
|
||||
auto expected_response = "[{\"message\":\"no attribute 'bad' in test_analogsensor1\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analogsensor1/bad"));
|
||||
}
|
||||
|
||||
void test_51() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'test_analog10' in analogsensor\"}]";
|
||||
void test_53() {
|
||||
auto expected_response = "[{\"message\":\"no 'test_analog10' in analogsensor\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog10"));
|
||||
}
|
||||
|
||||
void test_52() {
|
||||
auto expected_response = "[{\"message\":\"no entity 'test_analog10' in analogsensor\"}]";
|
||||
void test_54() {
|
||||
auto expected_response = "[{\"message\":\"no 'test_analog10' in analogsensor\"}]";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog10/bad2"));
|
||||
}
|
||||
|
||||
@@ -426,6 +438,8 @@ void run_tests() {
|
||||
RUN_TEST(test_50);
|
||||
RUN_TEST(test_51);
|
||||
RUN_TEST(test_52);
|
||||
RUN_TEST(test_53);
|
||||
RUN_TEST(test_54);
|
||||
}
|
||||
|
||||
// ---------- END - CUT HERE ----------
|
||||
// ---------- END - CUT HERE ----------
|
||||
136
test/test_api/test_shuntingYard.h
Normal file
136
test/test_api/test_shuntingYard.h
Normal file
@@ -0,0 +1,136 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include "core/shuntingYard.h"
|
||||
|
||||
void run_shuntingYard_test(const std::string & expected, const std::string & actual) {
|
||||
TEST_ASSERT_EQUAL_STRING(expected.c_str(), emsesp::compute(actual).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test1() {
|
||||
run_shuntingYard_test("locale is en", "\"locale is \"system/settings/locale");
|
||||
}
|
||||
|
||||
void shuntingYard_test2() {
|
||||
run_shuntingYard_test("rssi is -23", "\"rssi is \"0+system/network/rssi");
|
||||
}
|
||||
|
||||
void shuntingYard_test3() {
|
||||
run_shuntingYard_test("rssi is -23 dBm", "\"rssi is \"(system/network/rssi)\" dBm\"");
|
||||
}
|
||||
|
||||
void shuntingYard_test4() {
|
||||
run_shuntingYard_test("14", "(custom/test_seltemp/value)");
|
||||
}
|
||||
|
||||
void shuntingYard_test5() {
|
||||
run_shuntingYard_test("seltemp=14", "\"seltemp=\"(custom/test_seltemp/value)");
|
||||
}
|
||||
|
||||
void shuntingYard_test6() {
|
||||
run_shuntingYard_test("14", "custom/test_seltemp");
|
||||
}
|
||||
|
||||
void shuntingYard_test7() {
|
||||
run_shuntingYard_test("40", "boiler/flowtempoffset");
|
||||
}
|
||||
|
||||
void shuntingYard_test8() {
|
||||
run_shuntingYard_test("40", "(boiler/flowtempoffset/value)");
|
||||
}
|
||||
|
||||
void shuntingYard_test9() {
|
||||
run_shuntingYard_test("53.8", "(boiler/storagetemp1/value)");
|
||||
}
|
||||
|
||||
void shuntingYard_test10() {
|
||||
run_shuntingYard_test("-67.8", "(custom/test_seltemp - boiler/flowtempoffset) * 2.8 + 5");
|
||||
}
|
||||
|
||||
void shuntingYard_test11() {
|
||||
run_shuntingYard_test("4", "1 > 2 ? 3 : 4");
|
||||
}
|
||||
|
||||
void shuntingYard_test12() {
|
||||
run_shuntingYard_test("3", "1 < 2 ? 3 : 4");
|
||||
}
|
||||
|
||||
void shuntingYard_test13() {
|
||||
run_shuntingYard_test("5", "1<2?(3<4?5:6):7");
|
||||
}
|
||||
|
||||
void shuntingYard_test14() {
|
||||
run_shuntingYard_test("7", "1>2?(3<4?5:6):7");
|
||||
}
|
||||
|
||||
void shuntingYard_test15() {
|
||||
run_shuntingYard_test("6", "1<2?(3>4?5:6):7");
|
||||
}
|
||||
|
||||
void shuntingYard_test16() {
|
||||
run_shuntingYard_test("3", "1<2?3:(4<5?6:7)");
|
||||
}
|
||||
|
||||
void shuntingYard_test17() {
|
||||
run_shuntingYard_test("6", "1>2?3:(4<5?6:7)");
|
||||
}
|
||||
|
||||
void shuntingYard_test18() {
|
||||
run_shuntingYard_test("7", "1>2?3:(4>5?6:7)");
|
||||
}
|
||||
|
||||
void shuntingYard_test19() {
|
||||
run_shuntingYard_test("44", "(1>2?3:4)+(10>20?30:40)");
|
||||
}
|
||||
|
||||
void shuntingYard_test20() {
|
||||
run_shuntingYard_test("8", "1<2 ? 3>4 ? 5 : 6<7 ? 8 : 9 : 10");
|
||||
}
|
||||
|
||||
void shuntingYard_test21() {
|
||||
run_shuntingYard_test("", "boiler/storagetemp2 == \"\"");
|
||||
}
|
||||
|
||||
void shuntingYard_test22() {
|
||||
run_shuntingYard_test("", "boiler/storagetemp2 == ''");
|
||||
}
|
||||
|
||||
void shuntingYard_test23() {
|
||||
run_shuntingYard_test("9", "custom/test_ram");
|
||||
}
|
||||
|
||||
void shuntingYard_test24() {
|
||||
run_shuntingYard_test("hello world!", "\"hello world!\"");
|
||||
}
|
||||
|
||||
void shuntingYard_test25() {
|
||||
run_shuntingYard_test("hello world!", "'hello world!'");
|
||||
}
|
||||
|
||||
void run_shuntingYard_tests() {
|
||||
RUN_TEST(shuntingYard_test1);
|
||||
RUN_TEST(shuntingYard_test2);
|
||||
RUN_TEST(shuntingYard_test3);
|
||||
RUN_TEST(shuntingYard_test4);
|
||||
RUN_TEST(shuntingYard_test5);
|
||||
RUN_TEST(shuntingYard_test6);
|
||||
RUN_TEST(shuntingYard_test7);
|
||||
RUN_TEST(shuntingYard_test8);
|
||||
RUN_TEST(shuntingYard_test9);
|
||||
RUN_TEST(shuntingYard_test10);
|
||||
RUN_TEST(shuntingYard_test11);
|
||||
RUN_TEST(shuntingYard_test12);
|
||||
RUN_TEST(shuntingYard_test13);
|
||||
RUN_TEST(shuntingYard_test14);
|
||||
RUN_TEST(shuntingYard_test15);
|
||||
RUN_TEST(shuntingYard_test16);
|
||||
RUN_TEST(shuntingYard_test17);
|
||||
RUN_TEST(shuntingYard_test18);
|
||||
RUN_TEST(shuntingYard_test19);
|
||||
RUN_TEST(shuntingYard_test20);
|
||||
RUN_TEST(shuntingYard_test21);
|
||||
RUN_TEST(shuntingYard_test22);
|
||||
RUN_TEST(shuntingYard_test23);
|
||||
RUN_TEST(shuntingYard_test24);
|
||||
RUN_TEST(shuntingYard_test25);
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <unity.h>
|
||||
#include <HTTPClient.h>
|
||||
#include "core/shuntingYard.hpp"
|
||||
|
||||
void shuntingYard_test1() {
|
||||
std::string expected_result = "locale is en";
|
||||
std::string test_value = "\"locale is \"system/settings/locale";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test2() {
|
||||
// test with negative value
|
||||
std::string expected_result = "rssi is -23";
|
||||
std::string test_value = "\"rssi is \"0+system/network/rssi";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test3() {
|
||||
std::string expected_result = "rssi is -23 dBm";
|
||||
std::string test_value = "\"rssi is \"(system/network/rssi)\" dBm\"";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test4() {
|
||||
std::string expected_result = "14";
|
||||
std::string test_value = "(custom/seltemp/value)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test5() {
|
||||
std::string expected_result = "seltemp=14";
|
||||
std::string test_value = "\"seltemp=\"(custom/seltemp/value)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test6() {
|
||||
std::string expected_result = "14";
|
||||
std::string test_value = "(custom/seltemp)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test7() {
|
||||
std::string expected_result = "40";
|
||||
std::string test_value = "boiler/flowtempoffset";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test8() {
|
||||
std::string expected_result = "40";
|
||||
std::string test_value = "(boiler/flowtempoffset/value)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test9() {
|
||||
std::string expected_result = "53.8";
|
||||
std::string test_value = "(boiler/storagetemp1/value)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test10() {
|
||||
// (14 - 40) * 2.8 + 5 = -67.8
|
||||
std::string expected_result = "-67.8";
|
||||
std::string test_value = "(custom/seltemp - boiler/flowtempoffset) * 2.8 + 5";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test11() {
|
||||
std::string expected_result = "4";
|
||||
std::string test_value = "1 > 2 ? 3 : 4";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test12() {
|
||||
std::string expected_result = "3";
|
||||
std::string test_value = "1 < 2 ? 3 : 4";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test13() {
|
||||
std::string expected_result = "5";
|
||||
std::string test_value = "1<2?(3<4?5:6):7";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test14() {
|
||||
std::string expected_result = "7";
|
||||
std::string test_value = "1>2?(3<4?5:6):7";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test15() {
|
||||
std::string expected_result = "6";
|
||||
std::string test_value = "1<2?(3>4?5:6):7";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test16() {
|
||||
std::string expected_result = "3";
|
||||
std::string test_value = "1<2?3:(4<5?6:7)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test17() {
|
||||
std::string expected_result = "6";
|
||||
std::string test_value = "1>2?3:(4<5?6:7)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test18() {
|
||||
std::string expected_result = "7";
|
||||
std::string test_value = "1>2?3:(4>5?6:7)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test19() {
|
||||
std::string expected_result = "44";
|
||||
std::string test_value = "(1>2?3:4)+(10>20?30:40)";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test20() {
|
||||
std::string expected_result = "8";
|
||||
std::string test_value = "1<2 ? 3>4 ? 5 : 6<7 ? 8 : 9 : 10";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void shuntingYard_test21() {
|
||||
std::string expected_result = "1";
|
||||
std::string test_value = "boiler/storagetemp2 == \"\"";
|
||||
TEST_ASSERT_EQUAL_STRING(expected_result.c_str(), compute(test_value).c_str());
|
||||
}
|
||||
|
||||
void run_shuntingYard_tests() {
|
||||
RUN_TEST(shuntingYard_test1);
|
||||
RUN_TEST(shuntingYard_test2);
|
||||
RUN_TEST(shuntingYard_test3);
|
||||
RUN_TEST(shuntingYard_test4);
|
||||
RUN_TEST(shuntingYard_test5);
|
||||
RUN_TEST(shuntingYard_test6);
|
||||
RUN_TEST(shuntingYard_test7);
|
||||
RUN_TEST(shuntingYard_test8);
|
||||
RUN_TEST(shuntingYard_test9);
|
||||
RUN_TEST(shuntingYard_test10);
|
||||
RUN_TEST(shuntingYard_test11);
|
||||
RUN_TEST(shuntingYard_test12);
|
||||
RUN_TEST(shuntingYard_test13);
|
||||
RUN_TEST(shuntingYard_test14);
|
||||
RUN_TEST(shuntingYard_test15);
|
||||
RUN_TEST(shuntingYard_test16);
|
||||
RUN_TEST(shuntingYard_test17);
|
||||
RUN_TEST(shuntingYard_test18);
|
||||
RUN_TEST(shuntingYard_test19);
|
||||
RUN_TEST(shuntingYard_test20);
|
||||
RUN_TEST(shuntingYard_test21);
|
||||
}
|
||||
Reference in New Issue
Block a user