Skip to content

Commit

Permalink
Publish the new value if a number entity gets changed (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
RFDarter authored Mar 21, 2024
1 parent ce4fd3f commit b40d3ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/heltec_balancer_ble/number/heltec_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions components/jk_bms_ble/number/jk_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ 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;
}

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;
}

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;
}
Expand Down

0 comments on commit b40d3ee

Please sign in to comment.