From 31c4551890273e902019bab26e17d8ea098cd975 Mon Sep 17 00:00:00 2001 From: Nicholas Peters Date: Tue, 7 Jun 2022 06:43:46 -0400 Subject: [PATCH] Fix sdp3x error checking (#3531) --- esphome/components/sdp3x/sdp3x.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/esphome/components/sdp3x/sdp3x.cpp b/esphome/components/sdp3x/sdp3x.cpp index 251d59607a..7a957e55ac 100644 --- a/esphome/components/sdp3x/sdp3x.cpp +++ b/esphome/components/sdp3x/sdp3x.cpp @@ -40,7 +40,7 @@ void SDP3XComponent::setup() { } uint16_t data[6]; - if (this->read_data(data, 6) != i2c::ERROR_OK) { + if (!this->read_data(data, 6)) { ESP_LOGE(TAG, "Read ID SDP3X failed!"); this->mark_failed(); return; @@ -78,8 +78,7 @@ void SDP3XComponent::setup() { } } - if (this->write_command(measurement_mode_ == DP_AVG ? SDP3X_START_DP_AVG : SDP3X_START_MASS_FLOW_AVG) != - i2c::ERROR_OK) { + if (!this->write_command(measurement_mode_ == DP_AVG ? SDP3X_START_DP_AVG : SDP3X_START_MASS_FLOW_AVG)) { ESP_LOGE(TAG, "Start Measurements SDP3X failed!"); this->mark_failed(); return; @@ -98,7 +97,7 @@ void SDP3XComponent::dump_config() { void SDP3XComponent::read_pressure_() { uint16_t data[3]; - if (this->read_data(data, 3) != i2c::ERROR_OK) { + if (!this->read_data(data, 3)) { ESP_LOGW(TAG, "Couldn't read SDP3X data!"); this->status_set_warning(); return;