diff --git a/src/analogsensor.h b/src/analogsensor.h index 04e5439ff..96f239e0a 100644 --- a/src/analogsensor.h +++ b/src/analogsensor.h @@ -153,8 +153,8 @@ class AnalogSensor { return (!sensors_.empty()); } - size_t count_entities(bool count_disabled = false) const { - if (count_disabled) { + size_t count_entities(bool include_disabled = true) const { + if (!include_disabled) { // count number of items in sensors_ where type is not set to disabled return std::count_if(sensors_.begin(), sensors_.end(), [](const Sensor & sensor) { return sensor.type() != AnalogSensor::AnalogType::NOTUSED; }); } diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index c2b80a708..f30109b5e 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -400,8 +400,8 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) { } } - // add analog sensors - if (EMSESP::analog_enabled() && EMSESP::analogsensor_.have_sensors()) { + // add analog sensors, count excludes disabled entries + if (EMSESP::analog_enabled() && EMSESP::analogsensor_.count_entities(false)) { JsonObject obj = root.add(); obj["id"] = EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID; // it's unique id obj["t"] = EMSdevice::DeviceType::ANALOGSENSOR; // device type number