mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
add new return code NO_VALUE
This commit is contained in:
@@ -48,7 +48,8 @@ enum CommandRet : uint8_t {
|
||||
NOT_FOUND, // 2
|
||||
ERROR, // 3
|
||||
NOT_ALLOWED, // 4 - needs authentication
|
||||
INVALID // 5 - invalid (tag)
|
||||
INVALID, // 5 - invalid (tag)
|
||||
NO_VALUE // 6 - no value
|
||||
};
|
||||
|
||||
using cmd_function_p = std::function<bool(const char * data, const int8_t id)>;
|
||||
|
||||
@@ -380,7 +380,13 @@ std::string commands(std::string & expr, bool quotes = true) {
|
||||
JsonObject output = doc_out.to<JsonObject>();
|
||||
JsonObject input = doc_in.to<JsonObject>();
|
||||
std::string cmd_s = "api/" + std::string(cmd);
|
||||
emsesp::Command::process(cmd_s.c_str(), true, input, output);
|
||||
|
||||
auto return_code = emsesp::Command::process(cmd_s.c_str(), true, input, output);
|
||||
// check for no value (entity is valid but has no value set)
|
||||
if (return_code == emsesp::CommandRet::NO_VALUE) {
|
||||
return expr = ""; // just ignore for now
|
||||
}
|
||||
|
||||
if (output["api_data"].is<std::string>()) {
|
||||
std::string data = output["api_data"];
|
||||
if (!isnum(data) && quotes) {
|
||||
|
||||
Reference in New Issue
Block a user