From 5312c7a1c9c7cab0ac0ef11b52437e0bd5d0cb1d Mon Sep 17 00:00:00 2001 From: Txu Date: Wed, 27 Mar 2024 10:36:05 +0100 Subject: [PATCH] BLE status of balancing corrected? (some new params added as well) small bug corrected at rs-485-bms --- components/jk_bms_ble/jk_bms_ble.cpp | 20 +++++++++---------- .../home_assistant_dashboards/batteries.yaml | 7 ++++--- esp32-ble-battery_number_001.yaml | 6 +++--- esp32-example-jkpb-rs485_1master_1slave.yaml | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/components/jk_bms_ble/jk_bms_ble.cpp b/components/jk_bms_ble/jk_bms_ble.cpp index 5a47ae29..05c668e8 100644 --- a/components/jk_bms_ble/jk_bms_ble.cpp +++ b/components/jk_bms_ble/jk_bms_ble.cpp @@ -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); + } } } @@ -861,8 +861,8 @@ void JkBmsBle::decode_jk04_cell_info_(const std::vector &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]); diff --git a/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml b/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml index c0a15f29..b2858f08 100644 --- a/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml +++ b/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml @@ -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 = '' if (balancing_direction|int)>0 else '' if (balancing_direction|int)<0 diff --git a/esp32-ble-battery_number_001.yaml b/esp32-ble-battery_number_001.yaml index e88c2ab9..5fef1ee7 100644 --- a/esp32-ble-battery_number_001.yaml +++ b/esp32-ble-battery_number_001.yaml @@ -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 diff --git a/esp32-example-jkpb-rs485_1master_1slave.yaml b/esp32-example-jkpb-rs485_1master_1slave.yaml index ec91558a..e469e195 100644 --- a/esp32-example-jkpb-rs485_1master_1slave.yaml +++ b/esp32-example-jkpb-rs485_1master_1slave.yaml @@ -25,7 +25,7 @@ esp32: external_components: - source: ${external_components_source} - refresh: 0s + refresh: 0s # - source: ./components # refresh: 0s wifi: