From 410fad3b41640b76c7f902fb4656d0b1c2598681 Mon Sep 17 00:00:00 2001 From: SenexCrenshaw <35600301+SenexCrenshaw@users.noreply.github.com> Date: Tue, 16 Feb 2021 02:42:14 -0500 Subject: [PATCH] fix DHT auto_detect check (#1536) --- esphome/components/dht/dht.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/dht/dht.cpp b/esphome/components/dht/dht.cpp index 988a5300dd..9626260cf2 100644 --- a/esphome/components/dht/dht.cpp +++ b/esphome/components/dht/dht.cpp @@ -32,19 +32,19 @@ void DHT::dump_config() { void DHT::update() { float temperature, humidity; - bool error; + bool success; if (this->model_ == DHT_MODEL_AUTO_DETECT) { this->model_ = DHT_MODEL_DHT22; - error = this->read_sensor_(&temperature, &humidity, false); - if (error) { + success = this->read_sensor_(&temperature, &humidity, false); + if (!success) { this->model_ = DHT_MODEL_DHT11; return; } } else { - error = this->read_sensor_(&temperature, &humidity, true); + success = this->read_sensor_(&temperature, &humidity, true); } - if (error) { + if (success) { ESP_LOGD(TAG, "Got Temperature=%.1f°C Humidity=%.1f%%", temperature, humidity); if (this->temperature_sensor_ != nullptr)