From fd8908ce9b562025538c3519f2c0e873bfc537b0 Mon Sep 17 00:00:00 2001 From: Darter Date: Wed, 14 Feb 2024 02:07:32 +0100 Subject: [PATCH 1/2] fix Number components state getting published with the wrong value #450 --- components/jk_bms_ble/number/jk_number.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/jk_bms_ble/number/jk_number.cpp b/components/jk_bms_ble/number/jk_number.cpp index 78635cfc..e5cb126d 100644 --- a/components/jk_bms_ble/number/jk_number.cpp +++ b/components/jk_bms_ble/number/jk_number.cpp @@ -11,7 +11,7 @@ void JkNumber::control(float value) { if (this->parent_->get_protocol_version() == PROTOCOL_VERSION_JK04 && this->jk04_holding_register_) { uint32_t payload = (uint32_t) (value * this->factor_); if (this->parent_->write_register(this->jk04_holding_register_, payload, sizeof(payload))) { - this->publish_state(state); + this->publish_state(value); } return; } @@ -19,7 +19,7 @@ void JkNumber::control(float value) { if (this->parent_->get_protocol_version() == PROTOCOL_VERSION_JK02_24S && this->jk02_holding_register_) { uint32_t payload = (uint32_t) (value * this->factor_); if (this->parent_->write_register(this->jk02_holding_register_, payload, sizeof(payload))) { - this->publish_state(state); + this->publish_state(value); } return; } @@ -27,7 +27,7 @@ void JkNumber::control(float value) { if (this->parent_->get_protocol_version() == PROTOCOL_VERSION_JK02_32S && this->jk02_32s_holding_register_) { uint32_t payload = (uint32_t) (value * this->factor_); if (this->parent_->write_register(this->jk02_32s_holding_register_, payload, sizeof(payload))) { - this->publish_state(state); + this->publish_state(value); } return; } From 7a49c55030fea6f5eea02278ce66a1babb3a53f0 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 21 Mar 2024 08:12:59 +0100 Subject: [PATCH 2/2] Fix heltec balancer component too --- components/heltec_balancer_ble/number/heltec_number.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/heltec_balancer_ble/number/heltec_number.cpp b/components/heltec_balancer_ble/number/heltec_number.cpp index 79b7f7ea..35d86ef1 100644 --- a/components/heltec_balancer_ble/number/heltec_number.cpp +++ b/components/heltec_balancer_ble/number/heltec_number.cpp @@ -14,7 +14,7 @@ void HeltecNumber::control(float value) { uint32_t payload = (this->holding_register_ == 0x01 || this->holding_register_ == 0x16) ? (uint32_t) value : ieee_float_(value); if (this->parent_->send_command(FUNCTION_WRITE, COMMAND_WRITE_REGISTER, this->holding_register_, payload)) { - this->publish_state(state); + this->publish_state(value); } }