diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp index 4ded854a07..dcc4b566ce 100644 --- a/esphome/components/mcp4461/mcp4461.cpp +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -22,7 +22,7 @@ void Mcp4461Component::setup() { void Mcp4461Component::begin_() { // save WP/WL status - this->set_write_protection_status_(); + this->update_write_protection_status_(); for (uint8_t i = 0; i < 8; i++) { if (this->reg_[i].initial_value.has_value()) { uint16_t initial_state; @@ -76,7 +76,7 @@ void Mcp4461Component::set_initial_value(Mcp4461WiperIdx wiper, float initial_va this->reg_[wiper_id].initial_value = initial_value; } -void Mcp4461Component::set_write_protection_status_() { +void Mcp4461Component::update_write_protection_status_() { uint8_t status_register_value; status_register_value = this->get_status_register(); this->write_protected_ = static_cast((status_register_value >> 0) & 0x01); @@ -457,7 +457,7 @@ uint8_t Mcp4461Component::get_terminal_register(Mcp4461TerminalIdx terminal_conn void Mcp4461Component::update_terminal_register(Mcp4461TerminalIdx terminal_connector) { if (this->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_))); return; } if ((static_cast(terminal_connector) != 0 && static_cast(terminal_connector) != 1)) { diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h index 61b7713f71..1f6598e478 100644 --- a/esphome/components/mcp4461/mcp4461.h +++ b/esphome/components/mcp4461/mcp4461.h @@ -107,7 +107,7 @@ class Mcp4461Component : public Component, public i2c::I2CDevice { protected: friend class Mcp4461Wiper; - void set_write_protection_status_(); + void update_write_protection_status_(); uint8_t get_wiper_address_(uint8_t wiper); uint16_t read_wiper_level_(uint8_t wiper); bool is_writing_(); diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp index 932cf1a5ac..f3bea80b9b 100644 --- a/esphome/components/mcp4461/output/mcp4461_output.cpp +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -8,10 +8,11 @@ namespace esphome { namespace mcp4461 { static const char *const TAG = "mcp4461.output"; +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(Mcp4461Component::Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -33,7 +34,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(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -49,7 +50,7 @@ void Mcp4461Wiper::save_level() { void Mcp4461Wiper::enable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -62,7 +63,7 @@ void Mcp4461Wiper::enable_wiper() { void Mcp4461Wiper::disable_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -75,7 +76,7 @@ void Mcp4461Wiper::disable_wiper() { void Mcp4461Wiper::increase_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -90,7 +91,7 @@ void Mcp4461Wiper::increase_wiper() { void Mcp4461Wiper::decrease_wiper() { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -105,7 +106,7 @@ void Mcp4461Wiper::decrease_wiper() { void Mcp4461Wiper::enable_terminal(char terminal) { if (this->parent_->is_failed()) { - ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_); @@ -118,7 +119,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(Mcp4461Component::MCP4461_PARENT_FAILED)); + ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR)); return; } uint8_t wiper_idx = static_cast(this->wiper_);