mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
don't include disabled analog sensors in dashboard
This commit is contained in:
@@ -153,7 +153,11 @@ class AnalogSensor {
|
|||||||
return (!sensors_.empty());
|
return (!sensors_.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t count_entities() const {
|
size_t count_entities(bool count_disabled = false) const {
|
||||||
|
if (count_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 sensors_.size();
|
return sensors_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
|
|||||||
JsonArray nodes = obj["nodes"].to<JsonArray>();
|
JsonArray nodes = obj["nodes"].to<JsonArray>();
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
for (const auto & sensor : EMSESP::analogsensor_.sensors()) {
|
for (const auto & sensor : EMSESP::analogsensor_.sensors()) {
|
||||||
if (sensor.type() != AnalogSensor::AnalogType::NOTUSED) {
|
if (sensor.type() != AnalogSensor::AnalogType::NOTUSED) { // ignore disabled
|
||||||
JsonObject node = nodes.add<JsonObject>();
|
JsonObject node = nodes.add<JsonObject>();
|
||||||
node["id"] = (EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID * 100) + count++;
|
node["id"] = (EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID * 100) + count++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user