mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 01:09:51 +03:00
show emsesp-devices in system info, add common fields to value_info #2033
This commit is contained in:
@@ -320,9 +320,10 @@ bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd)
|
||||
|
||||
// build the json for specific entity
|
||||
void WebCustomEntityService::get_value_json(JsonObject output, const CustomEntityItem & entity) {
|
||||
output["name"] = entity.name;
|
||||
output["storage"] = entity.ram ? "ram" : "ems";
|
||||
output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : entity.value_type == DeviceValueType::STRING ? "string" : F_(number);
|
||||
output["name"] = entity.name;
|
||||
output["fullname"] = entity.name;
|
||||
output["storage"] = entity.ram ? "ram" : "ems";
|
||||
output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : entity.value_type == DeviceValueType::STRING ? "string" : F_(number);
|
||||
if (entity.uom > 0) {
|
||||
output["uom"] = EMSdevice::uom_to_string(entity.uom);
|
||||
}
|
||||
@@ -471,15 +472,6 @@ uint8_t WebCustomEntityService::count_entities() {
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t WebCustomEntityService::has_commands() {
|
||||
uint8_t count = 0;
|
||||
for (const CustomEntityItem & entity : *customEntityItems_) {
|
||||
count += entity.writeable ? 1 : 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// send to dashboard, msgpack don't like serialized, use number
|
||||
void WebCustomEntityService::generate_value_web(JsonObject output) {
|
||||
JsonArray data = output["data"].to<JsonArray>();
|
||||
|
||||
@@ -67,7 +67,6 @@ class WebCustomEntityService : public StatefulService<WebCustomEntity> {
|
||||
void generate_value_web(JsonObject output);
|
||||
|
||||
uint8_t count_entities();
|
||||
uint8_t has_commands();
|
||||
void ha_reset() {
|
||||
ha_registered_ = false;
|
||||
}
|
||||
|
||||
@@ -178,8 +178,9 @@ bool WebSchedulerService::get_value_info(JsonObject output, const char * cmd) {
|
||||
|
||||
// build the json for specific entity
|
||||
void WebSchedulerService::get_value_json(JsonObject output, const ScheduleItem & scheduleItem) {
|
||||
output["name"] = scheduleItem.name;
|
||||
output["type"] = "boolean";
|
||||
output["name"] = scheduleItem.name;
|
||||
output["fullname"] = scheduleItem.name;
|
||||
output["type"] = "boolean";
|
||||
if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) {
|
||||
output["value"] = scheduleItem.active;
|
||||
} else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) {
|
||||
@@ -299,18 +300,15 @@ void WebSchedulerService::publish(const bool force) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebSchedulerService::has_commands() {
|
||||
if (scheduleItems_->size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// count number of entries, default: only named items
|
||||
uint8_t WebSchedulerService::count_entities(bool cmd_only) {
|
||||
uint8_t count = 0;
|
||||
for (const ScheduleItem & scheduleItem : *scheduleItems_) {
|
||||
if (!scheduleItem.name.empty()) {
|
||||
return true;
|
||||
if (!scheduleItem.name.empty() || !cmd_only) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return count;
|
||||
}
|
||||
|
||||
#include "shuntingYard.hpp"
|
||||
|
||||
@@ -65,14 +65,14 @@ class WebSchedulerService : public StatefulService<WebScheduler> {
|
||||
void loop();
|
||||
void publish_single(const char * name, const bool state);
|
||||
void publish(const bool force = false);
|
||||
bool has_commands();
|
||||
bool command_setvalue(const char * value, const int8_t id, const char * name);
|
||||
bool get_value_info(JsonObject output, const char * cmd);
|
||||
void get_value_json(JsonObject output, const ScheduleItem & scheduleItem);
|
||||
void ha_reset() {
|
||||
ha_registered_ = false;
|
||||
}
|
||||
bool onChange(const char * cmd);
|
||||
uint8_t count_entities(bool cmd_only = false);
|
||||
bool onChange(const char * cmd);
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
void test();
|
||||
|
||||
@@ -51,8 +51,8 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
|
||||
root["bus_status"] = EMSESP::bus_status(); // 0, 1 or 2
|
||||
root["bus_uptime"] = EMSbus::bus_uptime();
|
||||
root["num_devices"] = EMSESP::count_devices();
|
||||
root["num_sensors"] = EMSESP::temperaturesensor_.no_sensors();
|
||||
root["num_analogs"] = EMSESP::analogsensor_.no_sensors();
|
||||
root["num_sensors"] = EMSESP::temperaturesensor_.count_entities();
|
||||
root["num_analogs"] = EMSESP::analogsensor_.count_entities();
|
||||
root["free_heap"] = EMSESP::system_.getHeapMem();
|
||||
root["uptime"] = uuid::get_uptime_sec();
|
||||
root["mqtt_status"] = EMSESP::mqtt_.connected();
|
||||
|
||||
Reference in New Issue
Block a user