From ab5611cb5b3e91ccc074eb5e1bb26c04c1839c88 Mon Sep 17 00:00:00 2001 From: valordk Date: Fri, 26 Jul 2019 02:19:00 +0200 Subject: [PATCH] #550 Fix STH3x component reporting WARNING status and reinitialzing the sensor upon reconnecting. --- esphome/components/sht3xd/sht3xd.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/esphome/components/sht3xd/sht3xd.cpp b/esphome/components/sht3xd/sht3xd.cpp index f23c0d59b4..e021570dc3 100644 --- a/esphome/components/sht3xd/sht3xd.cpp +++ b/esphome/components/sht3xd/sht3xd.cpp @@ -43,8 +43,14 @@ void SHT3XDComponent::dump_config() { } float SHT3XDComponent::get_setup_priority() const { return setup_priority::DATA; } void SHT3XDComponent::update() { - if (!this->write_command_(SHT3XD_COMMAND_POLLING_H)) + if (this->status_has_warning()){ + ESP_LOGD(TAG, "Retrying to reconnect the sensor."); + this->write_command_(SHT3XD_COMMAND_SOFT_RESET); + } + if (!this->write_command_(SHT3XD_COMMAND_POLLING_H)){ + this->status_set_warning(); return; + } this->set_timeout(50, [this]() { uint16_t raw_data[2];