standardizing is_valid_gpio

This commit is contained in:
proddy
2025-11-15 16:27:39 +01:00
parent bcde5bad63
commit c7acf89d84
6 changed files with 57 additions and 52 deletions

View File

@@ -187,8 +187,8 @@ void AnalogSensor::reload(bool get_nvs) {
for (auto & sensor : sensors_) {
sensor.ha_registered = false; // force HA configs to be re-created
// first check if the GPIO is valid. If not, force set it to disabled
if (!System::is_valid_gpio(sensor.gpio())) {
// first check if the GPIO is valid. If not, force set the sensor to disabled, but don't remove it
if (!EMSESP::system_.is_valid_gpio(sensor.gpio())) {
LOG_WARNING("Bad GPIO %d for Sensor %s. Disabling.", sensor.gpio(), sensor.name().c_str());
sensor.set_type(AnalogType::NOTUSED); // set disabled
continue; // skip this loop pass
@@ -542,7 +542,7 @@ bool AnalogSensor::update(uint8_t gpio, std::string & name, double offset, doubl
// 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);
return EMSESP::system_.is_valid_gpio(gpio);
}
// check to see if values have been updated