Skip to content

Commit

Permalink
BLE status of balancing corrected? (some new params added as well)
Browse files Browse the repository at this point in the history
small bug corrected at rs-485-bms
  • Loading branch information
txubelaxu committed Mar 27, 2024
1 parent c0eb1a8 commit 5312c7a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
20 changes: 10 additions & 10 deletions components/jk_bms_ble/jk_bms_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ void JkBmsBle::update() {
ESP_LOGW(TAG, "[%s] Not connected", this->parent_->address_str().c_str());
return;
}

if (!this->status_notification_received_) {
ESP_LOGI(TAG, "Request status notification");
this->write_register(COMMAND_CELL_INFO, 0x00000000, 0x00);
}

if (this->cell_count_number_->state==0){

if (this->cell_request_float_voltage_time_number_->state==0){
const uint32_t now = millis();
if (now - this->last_device_info_ < 60000) { //testing
if (now - this->last_device_info_ < 2000) { //testing
return;
}
this->last_device_info_ = now;
ESP_LOGI(TAG, "Request device info");
this->write_register(COMMAND_DEVICE_INFO, 0x00000000, 0x00);
} else {
if (!this->status_notification_received_) {
ESP_LOGI(TAG, "Request status notification");
this->write_register(COMMAND_CELL_INFO, 0x00000000, 0x00);
}
}

}
Expand Down Expand Up @@ -861,8 +861,8 @@ void JkBmsBle::decode_jk04_cell_info_(const std::vector<uint8_t> &data) {

// 220 1 0x00 Blink cells (0x00: Off, 0x01: Charging balancer, 0x02: Discharging balancer)
bool balancing = (data[220] != 0x00);
this->publish_state_(this->status_balancing_binary_sensor_, balancing);
this->publish_state_(this->operation_status_text_sensor_, (balancing) ? "Balancing" : "Idle");
//this->publish_state_(this->status_balancing_binary_sensor_, balancing);
//this->publish_state_(this->operation_status_text_sensor_, (balancing) ? "Balancing" : "Idle");

// 221 1 0x01 Unknown221
ESP_LOGD(TAG, "Unknown221: 0x%02X", data[221]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ views:
{%- set balancing_direction =
states('sensor.rs485_bms0_balancing_direction')%} {%-
set is_working = "charging" if
(balancing_direction|int)>0
else "discharging" if (balancing_direction|int)<0
else 'idle' %}
(balancing_direction|int)==1
else "discharging" if (balancing_direction|int)==2
else "idle" if (balancing_direction|int)==0
else 'unknown' %}
{%- set font_start = '<b><font size=2 color="#41CD52">' if
(balancing_direction|int)>0
else '<b><font size=2 color=#3090C7>' if (balancing_direction|int)<0
Expand Down
6 changes: 3 additions & 3 deletions esp32-ble-battery_number_001.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ esp32:
type: esp-idf

external_components:
- source: ${external_components_source}
refresh: 0s
# - source: ./components
# - source: ${external_components_source}
# refresh: 0s
- source: ./components
refresh: 0s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
Expand Down
2 changes: 1 addition & 1 deletion esp32-example-jkpb-rs485_1master_1slave.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ esp32:

external_components:
- source: ${external_components_source}
refresh: 0s
refresh: 0s
# - source: ./components
# refresh: 0s
wifi:
Expand Down

0 comments on commit 5312c7a

Please sign in to comment.