mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
if no fullname, use shortname in customizations json
This commit is contained in:
@@ -775,7 +775,7 @@ void EMSdevice::generate_values_web(JsonObject & output) {
|
|||||||
|
|
||||||
// as generate_values_web() but stripped down to only show all entities and their state
|
// as generate_values_web() but stripped down to only show all entities and their state
|
||||||
// this is used only for WebCustomizationService::device_entities()
|
// this is used only for WebCustomizationService::device_entities()
|
||||||
void EMSdevice::generate_values_web_all(JsonArray & output) {
|
void EMSdevice::generate_values_web_customization(JsonArray & output) {
|
||||||
for (const auto & dv : devicevalues_) {
|
for (const auto & dv : devicevalues_) {
|
||||||
// also show commands and entities that have an empty full name
|
// also show commands and entities that have an empty full name
|
||||||
JsonObject obj = output.createNestedObject();
|
JsonObject obj = output.createNestedObject();
|
||||||
@@ -832,11 +832,19 @@ void EMSdevice::generate_values_web_all(JsonArray & output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// must always have v for sorting to work in web
|
obj["v"] = ""; // must always have v for sorting to work in web
|
||||||
obj["v"] = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add name, prefixing the tag if it exists as the id (key for table sorting)
|
// shortname
|
||||||
|
std::string shortname;
|
||||||
|
if (dv.tag >= DeviceValueTAG::TAG_HC1) {
|
||||||
|
shortname = tag_to_string(dv.tag) + "/" + read_flash_string(dv.short_name);
|
||||||
|
} else {
|
||||||
|
shortname = read_flash_string(dv.short_name);
|
||||||
|
}
|
||||||
|
obj["s"] = shortname;
|
||||||
|
|
||||||
|
// id is the fullname, or the shortname (it must exist for the web table to work)
|
||||||
if (dv.full_name) {
|
if (dv.full_name) {
|
||||||
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
|
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
|
||||||
obj["id"] = dv.full_name;
|
obj["id"] = dv.full_name;
|
||||||
@@ -846,14 +854,7 @@ void EMSdevice::generate_values_web_all(JsonArray & output) {
|
|||||||
obj["id"] = name;
|
obj["id"] = name;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obj["id"] = "";
|
obj["id"] = shortname; // fullname/id is same as shortname
|
||||||
}
|
|
||||||
|
|
||||||
// shortname
|
|
||||||
if (dv.tag >= DeviceValueTAG::TAG_HC1) {
|
|
||||||
obj["s"] = tag_to_string(dv.tag) + "/" + read_flash_string(dv.short_name);
|
|
||||||
} else {
|
|
||||||
obj["s"] = dv.short_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obj["m"] = dv.state >> 4; // send back the mask state. We're only interested in the high nibble
|
obj["m"] = dv.state >> 4; // send back the mask state. We're only interested in the high nibble
|
||||||
|
|||||||
Reference in New Issue
Block a user