mirror of
https://github.com/esphome/esphome.git
synced 2024-12-01 11:14:13 +01:00
fix DHT auto_detect check (#1536)
This commit is contained in:
parent
dce20680d7
commit
410fad3b41
1 changed files with 5 additions and 5 deletions
|
@ -32,19 +32,19 @@ void DHT::dump_config() {
|
||||||
|
|
||||||
void DHT::update() {
|
void DHT::update() {
|
||||||
float temperature, humidity;
|
float temperature, humidity;
|
||||||
bool error;
|
bool success;
|
||||||
if (this->model_ == DHT_MODEL_AUTO_DETECT) {
|
if (this->model_ == DHT_MODEL_AUTO_DETECT) {
|
||||||
this->model_ = DHT_MODEL_DHT22;
|
this->model_ = DHT_MODEL_DHT22;
|
||||||
error = this->read_sensor_(&temperature, &humidity, false);
|
success = this->read_sensor_(&temperature, &humidity, false);
|
||||||
if (error) {
|
if (!success) {
|
||||||
this->model_ = DHT_MODEL_DHT11;
|
this->model_ = DHT_MODEL_DHT11;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
ESP_LOGD(TAG, "Got Temperature=%.1f°C Humidity=%.1f%%", temperature, humidity);
|
||||||
|
|
||||||
if (this->temperature_sensor_ != nullptr)
|
if (this->temperature_sensor_ != nullptr)
|
||||||
|
|
Loading…
Reference in a new issue