mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-07-29 01:52:51 +00:00
device value info for command attributes and GET requests
This commit is contained in:
@@ -382,7 +382,7 @@ uint8_t Command::call(const uint8_t device_type, const char * command, const cha
|
|||||||
// rather than returning its definition, so skip the value-info lookup and fall through
|
// rather than returning its definition, so skip the value-info lookup and fall through
|
||||||
// to the registered command function. The list keywords above are still handled.
|
// to the registered command function. The list keywords above are still handled.
|
||||||
bool is_named_command = (device_type == EMSdevice::DeviceType::COMMAND) && strcmp(cmd, F_(info)) && strcmp(cmd, F_(values)) && strcmp(cmd, F_(entities))
|
bool is_named_command = (device_type == EMSdevice::DeviceType::COMMAND) && strcmp(cmd, F_(info)) && strcmp(cmd, F_(values)) && strcmp(cmd, F_(entities))
|
||||||
&& strcmp(cmd, F_(metrics));
|
&& strcmp(cmd, F_(metrics)) && !strchr(cmd, '/') && is_admin;
|
||||||
if (!is_named_command && EMSESP::get_device_value_info(output, cmd, id, device_type)) { // entity = cmd
|
if (!is_named_command && EMSESP::get_device_value_info(output, cmd, id, device_type)) { // entity = cmd
|
||||||
LOG_DEBUG("Fetched device entity/attributes for %s/%s (id=%d)", dname, cmd, id);
|
LOG_DEBUG("Fetched device entity/attributes for %s/%s (id=%d)", dname, cmd, id);
|
||||||
return CommandRet::OK;
|
return CommandRet::OK;
|
||||||
|
|||||||
@@ -374,13 +374,12 @@ std::string WebCommandService::get_metrics_prometheus() {
|
|||||||
void WebCommandService::get_value_json(JsonObject output, const CommandItem & ci) {
|
void WebCommandService::get_value_json(JsonObject output, const CommandItem & ci) {
|
||||||
output["name"] = (const char *)ci.name;
|
output["name"] = (const char *)ci.name;
|
||||||
// output["fullname"] = (const char *)ci.name;
|
// output["fullname"] = (const char *)ci.name;
|
||||||
// output["type"] = "command";
|
output["type"] = "command";
|
||||||
output["command"] = ci.cmd;
|
output["command"] = ci.cmd;
|
||||||
output["value"] = ci.value;
|
output["value"] = ci.value;
|
||||||
// bool hasName = ci.name[0] != '\0';
|
output["readable"] = true;
|
||||||
// output["readable"] = hasName;
|
output["writeable"] = true;
|
||||||
// output["writeable"] = hasName;
|
output["visible"] = true;
|
||||||
// output["visible"] = hasName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebCommandService::publish(const bool force) {
|
void WebCommandService::publish(const bool force) {
|
||||||
|
|||||||
Reference in New Issue
Block a user