[components] Let core report communication failures in dump_config (5/5) (#20874)

This commit is contained in:
J. Nick Koston
2026-10-17 15:16:21 -10:00
committed by GitHub
parent ec642f928f
commit c1687aba4c
34 changed files with 54 additions and 220 deletions
+1 -5
View File
@@ -29,8 +29,7 @@ void SHTCXComponent::setup() {
uint16_t device_id_register;
if (!this->write_command(SHTCX_COMMAND_READ_ID_REGISTER) || !this->read_data(&device_id_register, 1)) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -53,9 +52,6 @@ void SHTCXComponent::dump_config() {
" Model: %s (%04x)",
LOG_STR_ARG(shtcx_type_to_string(this->type_)), this->sensor_id_);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
+2 -29
View File
@@ -29,15 +29,13 @@ void SPS30Component::setup() {
this->set_timeout(500, [this]() {
/// Firmware version identification
if (!this->get_register(SPS30_CMD_GET_FIRMWARE_VERSION, raw_firmware_version_, 1)) {
this->error_code_ = FIRMWARE_VERSION_READ_FAILED;
this->mark_failed();
this->mark_failed(LOG_STR("Unable to read firmware version"));
return;
}
/// Serial number identification
uint16_t raw_serial_number[8];
if (!this->get_register(SPS30_CMD_GET_SERIAL_NUMBER, raw_serial_number, 8, 1)) {
this->error_code_ = SERIAL_NUMBER_READ_FAILED;
this->mark_failed();
this->mark_failed(LOG_STR("Unable to read serial number"));
return;
}
@@ -75,31 +73,6 @@ void SPS30Component::setup() {
void SPS30Component::dump_config() {
ESP_LOGCONFIG(TAG, "SPS30:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case MEASUREMENT_INIT_FAILED:
ESP_LOGW(TAG, "Measurement Initialization failed");
break;
case SERIAL_NUMBER_REQUEST_FAILED:
ESP_LOGW(TAG, "Unable to request serial number");
break;
case SERIAL_NUMBER_READ_FAILED:
ESP_LOGW(TAG, "Unable to read serial number");
break;
case FIRMWARE_VERSION_REQUEST_FAILED:
ESP_LOGW(TAG, "Unable to request firmware version");
break;
case FIRMWARE_VERSION_READ_FAILED:
ESP_LOGW(TAG, "Unable to read firmware version");
break;
default:
ESP_LOGW(TAG, "Unknown setup error");
break;
}
}
LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG,
" Serial number: %s\n"
-10
View File
@@ -42,16 +42,6 @@ class SPS30Component final : public PollingComponent, public sensirion_common::S
bool start_continuous_measurement_();
enum ErrorCode : uint8_t {
COMMUNICATION_FAILED,
FIRMWARE_VERSION_REQUEST_FAILED,
FIRMWARE_VERSION_READ_FAILED,
SERIAL_NUMBER_REQUEST_FAILED,
SERIAL_NUMBER_READ_FAILED,
MEASUREMENT_INIT_FAILED,
UNKNOWN
} error_code_{UNKNOWN};
sensor::Sensor *pm_1_0_sensor_{nullptr};
sensor::Sensor *pm_2_5_sensor_{nullptr};
sensor::Sensor *pm_4_0_sensor_{nullptr};
@@ -10,8 +10,7 @@ void I2CSSD1306::setup() {
auto err = this->write(nullptr, 0);
if (err != i2c::ERROR_OK) {
this->error_code_ = COMMUNICATION_FAILED;
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -32,10 +31,6 @@ void I2CSSD1306::dump_config() {
LOG_I2C_DEVICE(this);
LOG_PIN(" Reset Pin: ", this->reset_pin_);
LOG_UPDATE_INTERVAL(this);
if (this->error_code_ == COMMUNICATION_FAILED) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void I2CSSD1306::command(uint8_t value) { this->write_byte(0x00, value); }
void HOT I2CSSD1306::write_display_data() {
@@ -14,8 +14,6 @@ class I2CSSD1306 final : public ssd1306_base::SSD1306, public i2c::I2CDevice {
protected:
void command(uint8_t value) override;
void write_display_data() override;
enum ErrorCode { NONE = 0, COMMUNICATION_FAILED } error_code_{NONE};
};
} // namespace esphome::ssd1306_i2c
@@ -10,8 +10,7 @@ void I2CSSD1327::setup() {
auto err = this->write(nullptr, 0);
if (err != i2c::ERROR_OK) {
this->error_code_ = COMMUNICATION_FAILED;
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -23,10 +22,6 @@ void I2CSSD1327::dump_config() {
ESP_LOGCONFIG(TAG, " Model: %s", this->model_str_());
LOG_PIN(" Reset Pin: ", this->reset_pin_);
LOG_UPDATE_INTERVAL(this);
if (this->error_code_ == COMMUNICATION_FAILED) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void I2CSSD1327::command(uint8_t value) { this->write_byte(0x00, value); }
void HOT I2CSSD1327::write_display_data() {
@@ -14,8 +14,6 @@ class I2CSSD1327 final : public ssd1327_base::SSD1327, public i2c::I2CDevice {
protected:
void command(uint8_t value) override;
void write_display_data() override;
enum ErrorCode { NONE = 0, COMMUNICATION_FAILED } error_code_{NONE};
};
} // namespace esphome::ssd1327_i2c
+1 -6
View File
@@ -10,8 +10,7 @@ void I2CST7567::setup() {
auto err = this->write(nullptr, 0);
if (err != i2c::ERROR_OK) {
this->error_code_ = COMMUNICATION_FAILED;
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
ST7567::setup();
@@ -28,10 +27,6 @@ void I2CST7567::dump_config() {
LOG_I2C_DEVICE(this);
LOG_PIN(" Reset Pin: ", this->reset_pin_);
LOG_UPDATE_INTERVAL(this);
if (this->error_code_ == COMMUNICATION_FAILED) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void I2CST7567::command(uint8_t value) { this->write_byte(0x00, value); }
@@ -14,8 +14,6 @@ class I2CST7567 final : public st7567_base::ST7567, public i2c::I2CDevice {
protected:
void command(uint8_t value) override;
void write_display_data() override;
enum ErrorCode { NONE = 0, COMMUNICATION_FAILED } error_code_{NONE};
};
} // namespace esphome::st7567_i2c
+3 -9
View File
@@ -77,8 +77,7 @@ void STCC4Component::poll_until_ready_for_setup_or_timeout_(uint32_t start_time)
(uint64_t(raw_product_id[4]) << 16) | raw_product_id[5];
ESP_LOGD(TAG, "Product ID: 0x%08" PRIX32 ", Serial: 0x%016" PRIX64, product_id, serial_number);
if (product_id != STCC4_PRODUCT_ID) {
ESP_LOGE(TAG, "Unsupported product ID");
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
this->mark_failed(LOG_STR("Unsupported product ID"));
return;
}
@@ -106,8 +105,7 @@ void STCC4Component::poll_until_ready_for_setup_or_timeout_(uint32_t start_time)
// Start continuous measurement
if (!this->write_command(STCC4_CMD_START_CONTINUOUS_MEASUREMENT)) {
ESP_LOGE(TAG, "Failed to start continuous measurement");
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
this->mark_failed(LOG_STR("Failed to start continuous measurement"));
return;
}
this->schedule_continuous_update_(false);
@@ -123,8 +121,7 @@ void STCC4Component::poll_until_ready_for_setup_or_timeout_(uint32_t start_time)
return;
}
ESP_LOGE(TAG, "Failed to stop continuous measurements and read product ID");
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
this->mark_failed(LOG_STR("Failed to stop continuous measurements and read product ID"));
}
void STCC4Component::finish_setup_() {
@@ -143,9 +140,6 @@ void STCC4Component::finish_setup_() {
void STCC4Component::dump_config() {
ESP_LOGCONFIG(TAG, "STCC4:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
}
ESP_LOGCONFIG(TAG, " Measurement mode: %s",
this->measurement_mode_ == MeasurementMode::CONTINUOUS ? LOG_STR_LITERAL("Continuous (1s)")
: LOG_STR_LITERAL("Single shot"));
+2 -5
View File
@@ -18,13 +18,13 @@ static const uint16_t STS3X_COMMAND_FETCH_DATA = 0xE000;
void STS3XComponent::setup() {
if (!this->write_command(STS3X_COMMAND_READ_SERIAL_NUMBER)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
uint16_t raw_serial_number[2];
if (!this->read_data(raw_serial_number, 1)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
uint32_t serial_number = (uint32_t(raw_serial_number[0]) << 16);
@@ -33,9 +33,6 @@ void STS3XComponent::setup() {
void STS3XComponent::dump_config() {
ESP_LOGCONFIG(TAG, "STS3x:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "STS3x", this);
-3
View File
@@ -37,9 +37,6 @@ void STTS22HComponent::dump_config() {
LOG_SENSOR("", "STTS22H", this);
LOG_I2C_DEVICE(this);
LOG_UPDATE_INTERVAL(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
float STTS22HComponent::read_temperature_() {
+2 -6
View File
@@ -164,7 +164,7 @@ void SX126x::configure() {
this->read_register_(REG_VERSION_STRING, (uint8_t *) this->version_, sizeof(this->version_));
this->version_[sizeof(this->version_) - 1] = '\0';
if (strncmp(this->version_, "SX126", 5) != 0 && strncmp(this->version_, "LLCC68", 6) != 0) {
this->mark_failed();
this->mark_failed(LOG_STR("Unsupported chip version"));
return;
}
@@ -494,8 +494,7 @@ void SX126x::wait_busy_() {
uint32_t start = millis();
while (this->busy_pin_->digital_read()) {
if (millis() - start > BUSY_TIMEOUT_MS) {
ESP_LOGE(TAG, "Wait busy timeout");
this->mark_failed();
this->mark_failed(LOG_STR("Wait busy timeout"));
break;
}
}
@@ -562,9 +561,6 @@ void SX126x::dump_config() {
if (this->whitening_enable_) {
ESP_LOGCONFIG(TAG, " Whitening Initial: 0x%03x", this->whitening_initial_);
}
if (this->is_failed()) {
ESP_LOGE(TAG, "Configuring SX126x failed");
}
}
} // namespace esphome::sx126x
+3 -8
View File
@@ -81,7 +81,7 @@ void SX127x::configure() {
// check silicon version to make sure hw is ok
if (this->read_register_(REG_VERSION) != 0x12) {
this->mark_failed();
this->mark_failed(LOG_STR("Unsupported chip version"));
return;
}
@@ -367,8 +367,7 @@ void SX127x::run_image_cal() {
uint32_t start = millis();
while (this->read_register_(REG_IMAGE_CAL) & IMAGE_CAL_RUNNING) {
if (millis() - start > 20) {
ESP_LOGE(TAG, "Image cal failure");
this->mark_failed();
this->mark_failed(LOG_STR("Image cal failure"));
break;
}
}
@@ -390,8 +389,7 @@ void SX127x::set_mode_(uint8_t modulation, uint8_t mode) {
break;
}
if (millis() - start > 20) {
ESP_LOGE(TAG, "Set mode failure");
this->mark_failed();
this->mark_failed(LOG_STR("Set mode failure"));
return;
}
}
@@ -508,9 +506,6 @@ void SX127x::dump_config() {
this->preamble_polarity_, this->preamble_size_, this->preamble_detect_, this->preamble_errors_);
}
}
if (this->is_failed()) {
ESP_LOGE(TAG, "Configuring SX127x failed");
}
}
} // namespace esphome::sx127x
+3 -6
View File
@@ -9,18 +9,18 @@ ESPHOME_LOG_TAG(TAG, "sx1509");
void SX1509Component::setup() {
ESP_LOGV(TAG, " Resetting devices");
if (!this->write_byte(REG_RESET, 0x12)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
this->write_byte(REG_RESET, 0x34);
uint16_t data;
if (!this->read_byte_16(REG_INTERRUPT_MASK_A, &data)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
if (data != 0xFF00) {
this->mark_failed();
this->mark_failed(LOG_STR("Unexpected reset value"));
return;
}
clock_(INTERNAL_CLOCK_2MHZ);
@@ -31,9 +31,6 @@ void SX1509Component::setup() {
void SX1509Component::dump_config() {
ESP_LOGCONFIG(TAG, "SX1509:");
if (this->is_failed()) {
ESP_LOGE(TAG, "Setting up SX1509 failed!");
}
LOG_I2C_DEVICE(this);
}
+1 -5
View File
@@ -60,8 +60,7 @@ void SY6970Component::setup() {
// Try to read chip ID
uint8_t reg_value;
if (!this->read_byte(SY6970_REG_DEVICE_ID, &reg_value)) {
ESP_LOGE(TAG, "Failed to communicate with SY6970");
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -116,9 +115,6 @@ void SY6970Component::dump_config() {
LOG_STR_ARG(i2c_watchdog_timeout_to_string(this->i2c_watchdog_timeout_)));
LOG_I2C_DEVICE(this);
LOG_UPDATE_INTERVAL(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Communication with SY6970 failed!");
}
}
void SY6970Component::update() {
+1 -4
View File
@@ -16,7 +16,7 @@ static const uint8_t TC74_DATA_READY_MASK = 0x40;
void TC74Component::setup() {
uint8_t config_reg;
if (this->read_register(TC74_REGISTER_CONFIGURATION, &config_reg, 1) != i2c::ERROR_OK) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
this->data_ready_ = config_reg & TC74_DATA_READY_MASK;
@@ -27,9 +27,6 @@ void TC74Component::update() { this->read_temperature_(); }
void TC74Component::dump_config() {
LOG_SENSOR("", "TC74", this);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, "Connection with TC74 failed!");
}
LOG_UPDATE_INTERVAL(this);
}
+4 -11
View File
@@ -15,21 +15,18 @@ void TCA8418Component::setup() {
// The configuration register reads back, so use it to check the device is there.
uint8_t config;
if (!this->read_byte(TCA8418_REG_CFG, &config)) {
ESP_LOGE(TAG, "Failed to read from device - check wiring / address");
this->mark_failed();
this->mark_failed(LOG_STR("Failed to read from device - check wiring / address"));
return;
}
if (!this->configure_pins_()) {
ESP_LOGE(TAG, "Failed to configure pins");
this->mark_failed();
this->mark_failed(LOG_STR("Failed to configure pins"));
return;
}
// Report key events, and keep the interrupt asserted while events remain queued.
if (!this->write_byte(TCA8418_REG_CFG, TCA8418_CFG_KEY_INT_EN | TCA8418_CFG_INT_CFG)) {
ESP_LOGE(TAG, "Failed to write the configuration register");
this->mark_failed();
this->mark_failed(LOG_STR("Failed to write the configuration register"));
return;
}
@@ -43,8 +40,7 @@ void TCA8418Component::setup() {
// Discard anything the device queued before it was configured, and clear
// every interrupt flag: leaving one set holds the interrupt output asserted.
if (!this->drain_events_(false)) {
ESP_LOGE(TAG, "Failed to clear the event queue");
this->mark_failed();
this->mark_failed(LOG_STR("Failed to clear the event queue"));
return;
}
@@ -162,9 +158,6 @@ void TCA8418Component::dump_config() {
}
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
} // namespace esphome::tca8418
+2 -5
View File
@@ -16,11 +16,11 @@ ESPHOME_LOG_TAG(TAG, "tca9555");
void TCA9555Component::setup() {
if (!this->read_gpio_modes_()) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
if (!this->read_gpio_outputs_()) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -36,9 +36,6 @@ void TCA9555Component::dump_config() {
ESP_LOGCONFIG(TAG, "TCA9555:");
LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_);
LOG_I2C_DEVICE(this)
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void TCA9555Component::pin_mode(uint8_t pin, gpio::Flags flags) {
if (flags == gpio::FLAG_INPUT) {
+5 -8
View File
@@ -19,23 +19,23 @@ static const uint8_t TCS34725_REGISTER_CRGBDATAL = TCS34725_COMMAND_BIT | 0x14;
void TCS34725Component::setup() {
uint8_t id;
if (this->read_register(TCS34725_REGISTER_ID, &id, 1) != i2c::ERROR_OK) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
if (this->write_config_register_(TCS34725_REGISTER_ATIME, this->integration_reg_) != i2c::ERROR_OK ||
this->write_config_register_(TCS34725_REGISTER_CONTROL, this->gain_reg_) != i2c::ERROR_OK) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
if (this->write_config_register_(TCS34725_REGISTER_ENABLE, 0x01) !=
i2c::ERROR_OK) { // Power on (internal oscillator on)
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
delay(3);
if (this->write_config_register_(TCS34725_REGISTER_ENABLE, 0x03) !=
i2c::ERROR_OK) { // Power on (internal oscillator on) + RGBC ADC Enable
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
}
@@ -43,9 +43,6 @@ void TCS34725Component::setup() {
void TCS34725Component::dump_config() {
ESP_LOGCONFIG(TAG, "TCS34725:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Clear Channel", this->clear_sensor_);
@@ -292,7 +289,7 @@ void TCS34725Component::update() {
set_gain((TCS34725Gain) gain_reg_val_new);
if (this->write_config_register_(TCS34725_REGISTER_ATIME, this->integration_reg_) != i2c::ERROR_OK ||
this->write_config_register_(TCS34725_REGISTER_CONTROL, this->gain_reg_) != i2c::ERROR_OK) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
ESP_LOGW(TAG, "TCS34725I update timing failed!");
} else {
this->integration_time_ = integration_time_next;
@@ -65,32 +65,27 @@ void TLC59208FOutput::setup() {
// Reset all devices on the bus
if (this->bus_->write_readv(TLC59208F_SWRST_ADDR >> 1, TLC59208F_SWRST_SEQ, sizeof TLC59208F_SWRST_SEQ, nullptr, 0) !=
i2c::ERROR_OK) {
ESP_LOGE(TAG, "RESET failed");
this->mark_failed();
this->mark_failed(LOG_STR("RESET failed"));
return;
}
// Auto increment registers, and respond to all-call address
if (!this->write_byte(TLC59208F_REG_MODE1, TLC59208F_MODE1_AI2 | TLC59208F_MODE1_ALLCALL)) {
ESP_LOGE(TAG, "MODE1 failed");
this->mark_failed();
this->mark_failed(LOG_STR("MODE1 failed"));
return;
}
if (!this->write_byte(TLC59208F_REG_MODE2, this->mode_)) {
ESP_LOGE(TAG, "MODE2 failed");
this->mark_failed();
this->mark_failed(LOG_STR("MODE2 failed"));
return;
}
// Set all 3 outputs to be individually controlled
// TODO: think of a way to support group dimming
if (!this->write_byte(TLC59208F_REG_LEDOUT0, (LDR_PWM << 6) | (LDR_PWM << 4) | (LDR_PWM << 2) | (LDR_PWM << 0))) {
ESP_LOGE(TAG, "LEDOUT0 failed");
this->mark_failed();
this->mark_failed(LOG_STR("LEDOUT0 failed"));
return;
}
if (!this->write_byte(TLC59208F_REG_LEDOUT1, (LDR_PWM << 6) | (LDR_PWM << 4) | (LDR_PWM << 2) | (LDR_PWM << 0))) {
ESP_LOGE(TAG, "LEDOUT1 failed");
this->mark_failed();
this->mark_failed(LOG_STR("LEDOUT1 failed"));
return;
}
delayMicroseconds(500);
@@ -103,10 +98,6 @@ void TLC59208FOutput::dump_config() {
"TLC59208F:\n"
" Mode: 0x%02X",
this->mode_);
if (this->is_failed()) {
ESP_LOGE(TAG, "Setting up TLC59208F failed!");
}
}
void TLC59208FOutput::loop() {
-3
View File
@@ -256,9 +256,6 @@ void TMC22XXStepper::dump_config() {
LOG_PIN(" INDEX Pin: ", this->index_pin_);
LOG_PIN(" DIAG Pin: ", this->diag_pin_);
LOG_STEPPER(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void TMC22XXStepper::loop() {
+1 -4
View File
@@ -96,7 +96,7 @@ void TMP102Component::setup_configured_() {
#endif
if (!this->write_configuration_()) {
this->publish_threshold_status_(TMP102_THRESHOLD_STATUS_SETUP_FAILED);
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
#ifdef USE_TMP102_NUMBER
@@ -123,9 +123,6 @@ void TMP102Component::setup_configured_() {
void TMP102Component::dump_config() {
ESP_LOGCONFIG(TAG, "TMP102:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
LOG_SENSOR(" ", "Temperature", this);
#ifdef USE_TMP102_BINARY_SENSOR
+2 -4
View File
@@ -20,7 +20,7 @@ void TMP1075Sensor::setup() {
uint8_t cfg;
if (!this->read_byte(REG_CFGR, &cfg)) {
ESP_LOGE(TAG, "'%s' - unable to read", this->name_.c_str());
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -42,10 +42,8 @@ void TMP1075Sensor::update() {
void TMP1075Sensor::dump_config() {
LOG_SENSOR("", "TMP1075 Sensor", this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
if (this->is_failed())
return;
}
ESP_LOGCONFIG(TAG,
" limit low : %.4f °C\n"
" limit high : %.4f °C\n"
+2 -5
View File
@@ -25,22 +25,19 @@ void TMP117Component::update() {
}
void TMP117Component::setup() {
if (!this->write_config_(this->config_)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
int16_t data;
if (!this->read_data_(&data)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
}
void TMP117Component::dump_config() {
ESP_LOGCONFIG(TAG, "TMP117:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_SENSOR(" ", "Temperature", this);
}
+2 -6
View File
@@ -18,13 +18,13 @@ static const uint8_t TSL2561_REGISTER_DATA_1 = 0x0E;
void TSL2561Sensor::setup() {
uint8_t id;
if (!this->tsl2561_read_byte(TSL2561_REGISTER_ID, &id)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
uint8_t timing;
if (!this->tsl2561_read_byte(TSL2561_REGISTER_TIMING, &timing)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
@@ -40,10 +40,6 @@ void TSL2561Sensor::dump_config() {
LOG_SENSOR("", "TSL2561", this);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
int gain = this->gain_ == TSL2561_GAIN_1X ? 1 : 16;
ESP_LOGCONFIG(TAG,
" Gain: %dx\n"
+1 -3
View File
@@ -73,10 +73,8 @@ void TSL2591Component::dump_config() {
ESP_LOGCONFIG(TAG, "TSL2591:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
if (this->is_failed())
return;
}
ESP_LOGCONFIG(TAG, " Name: %s", this->name_);
TSL2591ComponentGain raw_gain = this->component_gain_;
+1 -10
View File
@@ -8,22 +8,13 @@ ESPHOME_LOG_TAG(TAG, "ttp229_lsf");
void TTP229LSFComponent::setup() {
uint8_t data[2];
if (this->read(data, 2) != i2c::ERROR_OK) {
this->error_code_ = COMMUNICATION_FAILED;
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
}
void TTP229LSFComponent::dump_config() {
ESP_LOGCONFIG(TAG, "ttp229:");
LOG_I2C_DEVICE(this);
switch (this->error_code_) {
case COMMUNICATION_FAILED:
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
break;
case NONE:
default:
break;
}
}
void TTP229LSFComponent::loop() {
uint16_t touched = 0;
@@ -26,10 +26,6 @@ class TTP229LSFComponent final : public Component, public i2c::I2CDevice {
protected:
std::vector<TTP229Channel *> channels_{};
enum ErrorCode {
NONE = 0,
COMMUNICATION_FAILED,
} error_code_{NONE};
};
} // namespace esphome::ttp229_lsf
+3 -8
View File
@@ -21,16 +21,14 @@ static const uint8_t MAX_ADJUSTMENTS_PER_UPDATE = 2;
void VEML3235Sensor::setup() {
uint8_t device_id[] = {0, 0};
if (!this->refresh_config_reg()) {
ESP_LOGE(TAG, "Unable to write configuration");
this->mark_failed();
this->mark_failed(LOG_STR("Unable to write configuration"));
return;
}
if ((this->read_register(ID_REG, device_id, sizeof device_id) != i2c::ERROR_OK)) {
ESP_LOGE(TAG, "Unable to read ID");
this->mark_failed();
this->mark_failed(LOG_STR("Unable to read ID"));
} else if (device_id[0] != DEVICE_ID) {
ESP_LOGE(TAG, "Incorrect device ID - expected 0x%.2x, read 0x%.2x", DEVICE_ID, device_id[0]);
this->mark_failed();
this->mark_failed(LOG_STR("Incorrect device ID"));
}
}
@@ -187,9 +185,6 @@ void VEML3235Sensor::dump_config() {
LOG_SENSOR("", "VEML3235", this);
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
LOG_UPDATE_INTERVAL(this);
ESP_LOGCONFIG(TAG, " Auto-gain enabled: %s", YESNO(this->auto_gain_));
if (this->auto_gain_) {
+1 -6
View File
@@ -80,8 +80,7 @@ static const char *get_gain_str(Gain gain) {
void VEML7700Component::setup() {
auto err = this->configure_();
if (err != i2c::ERROR_OK) {
ESP_LOGW(TAG, "Sensor configuration failed");
this->mark_failed();
this->mark_failed(LOG_STR("Sensor configuration failed"));
} else {
this->state_ = State::INITIAL_SETUP_COMPLETED;
}
@@ -109,10 +108,6 @@ void VEML7700Component::dump_config() {
LOG_SENSOR(" ", "FAKE_IR channel lux", this->fake_infrared_sensor_);
LOG_SENSOR(" ", "Actual gain", this->actual_gain_sensor_);
LOG_SENSOR(" ", "Actual integration time", this->actual_integration_time_sensor_);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
void VEML7700Component::update() {
@@ -20,8 +20,7 @@ void WaveshareIOCH32V003Component::setup() {
bool step2 = this->write_gpio_outputs_();
if (!step1 || !step2) {
ESP_LOGE(TAG, "Failed to initialize Waveshare IO expander");
this->mark_failed();
this->mark_failed(LOG_STR("Failed to initialize Waveshare IO expander"));
return;
}
@@ -46,9 +45,6 @@ void WaveshareIOCH32V003Component::loop() { this->reset_pin_cache_(); }
void WaveshareIOCH32V003Component::dump_config() {
ESP_LOGCONFIG(TAG, "WaveshareIO:");
LOG_I2C_DEVICE(this)
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
uint16_t WaveshareIOCH32V003Component::get_adc_value() {
+2 -5
View File
@@ -93,11 +93,11 @@ void XGZP68XXComponent::setup() {
// Display some sample bits to confirm we are talking to the sensor
if (i2c::ErrorCode::ERROR_OK != this->read_register(SYSCONFIG_ADDRESS, &config1, 1)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
if (i2c::ErrorCode::ERROR_OK != this->read_register(PCONFIG_ADDRESS, &config2, 1)) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
ESP_LOGD(TAG, "sys_config 0x%x, p_config 0x%x", config1, config2);
@@ -111,9 +111,6 @@ void XGZP68XXComponent::dump_config() {
ESP_LOGCONFIG(TAG, " Oversampling: %s", oversampling_to_str(this->pressure_oversampling_));
}
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, " Connection failed");
}
LOG_UPDATE_INTERVAL(this);
}
+1 -5
View File
@@ -9,7 +9,7 @@ void XL9535Component::setup() {
// Check to see if the device can read from the register
uint8_t port = 0;
if (this->read_register(XL9535_INPUT_PORT_0_REGISTER, &port, 1) != i2c::ERROR_OK) {
this->mark_failed();
this->mark_failed(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
}
@@ -17,10 +17,6 @@ void XL9535Component::setup() {
void XL9535Component::dump_config() {
ESP_LOGCONFIG(TAG, "XL9535:");
LOG_I2C_DEVICE(this);
if (this->is_failed()) {
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
}
}
bool XL9535Component::digital_read(uint8_t pin) {