mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@msgpack/msgpack": "^3.1.1",
|
"@msgpack/msgpack": "^3.1.1",
|
||||||
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
||||||
"formidable": "^3.5.3",
|
"formidable": "^3.5.4",
|
||||||
"itty-router": "^5.0.18",
|
"itty-router": "^5.0.18",
|
||||||
"prettier": "^3.5.3"
|
"prettier": "^3.5.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -210,14 +210,14 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"formidable@npm:^3.5.3":
|
"formidable@npm:^3.5.4":
|
||||||
version: 3.5.3
|
version: 3.5.4
|
||||||
resolution: "formidable@npm:3.5.3"
|
resolution: "formidable@npm:3.5.4"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@paralleldrive/cuid2": "npm:^2.2.2"
|
"@paralleldrive/cuid2": "npm:^2.2.2"
|
||||||
dezalgo: "npm:^1.0.4"
|
dezalgo: "npm:^1.0.4"
|
||||||
once: "npm:^1.4.0"
|
once: "npm:^1.4.0"
|
||||||
checksum: 10c0/4e2732d3ed946dd972bc80ecba5c5a3709baa7d541583058c7e0a7344e64ced3b69f32813884a174855ad31f9ce978a6dc9fbf2578a1ed5e08691baf679266f4
|
checksum: 10c0/3a311ce57617eb8f532368e91c0f2bbfb299a0f1a35090e085bd6ca772298f196fbb0b66f0d4b5549d7bf3c5e1844439338d4402b7b6d1fedbe206ad44a931f8
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ __metadata:
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@msgpack/msgpack": "npm:^3.1.1"
|
"@msgpack/msgpack": "npm:^3.1.1"
|
||||||
"@trivago/prettier-plugin-sort-imports": "npm:^5.2.2"
|
"@trivago/prettier-plugin-sort-imports": "npm:^5.2.2"
|
||||||
formidable: "npm:^3.5.3"
|
formidable: "npm:^3.5.4"
|
||||||
itty-router: "npm:^5.0.18"
|
itty-router: "npm:^5.0.18"
|
||||||
prettier: "npm:^3.5.3"
|
prettier: "npm:^3.5.3"
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
|
|||||||
@@ -352,6 +352,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
|
|
||||||
#ifdef EMSESP_STANDALONE
|
#ifdef EMSESP_STANDALONE
|
||||||
AsyncWebServerRequest request;
|
AsyncWebServerRequest request;
|
||||||
|
JsonDocument doc;
|
||||||
|
JsonVariant json;
|
||||||
|
|
||||||
|
// read requests
|
||||||
request.method(HTTP_GET);
|
request.method(HTTP_GET);
|
||||||
request.url("/api/custom");
|
request.url("/api/custom");
|
||||||
EMSESP::webAPIService.webAPIService(&request);
|
EMSESP::webAPIService.webAPIService(&request);
|
||||||
@@ -363,6 +367,20 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
EMSESP::webAPIService.webAPIService(&request);
|
EMSESP::webAPIService.webAPIService(&request);
|
||||||
shell.invoke_command("call custom info");
|
shell.invoke_command("call custom info");
|
||||||
|
|
||||||
|
// write requests
|
||||||
|
request.method(HTTP_POST);
|
||||||
|
char data[] = "{\"value\":\"99\"}";
|
||||||
|
deserializeJson(doc, data);
|
||||||
|
json = doc.as<JsonVariant>();
|
||||||
|
// validate
|
||||||
|
request.url("/api/custom/test_ram");
|
||||||
|
EMSESP::webAPIService.webAPIService(&request, json);
|
||||||
|
|
||||||
|
request.method(HTTP_GET);
|
||||||
|
request.url("/api/custom");
|
||||||
|
EMSESP::webAPIService.webAPIService(&request);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
@@ -1091,6 +1109,16 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
// POST COMMANDS
|
// POST COMMANDS
|
||||||
request.method(HTTP_POST);
|
request.method(HTTP_POST);
|
||||||
|
|
||||||
|
char data0[] = "{\"value\":12}";
|
||||||
|
deserializeJson(doc, data0);
|
||||||
|
request.url("/api/thermostat/seltemp");
|
||||||
|
EMSESP::webAPIService.webAPIService(&request, doc.as<JsonVariant>());
|
||||||
|
// request.method(HTTP_GET);
|
||||||
|
// request.url("/api/thermostat/seltemp/value");
|
||||||
|
// EMSESP::webAPIService.webAPIService(&request);
|
||||||
|
|
||||||
|
// request.method(HTTP_POST);
|
||||||
|
|
||||||
// char data1[] = "{\"device\":\"system\", \"cmd\":\"restart\",\"id\":-1}";
|
// char data1[] = "{\"device\":\"system\", \"cmd\":\"restart\",\"id\":-1}";
|
||||||
// deserializeJson(doc, data1);
|
// deserializeJson(doc, data1);
|
||||||
// request.url("/api");
|
// request.url("/api");
|
||||||
@@ -1114,28 +1142,28 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
// test version checks
|
// test version checks
|
||||||
// use same data as in rest_server.ts
|
// use same data as in rest_server.ts
|
||||||
// log shows first if you can upgrade to dev, and then if you can upgrade to stable
|
// log shows first if you can upgrade to dev, and then if you can upgrade to stable
|
||||||
request.url("/rest/action");
|
// request.url("/rest/action");
|
||||||
std::string LATEST_STABLE_VERSION = "3.7.2";
|
// std::string LATEST_STABLE_VERSION = "3.7.2";
|
||||||
std::string LATEST_DEV_VERSION = "3.7.3-dev.3";
|
// std::string LATEST_DEV_VERSION = "3.7.3-dev.3";
|
||||||
std::string param = LATEST_DEV_VERSION + "," + LATEST_STABLE_VERSION;
|
// std::string param = LATEST_DEV_VERSION + "," + LATEST_STABLE_VERSION;
|
||||||
std::string action = "{\"action\":\"checkUpgrade\", \"param\":\"" + param + "\"}";
|
// std::string action = "{\"action\":\"checkUpgrade\", \"param\":\"" + param + "\"}";
|
||||||
deserializeJson(doc, action);
|
// deserializeJson(doc, action);
|
||||||
|
|
||||||
// case 0: on latest stable, can upgrade to dev only. So true, false
|
// // case 0: on latest stable, can upgrade to dev only. So true, false
|
||||||
EMSESP::webStatusService.set_current_version(LATEST_STABLE_VERSION);
|
// EMSESP::webStatusService.set_current_version(LATEST_STABLE_VERSION);
|
||||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
// case 1: on latest dev, no updates to either dev or stable. So false, false
|
// // case 1: on latest dev, no updates to either dev or stable. So false, false
|
||||||
EMSESP::webStatusService.set_current_version(LATEST_DEV_VERSION);
|
// EMSESP::webStatusService.set_current_version(LATEST_DEV_VERSION);
|
||||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
// case 2: upgrade an older stable to latest stable or the latest dev. So true, true
|
// // case 2: upgrade an older stable to latest stable or the latest dev. So true, true
|
||||||
EMSESP::webStatusService.set_current_version("3.6.5");
|
// EMSESP::webStatusService.set_current_version("3.6.5");
|
||||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
// case 3: upgrade an older dev to latest dev, no stable upgrades available. So true, false
|
// // case 3: upgrade an older dev to latest dev, no stable upgrades available. So true, false
|
||||||
EMSESP::webStatusService.set_current_version("3.7.3-dev.2");
|
// EMSESP::webStatusService.set_current_version("3.7.3-dev.2");
|
||||||
EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
// EMSESP::webStatusService.action(&request, doc.as<JsonVariant>());
|
||||||
|
|
||||||
// char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}";
|
// char data6[] = "{\"device\":\"system\", \"cmd\":\"read\",\"value\":\"8 2 27 1\"}";
|
||||||
// deserializeJson(doc, data6);
|
// deserializeJson(doc, data6);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace emsesp {
|
|||||||
// #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 "api3"
|
// #define EMSESP_DEBUG_DEFAULT "api3"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "api4"
|
// #define EMSESP_DEBUG_DEFAULT "api4"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "crash"
|
// #define EMSESP_DEBUG_DEFAULT "crash"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "dv"
|
// #define EMSESP_DEBUG_DEFAULT "dv"
|
||||||
@@ -56,7 +56,7 @@ namespace emsesp {
|
|||||||
// #define EMSESP_DEBUG_DEFAULT "telegram_dump"
|
// #define EMSESP_DEBUG_DEFAULT "telegram_dump"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "memory"
|
// #define EMSESP_DEBUG_DEFAULT "memory"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "coldshot"
|
// #define EMSESP_DEBUG_DEFAULT "coldshot"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "custom"
|
#define EMSESP_DEBUG_DEFAULT "custom"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "scheduler"
|
// #define EMSESP_DEBUG_DEFAULT "scheduler"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "heat_exchange"
|
// #define EMSESP_DEBUG_DEFAULT "heat_exchange"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "ls"
|
// #define EMSESP_DEBUG_DEFAULT "ls"
|
||||||
|
|||||||
@@ -666,6 +666,7 @@ bool WebCustomEntityService::get_value(std::shared_ptr<const Telegram> telegram)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hard coded tests
|
// hard coded tests
|
||||||
|
// add the entity and also add the command for writeable entities
|
||||||
#ifdef EMSESP_TEST
|
#ifdef EMSESP_TEST
|
||||||
void WebCustomEntityService::test() {
|
void WebCustomEntityService::test() {
|
||||||
update([&](WebCustomEntity & webCustomEntity) {
|
update([&](WebCustomEntity & webCustomEntity) {
|
||||||
@@ -685,6 +686,14 @@ void WebCustomEntityService::test() {
|
|||||||
entityItem.writeable = true;
|
entityItem.writeable = true;
|
||||||
entityItem.data = "70";
|
entityItem.data = "70";
|
||||||
webCustomEntity.customEntityItems.push_back(entityItem);
|
webCustomEntity.customEntityItems.push_back(entityItem);
|
||||||
|
Command::add(
|
||||||
|
EMSdevice::DeviceType::CUSTOM,
|
||||||
|
webCustomEntity.customEntityItems.back().name.c_str(),
|
||||||
|
[webCustomEntity](const char * value, const int8_t id) {
|
||||||
|
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name.c_str());
|
||||||
|
},
|
||||||
|
FL_(entity_cmd),
|
||||||
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
// test 2
|
// test 2
|
||||||
entityItem.id = 2;
|
entityItem.id = 2;
|
||||||
@@ -713,6 +722,14 @@ void WebCustomEntityService::test() {
|
|||||||
entityItem.writeable = true;
|
entityItem.writeable = true;
|
||||||
entityItem.data = "14";
|
entityItem.data = "14";
|
||||||
webCustomEntity.customEntityItems.push_back(entityItem);
|
webCustomEntity.customEntityItems.push_back(entityItem);
|
||||||
|
Command::add(
|
||||||
|
EMSdevice::DeviceType::CUSTOM,
|
||||||
|
webCustomEntity.customEntityItems.back().name.c_str(),
|
||||||
|
[webCustomEntity](const char * value, const int8_t id) {
|
||||||
|
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name.c_str());
|
||||||
|
},
|
||||||
|
FL_(entity_cmd),
|
||||||
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
// test 4
|
// test 4
|
||||||
entityItem.id = 4;
|
entityItem.id = 4;
|
||||||
@@ -728,6 +745,14 @@ void WebCustomEntityService::test() {
|
|||||||
entityItem.data = "14";
|
entityItem.data = "14";
|
||||||
entityItem.value = 12;
|
entityItem.value = 12;
|
||||||
webCustomEntity.customEntityItems.push_back(entityItem);
|
webCustomEntity.customEntityItems.push_back(entityItem);
|
||||||
|
Command::add(
|
||||||
|
EMSdevice::DeviceType::CUSTOM,
|
||||||
|
webCustomEntity.customEntityItems.back().name.c_str(),
|
||||||
|
[webCustomEntity](const char * value, const int8_t id) {
|
||||||
|
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name.c_str());
|
||||||
|
},
|
||||||
|
FL_(entity_cmd),
|
||||||
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
return StateUpdateResult::CHANGED; // persist the changes
|
return StateUpdateResult::CHANGED; // persist the changes
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,6 +74,20 @@ Authorization: Bearer {{token}}
|
|||||||
|
|
||||||
GET {{host}}/api/boiler/commands
|
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
|
# Test on dev
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user