mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
show message if there is no error message set
This commit is contained in:
@@ -343,16 +343,20 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
|||||||
// see if there is a command registered and it's valid
|
// see if there is a command registered and it's valid
|
||||||
auto cf = find_command(device_type, device_id, cmd, flag);
|
auto cf = find_command(device_type, device_id, cmd, flag);
|
||||||
if (!cf) {
|
if (!cf) {
|
||||||
std::string err = std::string("unknown command ") + cmd;
|
// if we don't already have a message set, set it to invalid command
|
||||||
LOG_WARNING("Command failed: %s", err.c_str());
|
if (output["message"]) {
|
||||||
|
LOG_WARNING("Command failed: %s", output["message"].as<const char *>());
|
||||||
// if we don't alread have a message set, set it to invalid command
|
} else {
|
||||||
if (!output["message"]) {
|
std::string err = "no command " + std::string(cmd) + " in " + dname;
|
||||||
output["message"] = err;
|
output["message"] = err;
|
||||||
|
LOG_WARNING("Command failed: %s", err.c_str());
|
||||||
}
|
}
|
||||||
return CommandRet::ERROR;
|
return CommandRet::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO here
|
||||||
|
output.clear(); // we have a command function, clear messages from device_value_info
|
||||||
|
|
||||||
// before calling the command, check permissions and abort if not authorized
|
// before calling the command, check permissions and abort if not authorized
|
||||||
if (cf->has_flags(CommandFlag::ADMIN_ONLY) && !is_admin) {
|
if (cf->has_flags(CommandFlag::ADMIN_ONLY) && !is_admin) {
|
||||||
LOG_WARNING("Command failed: authentication failed");
|
LOG_WARNING("Command failed: authentication failed");
|
||||||
|
|||||||
Reference in New Issue
Block a user