From 4753d7b2791fa7d71ff4a53f9b4e41141cab6a58 Mon Sep 17 00:00:00 2001 From: dentra Date: Mon, 24 Jun 2024 15:21:30 +0300 Subject: [PATCH] ewh: publish error code only on change --- components/ewh/ewh_component.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/ewh/ewh_component.cpp b/components/ewh/ewh_component.cpp index d0d711a..e2b5646 100644 --- a/components/ewh/ewh_component.cpp +++ b/components/ewh/ewh_component.cpp @@ -24,7 +24,9 @@ void EWHComponent::on_state(const ewh_state_t &state) { #endif #ifdef USE_SENSOR if (this->error_code_) { - this->error_code_->publish_state(state.error); + if (std::isnan(this->error_code_->state) || static_cast(this->error_code_->state) != state.error) { + this->error_code_->publish_state(state.error); + } } #endif }