diff --git a/esphome/components/api/api_connection.cpp b/esphome/components/api/api_connection.cpp index 09a701bf3d..4f32112fa6 100644 --- a/esphome/components/api/api_connection.cpp +++ b/esphome/components/api/api_connection.cpp @@ -146,7 +146,7 @@ void APIConnection::loop() { APIError err = this->helper_->loop(); if (err != APIError::OK) { - this->fatal_error_with_socket_log_(err); + this->fatal_error_with_log_(LOG_STR("Socket operation failed"), err); return; } @@ -1574,7 +1574,7 @@ bool APIConnection::try_to_clear_buffer(bool log_out_of_space) { delay(0); APIError err = this->helper_->loop(); if (err != APIError::OK) { - this->fatal_error_with_socket_log_(err); + this->fatal_error_with_log_(LOG_STR("Socket operation failed"), err); return false; } if (this->helper_->can_write_without_blocking()) diff --git a/esphome/components/api/api_connection.h b/esphome/components/api/api_connection.h index 3eb50ea8fe..ee9c81026c 100644 --- a/esphome/components/api/api_connection.h +++ b/esphome/components/api/api_connection.h @@ -737,9 +737,6 @@ class APIConnection final : public APIServerConnection { this->on_fatal_error(); this->log_warning_(message, err); } - inline void fatal_error_with_socket_log_(APIError err) { - this->fatal_error_with_log_(LOG_STR("Socket operation failed"), err); - } }; } // namespace esphome::api diff --git a/esphome/components/sps30/sps30.cpp b/esphome/components/sps30/sps30.cpp index dc14e3a610..21a782e49a 100644 --- a/esphome/components/sps30/sps30.cpp +++ b/esphome/components/sps30/sps30.cpp @@ -45,16 +45,16 @@ void SPS30Component::setup() { } ESP_LOGV(TAG, " Serial number: %s", this->serial_number_); + bool result; if (this->fan_interval_.has_value()) { // override default value - this->result_ = - this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS, this->fan_interval_.value()); + result = this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS, this->fan_interval_.value()); } else { - this->result_ = this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS); + result = this->write_command(SPS30_CMD_SET_AUTOMATIC_CLEANING_INTERVAL_SECONDS); } - this->set_timeout(20, [this]() { - if (this->result_) { + this->set_timeout(20, [this, result]() { + if (result) { uint16_t secs[2]; if (this->read_data(secs, 2)) { this->fan_interval_ = secs[0] << 16 | secs[1]; diff --git a/esphome/components/sps30/sps30.h b/esphome/components/sps30/sps30.h index cab5a075a0..18847e16d9 100644 --- a/esphome/components/sps30/sps30.h +++ b/esphome/components/sps30/sps30.h @@ -30,7 +30,6 @@ class SPS30Component : public PollingComponent, public sensirion_common::Sensiri bool start_fan_cleaning(); protected: - bool result_{false}; bool setup_complete_{false}; uint16_t raw_firmware_version_; char serial_number_[17] = {0}; /// Terminating NULL character