[sht4x] Restore original comments removed in refactor

This commit is contained in:
J. Nick Koston
2026-03-20 14:10:40 -10:00
parent 464d333142
commit 0302a14fa2
+7
View File
@@ -79,7 +79,9 @@ void SHT4XComponent::dump_config() {
}
void SHT4XComponent::update() {
// Send command
if (!this->write_command(MEASURECOMMANDS[this->precision_])) {
// Warning will be printed only if warning status is not set yet
this->status_set_warning(LOG_STR("Failed to send measurement command"));
return;
}
@@ -87,7 +89,9 @@ void SHT4XComponent::update() {
this->set_timeout(10, [this]() {
uint16_t buffer[2];
// Read measurement
if (!this->read_data(buffer, 2)) {
// Using ESP_LOGW to force the warning to be printed
ESP_LOGW(TAG, "Sensor read failed");
this->status_set_warning();
return;
@@ -95,12 +99,15 @@ void SHT4XComponent::update() {
this->status_clear_warning();
// Evaluate and publish measurements
if (this->temp_sensor_ != nullptr) {
// Temp is contained in the first result word
float temp = TEMPERATURE_OFFSET + TEMPERATURE_SPAN * static_cast<float>(buffer[0]) / RAW_MAX;
this->temp_sensor_->publish_state(temp);
}
if (this->humidity_sensor_ != nullptr) {
// Relative humidity is in the second result word
float rh = HUMIDITY_OFFSET + HUMIDITY_SPAN * static_cast<float>(buffer[1]) / RAW_MAX;
this->humidity_sensor_->publish_state(rh);
}