From 69df9c9ea474aafff9633cded2428d48fa57cde5 Mon Sep 17 00:00:00 2001 From: Philipp Harms Date: Sat, 19 Oct 2024 06:00:35 +0200 Subject: [PATCH] fix error handling --- esphome/components/mcp3221/mcp3221_sensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mcp3221/mcp3221_sensor.cpp b/esphome/components/mcp3221/mcp3221_sensor.cpp index 674be499c3..dd5a55df73 100644 --- a/esphome/components/mcp3221/mcp3221_sensor.cpp +++ b/esphome/components/mcp3221/mcp3221_sensor.cpp @@ -10,7 +10,7 @@ static const char *const TAG = "mcp3221"; void MCP3221Sensor::setup() { ESP_LOGCONFIG(TAG, "Probing MCP3221..."); - if (!this->write(nullptr, 0)) { + if (this->write(nullptr, 0) != i2c::ERROR_OK) { this->mark_failed(); return; } @@ -20,7 +20,7 @@ float MCP3221Sensor::get_setup_priority() const { return setup_priority::DATA; } float MCP3221Sensor::sample() { uint8_t data[2]; - if (!this->read(data, 2)) { + if (this->read(data, 2) != i2c::ERROR_OK) { ESP_LOGW(TAG, "Failed to read data from MCP3221"); this->status_set_warning(); return NAN;