mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-07-28 17:42:45 +00:00
every readable entity has a value
This commit is contained in:
@@ -318,10 +318,19 @@ bool WebCommandService::get_value_info(JsonObject output, const char * cmd) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen(cmd) || !strcmp(cmd, F_(values)) || !strcmp(cmd, F_(info))) {
|
if (!strlen(cmd) || !strcmp(cmd, F_(values))) {
|
||||||
for (const CommandItem & ci : *commandItems_) {
|
for (const CommandItem & ci : *commandItems_) {
|
||||||
if (ci.name[0] != '\0') {
|
if (ci.name[0] != '\0') {
|
||||||
output[(const char *)ci.name] = ci.cmd;
|
output[(const char *)ci.name] = ci.value.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(cmd, F_(info))) {
|
||||||
|
for (const CommandItem & ci : *commandItems_) {
|
||||||
|
if (ci.name[0] != '\0') {
|
||||||
|
output[(const char *)ci.name] = std::string(ci.cmd + ": " + ci.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -364,7 +373,7 @@ std::string WebCommandService::get_metrics_prometheus() {
|
|||||||
if (ci.name[0] == '\0') {
|
if (ci.name[0] == '\0') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result += (std::string) "# HELP emsesp_cmd_" + ci.name + " " + ci.name + "\n";
|
result += (std::string) "# HELP emsesp_cmd_" + ci.name + " " + ci.name + ", readabe, writable, visible\n";
|
||||||
result += (std::string) "# TYPE emsesp_cmd_" + ci.name + " gauge\n";
|
result += (std::string) "# TYPE emsesp_cmd_" + ci.name + " gauge\n";
|
||||||
result += (std::string) "emsesp_cmd_" + ci.name + " 1\n";
|
result += (std::string) "emsesp_cmd_" + ci.name + " 1\n";
|
||||||
}
|
}
|
||||||
@@ -394,7 +403,7 @@ void WebCommandService::publish(const bool force) {
|
|||||||
JsonObject output = doc.to<JsonObject>();
|
JsonObject output = doc.to<JsonObject>();
|
||||||
for (const CommandItem & ci : *commandItems_) {
|
for (const CommandItem & ci : *commandItems_) {
|
||||||
if (ci.name[0] != '\0' && !output[ci.name].is<JsonVariantConst>()) {
|
if (ci.name[0] != '\0' && !output[ci.name].is<JsonVariantConst>()) {
|
||||||
output[(const char *)ci.name] = ci.cmd;
|
output[(const char *)ci.name] = ci.value.c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ void WebSchedulerService::get_value_json(JsonObject output, const ScheduleItem &
|
|||||||
output["name"] = (const char *)scheduleItem.name;
|
output["name"] = (const char *)scheduleItem.name;
|
||||||
output["fullname"] = (const char *)scheduleItem.name;
|
output["fullname"] = (const char *)scheduleItem.name;
|
||||||
output["type"] = "boolean";
|
output["type"] = "boolean";
|
||||||
Mqtt::add_value_bool(output, "active", scheduleItem.active);
|
Mqtt::add_value_bool(output, "value", scheduleItem.active);
|
||||||
if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_CONDITION) {
|
||||||
output["condition"] = scheduleItem.time;
|
output["condition"] = scheduleItem.time;
|
||||||
} else if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_ONCHANGE) {
|
} else if (scheduleItem.flags == SCHEDULEFLAG_SCHEDULE_ONCHANGE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user