mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
show error when using an invalid gpio in webUI
This commit is contained in:
@@ -134,7 +134,7 @@ void AnalogSensor::reload(bool get_nvs) {
|
|||||||
// first check if the GPIO is valid. If not, force set it to disabled
|
// first check if the GPIO is valid. If not, force set it to disabled
|
||||||
if (!System::is_valid_gpio(sensor.gpio())) {
|
if (!System::is_valid_gpio(sensor.gpio())) {
|
||||||
LOG_WARNING("Bad GPIO %d for Sensor %s. Disabling.", sensor.gpio(), sensor.name().c_str());
|
LOG_WARNING("Bad GPIO %d for Sensor %s. Disabling.", sensor.gpio(), sensor.name().c_str());
|
||||||
sensor.set_type(AnalogType::NOTUSED);
|
sensor.set_type(AnalogType::NOTUSED); // set disabled
|
||||||
continue; // skip this loop pass
|
continue; // skip this loop pass
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,9 @@ bool AnalogSensor::update(uint8_t gpio, std::string & name, double offset, doubl
|
|||||||
// reloads the sensors in the customizations file into the sensors list
|
// reloads the sensors in the customizations file into the sensors list
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
return true;
|
// return false if it's an invalid GPIO, an error will show in WebUI
|
||||||
|
// and reported as an error in the log
|
||||||
|
return System::is_valid_gpio(gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to see if values have been updated
|
// check to see if values have been updated
|
||||||
|
|||||||
Reference in New Issue
Block a user