From 831e329519f0e9728a73f71713c37f4d6b4ce4ff Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:38:05 +0100 Subject: [PATCH 1/5] Update mcp4461_output.cpp --- esphome/components/mcp4461/output/mcp4461_output.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index f3bea80b9b..b246e0231c 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -8,6 +8,11 @@ namespace esphome { namespace mcp4461 { static const char *const TAG = "mcp4461.output"; +static const LogString *mcp4461_get_message_string(int status) { + switch (status) { + + } +} static const LogString *const LOG_PARENT_FAILED_STR = LOG_STR("Parent MCP4461 component has failed! Aborting"); void Mcp4461Wiper::write_state(float state) { From 86329bcdb9552c3bd012723631ff5fed2cf53665 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:41:12 +0100 Subject: [PATCH 2/5] Update mcp4461_output.cpp --- .../mcp4461/output/mcp4461_output.cpp | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index b246e0231c..438b150944 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -8,16 +8,18 @@ namespace esphome { namespace mcp4461 { static const char *const TAG = "mcp4461.output"; -static const LogString *mcp4461_get_message_string(int status) { +static const LogString *get_wiper_message_string(int status) { switch (status) { - + case Mcp4461Component::COMPONENT_FAILED: + return LOG_STR("Parent MCP4461 component failed"); + default: + return LOG_STR("Unknown error"); } } -static const LogString *const LOG_PARENT_FAILED_STR = LOG_STR("Parent MCP4461 component has failed! Aborting"); void Mcp4461Wiper::write_state(float state) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -39,7 +41,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level void Mcp4461Wiper::save_level() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -55,7 +57,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -68,7 +70,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -81,7 +83,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -96,7 +98,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -111,7 +113,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -124,7 +126,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) { void Mcp4461Wiper::disable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); From a142f23b640475a295231bd5a66b0ca14a09c97f Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:42:42 +0100 Subject: [PATCH 3/5] Update mcp4461.cpp --- esphome/components/mcp4461/mcp4461.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index dcc4b566ce..c0002dc6d9 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -52,8 +52,6 @@ static const LogString *mcp4461_get_message_string(int status) { return LOG_STR("Status register could not be read"); case Mcp4461Component::MCP4461_STATUS_REGISTER_INVALID: return LOG_STR("Invalid status register value - bits 1,7 or 8 are 0"); - case Mcp4461Component::MCP4461_PARENT_FAILED: - return LOG_STR("Parent component failed"); case Mcp4461Component::MCP4461_VALUE_INVALID: return LOG_STR("Invalid value for wiper given"); case Mcp4461Component::MCP4461_WRITE_PROTECTED: From cf189910150ed8ba2d4d6fd2757467b3d83102cc Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:43:45 +0100 Subject: [PATCH 4/5] Update mcp4461.h --- esphome/components/mcp4461/mcp4461.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index 1f6598e478..bbb2da26ad 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -93,11 +93,11 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { enum ErrorCode { MCP4461_STATUS_OK = 0, // CMD completed successfully + MCP4461_FAILED, // component failed MCP4461_STATUS_I2C_ERROR, // Unable to communicate with device MCP4461_STATUS_REGISTER_INVALID, // Status register value was invalid MCP4461_STATUS_REGISTER_ERROR, // Error fetching status register - MCP4461_PARENT_FAILED, // Parent component failed - MCP4461_VALUE_INVALID, // Invalid value given for wiper / eeprom + MCP4461_VALUE_INVALID, // Invalid value given for wiper / eeprom MCP4461_WRITE_PROTECTED, // The value was read, but the CRC over the payload (valid and data) does not match MCP4461_WIPER_ENABLED, // The wiper is enabled, discard additional enabling actions MCP4461_WIPER_DISABLED, // The wiper is disabled - all actions for this wiper will be aborted/discarded From 825cfa9529d1599482a862a46a315658ec1ab553 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Sun, 9 Feb 2025 14:45:11 +0100 Subject: [PATCH 5/5] Update mcp4461_output.cpp --- .../mcp4461/output/mcp4461_output.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index 438b150944..544d83fd4c 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -10,7 +10,7 @@ namespace mcp4461 { static const char *const TAG = "mcp4461.output"; static const LogString *get_wiper_message_string(int status) { switch (status) { - case Mcp4461Component::COMPONENT_FAILED: + case Mcp4461Component::MCP4461_FAILED: return LOG_STR("Parent MCP4461 component failed"); default: return LOG_STR("Unknown error"); @@ -19,7 +19,7 @@ static const LogString *get_wiper_message_string(int status) { void Mcp4461Wiper::write_state(float state) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -41,7 +41,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level void Mcp4461Wiper::save_level() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -57,7 +57,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -70,7 +70,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -83,7 +83,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -98,7 +98,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -113,7 +113,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -126,7 +126,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) { void Mcp4461Wiper::disable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED))); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::MCP4461_FAILED))); return; } uint8_t wiper_idx = static_cast(this->wiper_);