show dashboard nodes when there is data

This commit is contained in:
proddy
2024-10-16 23:59:34 +02:00
parent 3f1c30c948
commit 7d93ecb949
2 changed files with 2 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ uint8_t EMSdevice::count_entities() {
uint8_t EMSdevice::count_entities_fav() { uint8_t EMSdevice::count_entities_fav() {
uint8_t count = 0; uint8_t count = 0;
for (const auto & dv : devicevalues_) { for (const auto & dv : devicevalues_) {
count += dv.has_state(DeviceValueState::DV_FAVORITE); count += dv.has_state(DeviceValueState::DV_FAVORITE) && dv.hasValue();
} }
return count; return count;
} }

View File

@@ -355,6 +355,7 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
JsonArray root = response->getRoot(); JsonArray root = response->getRoot();
#endif #endif
// first do all the recognized devices
for (const auto & emsdevice : EMSESP::emsdevices) { for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice->count_entities_fav()) { if (emsdevice->count_entities_fav()) {
JsonObject obj = root.add<JsonObject>(); JsonObject obj = root.add<JsonObject>();