3 Commits

Author SHA1 Message Date
Proddy
3ab402c56d Merge pull request #3162 from MichaelDvP/core3
api attributs
2026-07-25 08:38:45 +02:00
MichaelDvP
0ae46e9382 Merge remote-tracking branch 'emsesp/core3' into core3 2026-07-17 10:02:13 +02:00
MichaelDvP
7989ab5b3f every readable entity has a value 2026-07-17 10:01:59 +02:00
2 changed files with 14 additions and 5 deletions

View File

@@ -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();
} }
} }

View File

@@ -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) {