diff --git a/src/supla/sensor/therm_hygro_meter.cpp b/src/supla/sensor/therm_hygro_meter.cpp index c24605c7..53ba7de1 100644 --- a/src/supla/sensor/therm_hygro_meter.cpp +++ b/src/supla/sensor/therm_hygro_meter.cpp @@ -91,19 +91,21 @@ void Supla::Sensor::ThermHygroMeter::onLoadConfig(SuplaDeviceClass *sdc) { return; } - // set temperature correction - auto cfgTempCorrection = getConfiguredTemperatureCorrection(); - double correction = 1.0 * cfgTempCorrection / 10.0; - getChannel()->setCorrection(correction); - SUPLA_LOG_DEBUG("Channel[%d] temperature correction %.2f", - getChannelNumber(), correction); - - // set humidity correction - auto cfgHumCorrection = getConfiguredHumidityCorrection(); - correction = 1.0 * cfgHumCorrection / 10.0; - getChannel()->setCorrection(correction, true); - SUPLA_LOG_DEBUG("Channel[%d] humidity correction %.2f", - getChannelNumber(), correction); + if (applyCorrections) { + // set temperature correction + auto cfgTempCorrection = getConfiguredTemperatureCorrection(); + double correction = 1.0 * cfgTempCorrection / 10.0; + getChannel()->setCorrection(correction); + SUPLA_LOG_DEBUG("Channel[%d] temperature correction %.2f", + getChannelNumber(), correction); + + // set humidity correction + auto cfgHumCorrection = getConfiguredHumidityCorrection(); + correction = 1.0 * cfgHumCorrection / 10.0; + getChannel()->setCorrection(correction, true); + SUPLA_LOG_DEBUG("Channel[%d] humidity correction %.2f", + getChannelNumber(), correction); + } // load config changed offline flags loadConfigChangeFlag(); @@ -269,3 +271,7 @@ void Supla::Sensor::ThermHygroMeter::fillChannelConfig(void *channelConfig, config->AdjustmentAppliedByDevice = 1; } +void Supla::Sensor::ThermHygroMeter::setApplyCorrections( + bool applyCorrections) { + this->applyCorrections = applyCorrections; +} diff --git a/src/supla/sensor/therm_hygro_meter.h b/src/supla/sensor/therm_hygro_meter.h index 603ab0c6..d4da8ca6 100644 --- a/src/supla/sensor/therm_hygro_meter.h +++ b/src/supla/sensor/therm_hygro_meter.h @@ -52,6 +52,16 @@ class ThermHygroMeter : public ChannelElement { int32_t humidityCorrection, bool local = false); + // By default temperature and humidity corrections are applied on Channel + // level, so raw value is read from sensor, then it is corrected and + // send to server. + // However correction may be applied by a sensor device itself. In this + // case, correciton is send to that device and value read from sensor is + // already corrected. + // + // This function sets whether correction should be applied or not. + void setApplyCorrections(bool applyCorrections); + protected: int16_t readCorrectionFromIndex(int index); void setCorrectionAtIndex(int32_t correction, int index); @@ -60,6 +70,7 @@ class ThermHygroMeter : public ChannelElement { uint32_t lastReadTime = 0; uint16_t refreshIntervalMs = 10000; + bool applyCorrections = true; }; }; // namespace Sensor