mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
fix dashboard/disabled analog sensors
This commit is contained in:
@@ -153,8 +153,8 @@ class AnalogSensor {
|
|||||||
return (!sensors_.empty());
|
return (!sensors_.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t count_entities(bool count_disabled = false) const {
|
size_t count_entities(bool include_disabled = true) const {
|
||||||
if (count_disabled) {
|
if (!include_disabled) {
|
||||||
// count number of items in sensors_ where type is not set to 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; });
|
return std::count_if(sensors_.begin(), sensors_.end(), [](const Sensor & sensor) { return sensor.type() != AnalogSensor::AnalogType::NOTUSED; });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -400,8 +400,8 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add analog sensors
|
// add analog sensors, count excludes disabled entries
|
||||||
if (EMSESP::analog_enabled() && EMSESP::analogsensor_.have_sensors()) {
|
if (EMSESP::analog_enabled() && EMSESP::analogsensor_.count_entities(false)) {
|
||||||
JsonObject obj = root.add<JsonObject>();
|
JsonObject obj = root.add<JsonObject>();
|
||||||
obj["id"] = EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID; // it's unique id
|
obj["id"] = EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID; // it's unique id
|
||||||
obj["t"] = EMSdevice::DeviceType::ANALOGSENSOR; // device type number
|
obj["t"] = EMSdevice::DeviceType::ANALOGSENSOR; // device type number
|
||||||
|
|||||||
Reference in New Issue
Block a user