diff --git a/README.md b/README.md index dc0173c7..94854d84 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All JK-BMS models with software version `>=6.0` are using the implemented protoc * JK-B1A24S15P, hw 8.x, sw 8.1.0H (reported by [@killee](https://github.com/syssi/esphome-jk-bms/discussions/4)) * JK-B1A20S15P, hw 8.x, sw 8.14U (reported by [@trippfam07](https://github.com/syssi/esphome-jk-bms/issues/31)) * JK-B1A20S15P, hw 10.xw, sw 10.07 (reported by [@romeox44](https://github.com/syssi/esphome-jk-bms/discussions/125)) -* JK-B1A20S15P, hw 10.xw, sw 10.10, using `JK02` (reported by [@austin202220](https://github.com/syssi/esphome-jk-bms/issues/297#issuecomment-1510685683)) +* JK-B1A20S15P, hw 10.xw, sw 10.10, using `JK02_24S` (reported by [@austin202220](https://github.com/syssi/esphome-jk-bms/issues/297#issuecomment-1510685683)) * JK-B1A20S15P, hw 11.xw, sw 11.26, using UART-TTL (reported by [@Tesla72PL](https://github.com/syssi/esphome-jk-bms/issues/309)) * JK-B2A24S15P, hw 6.x, sw 6.1.3S (reported by [@miguel300477](https://github.com/syssi/esphome-jk-bms/issues/57)) * JK-B2A24S15P, hw 8.x, sw 8.21W (reported by [@mariusvaida](https://github.com/syssi/esphome-jk-bms/issues/120)) @@ -40,7 +40,7 @@ All JK-BMS models with software version `>=6.0` are using the implemented protoc * JK-B2A24S20P, hw 10.X-W, sw 10.02 (reported by [@SeByDocKy](https://github.com/syssi/esphome-jk-bms/issues/37#issuecomment-1040569576)) * JK-B2A24S20P, hw 10.XG, sw 10.07D30 (reported by [@TheSmartGerman](https://github.com/syssi/esphome-jk-bms/discussions/122)) * JK-B2A24S20P, hw 10.XW, sw 10.07 (reported by [@amagr0](https://github.com/syssi/esphome-jk-bms/issues/124#issuecomment-1166366196)) -* JK-B2A8S20P, hw 9.x, sw 9.01M3, using `JK02` (reported by [@EasilyBoredEngineer](https://github.com/syssi/esphome-jk-bms/discussions/110)) +* JK-B2A8S20P, hw 9.x, sw 9.01M3, using `JK02_24S` (reported by [@EasilyBoredEngineer](https://github.com/syssi/esphome-jk-bms/discussions/110)) * JK-B2A8S20P, hw 9.x, sw 9.08W (reported by [@vrabi-cv](https://github.com/syssi/esphome-jk-bms/discussions/144#discussioncomment-3285901)) * JK-B2A8S20P, hw 11.XW, sw 11.17, using `JK02_32S` (reported by [@senfkorn](https://github.com/syssi/esphome-jk-bms/issues/147)) * JK-B2A8S20P, hw 11.XW, sw 11.26, using `JK02_32S` (reported by [@riker65](https://github.com/syssi/esphome-jk-bms/issues/276)) diff --git a/components/jk_bms_ble/__init__.py b/components/jk_bms_ble/__init__.py index 3ad896b4..437ee4df 100644 --- a/components/jk_bms_ble/__init__.py +++ b/components/jk_bms_ble/__init__.py @@ -19,7 +19,7 @@ ProtocolVersion = jk_bms_ble_ns.enum("ProtocolVersion") PROTOCOL_VERSION_OPTIONS = { "JK04": ProtocolVersion.PROTOCOL_VERSION_JK04, - "JK02": ProtocolVersion.PROTOCOL_VERSION_JK02, + "JK02_24S": ProtocolVersion.PROTOCOL_VERSION_JK02_24S, "JK02_32S": ProtocolVersion.PROTOCOL_VERSION_JK02_32S, } @@ -33,7 +33,7 @@ cv.Schema( { cv.GenerateID(): cv.declare_id(JkBmsBle), - cv.Optional(CONF_PROTOCOL_VERSION, default="JK02"): cv.enum( + cv.Required(CONF_PROTOCOL_VERSION): cv.enum( PROTOCOL_VERSION_OPTIONS, upper=True ), cv.Optional( diff --git a/components/jk_bms_ble/button/jk_button.cpp b/components/jk_bms_ble/button/jk_button.cpp index 9a902ea7..cf1a3db0 100644 --- a/components/jk_bms_ble/button/jk_button.cpp +++ b/components/jk_bms_ble/button/jk_button.cpp @@ -9,7 +9,7 @@ static const char *const TAG = "jk_bms_ble.button"; void JkButton::dump_config() { LOG_BUTTON("", "JkBmsBle Button", this); } void JkButton::press_action() { - // JK04, JK02, JK02_32S + // JK04, JK02_24S, JK02_32S this->parent_->write_register(this->holding_register_, 0x00000000, 0x00); } diff --git a/components/jk_bms_ble/jk_bms_ble.cpp b/components/jk_bms_ble/jk_bms_ble.cpp index c5dc491e..3cd31633 100644 --- a/components/jk_bms_ble/jk_bms_ble.cpp +++ b/components/jk_bms_ble/jk_bms_ble.cpp @@ -11,7 +11,7 @@ static const char *const TAG = "jk_bms_ble"; static const uint8_t MAX_NO_RESPONSE_COUNT = 10; static const uint8_t FRAME_VERSION_JK04 = 0x01; -static const uint8_t FRAME_VERSION_JK02 = 0x02; +static const uint8_t FRAME_VERSION_JK02_24S = 0x02; static const uint8_t FRAME_VERSION_JK02_32S = 0x03; static const uint16_t JK_BMS_SERVICE_UUID = 0xFFE0; @@ -315,20 +315,8 @@ void JkBmsBle::decode_jk02_cell_info_(const std::vector &data) { } this->last_cell_info_ = now; + uint8_t frame_version = FRAME_VERSION_JK02_24S; uint8_t offset = 0; - uint8_t frame_version = FRAME_VERSION_JK02; - if (this->protocol_version_ == PROTOCOL_VERSION_JK02) { - // Weak assumption: The value of data[189] (JK02) or data[189+32] (JK02_32S) is 0x01, 0x02 or 0x03 - if (data[189] == 0x00 && data[189 + 32] > 0) { - frame_version = FRAME_VERSION_JK02_32S; - offset = 16; - ESP_LOGW(TAG, - "You hit the unstable auto detection of the protocol version. This feature will be removed in future!" - "Please update your configuration to protocol version JK02_32S if you are using a JK-B2A8S20P v11+"); - } - } - - // Override unstable auto detection if (this->protocol_version_ == PROTOCOL_VERSION_JK02_32S) { frame_version = FRAME_VERSION_JK02_32S; offset = 16; @@ -776,7 +764,7 @@ void JkBmsBle::decode_jk02_settings_(const std::vector &data) { ESP_LOGVV(TAG, " %s", format_hex_pretty(&data.front(), 160).c_str()); ESP_LOGVV(TAG, " %s", format_hex_pretty(&data.front() + 160, data.size() - 160).c_str()); - // JK02 response example: + // JK02_24S response example: // // 0x55 0xAA 0xEB 0x90 0x01 0x4F 0x58 0x02 0x00 0x00 0x54 0x0B 0x00 0x00 0x80 0x0C 0x00 0x00 0xCC 0x10 0x00 0x00 0x68 // 0x10 0x00 0x00 0x0A 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 @@ -1076,7 +1064,7 @@ void JkBmsBle::decode_device_info_(const std::vector &data) { // User data: // Setup passcode: - // JK02 response example: + // JK02_24S response example: // // 0x55 0xAA 0xEB 0x90 0x03 0x9F 0x4A 0x4B 0x2D 0x42 0x32 0x41 0x32 0x34 0x53 0x31 0x35 0x50 0x00 0x00 0x00 0x00 0x31 // 0x30 0x2E 0x58 0x57 0x00 0x00 0x00 0x31 0x30 0x2E 0x30 0x37 0x00 0x00 0x00 0x40 0xAF 0x01 0x00 0x06 0x00 0x00 0x00 diff --git a/components/jk_bms_ble/jk_bms_ble.h b/components/jk_bms_ble/jk_bms_ble.h index 2d9f2ae0..3409bc0d 100644 --- a/components/jk_bms_ble/jk_bms_ble.h +++ b/components/jk_bms_ble/jk_bms_ble.h @@ -21,7 +21,7 @@ namespace espbt = esphome::esp32_ble_tracker; enum ProtocolVersion { PROTOCOL_VERSION_JK04, - PROTOCOL_VERSION_JK02, + PROTOCOL_VERSION_JK02_24S, PROTOCOL_VERSION_JK02_32S, }; @@ -197,7 +197,7 @@ class JkBmsBle : public esphome::ble_client::BLEClientNode, public PollingCompon } temperatures_[4]; protected: - ProtocolVersion protocol_version_{PROTOCOL_VERSION_JK02}; + ProtocolVersion protocol_version_{PROTOCOL_VERSION_JK02_24S}; binary_sensor::BinarySensor *balancing_binary_sensor_; binary_sensor::BinarySensor *charging_binary_sensor_; diff --git a/components/jk_bms_ble/number/__init__.py b/components/jk_bms_ble/number/__init__.py index 36c16be5..bad107ba 100644 --- a/components/jk_bms_ble/number/__init__.py +++ b/components/jk_bms_ble/number/__init__.py @@ -25,7 +25,7 @@ DEFAULT_STEP = 1 -# JK02 +# JK02_24S # # 06 04 03000000 Set balance trig voltage to 0.003 # 1c 04 10000000 Set cell count to 16 diff --git a/components/jk_bms_ble/number/jk_number.cpp b/components/jk_bms_ble/number/jk_number.cpp index 307f582f..78635cfc 100644 --- a/components/jk_bms_ble/number/jk_number.cpp +++ b/components/jk_bms_ble/number/jk_number.cpp @@ -16,7 +16,7 @@ void JkNumber::control(float value) { return; } - if (this->parent_->get_protocol_version() == PROTOCOL_VERSION_JK02 && this->jk02_holding_register_) { + 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); diff --git a/components/jk_bms_ble/switch/jk_switch.cpp b/components/jk_bms_ble/switch/jk_switch.cpp index d5ca5f12..8a504dbc 100644 --- a/components/jk_bms_ble/switch/jk_switch.cpp +++ b/components/jk_bms_ble/switch/jk_switch.cpp @@ -16,7 +16,7 @@ void JkSwitch::write_state(bool state) { return; } - if (this->parent_->get_protocol_version() == PROTOCOL_VERSION_JK02 && this->jk02_holding_register_) { + if (this->parent_->get_protocol_version() == PROTOCOL_VERSION_JK02_24S && this->jk02_holding_register_) { if (this->parent_->write_register(this->jk02_holding_register_, (state) ? 0x00000001 : 0x00000000, 0x04)) { this->publish_state(state); } diff --git a/esp32-ble-example-multiple-devices.yaml b/esp32-ble-example-multiple-devices.yaml index be7d1af5..5b5fb344 100644 --- a/esp32-ble-example-multiple-devices.yaml +++ b/esp32-ble-example-multiple-devices.yaml @@ -6,18 +6,18 @@ substitutions: external_components_source: github://syssi/esphome-jk-bms@main bms0_mac_address: C8:47:8C:E1:E2:E1 bms1_mac_address: C8:47:8C:E1:E2:E2 - # Defaults to "JK02" (hardware version >= 6.0 and < 11.0) + # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0) # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26) # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) - bms0_protocol_version: JK02 - bms1_protocol_version: JK02 + bms0_protocol_version: JK02_32S + bms1_protocol_version: JK02_32S esphome: name: ${name} comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-ble-example.yaml b/esp32-ble-example.yaml index 4aebb01b..b87aedf2 100644 --- a/esp32-ble-example.yaml +++ b/esp32-ble-example.yaml @@ -3,17 +3,17 @@ substitutions: device_description: "Monitor and control a JK-BMS via bluetooth" external_components_source: github://syssi/esphome-jk-bms@main mac_address: C8:47:8C:E1:E2:E1 - # Defaults to "JK02" (hardware version >= 6.0 and < 11.0) + # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0) # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26) # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) - protocol_version: JK02 + protocol_version: JK02_32S esphome: name: ${name} comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-ble-jk04-example.yaml b/esp32-ble-jk04-example.yaml index 3ccf944a..471e182b 100644 --- a/esp32-ble-jk04-example.yaml +++ b/esp32-ble-jk04-example.yaml @@ -3,7 +3,7 @@ substitutions: device_description: "Monitor and control a JK-BMS via bluetooth" external_components_source: github://syssi/esphome-jk-bms@main mac_address: C8:47:FF:FF:FF:FF - # Defaults to "JK02" (hardware version >= 6.0 and < 11.0) + # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0) # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26) # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) protocol_version: JK04 @@ -13,7 +13,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-ble-scanner.yaml b/esp32-ble-scanner.yaml index a8175091..56e0bfc7 100644 --- a/esp32-ble-scanner.yaml +++ b/esp32-ble-scanner.yaml @@ -7,7 +7,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-ble-uart-hybrid-example.yaml b/esp32-ble-uart-hybrid-example.yaml index 98684b33..7c63f631 100644 --- a/esp32-ble-uart-hybrid-example.yaml +++ b/esp32-ble-uart-hybrid-example.yaml @@ -5,10 +5,10 @@ substitutions: # BLE settings mac_address: C8:47:8C:E1:E2:E1 - # Defaults to "JK02" (hardware version >= 6.0 and < 11.0) + # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0) # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26) # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) - protocol_version: JK02 + protocol_version: JK02_32S # UART settings tx_pin: GPIO16 @@ -19,7 +19,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-ble-v11-example.yaml b/esp32-ble-v11-example.yaml index c93a1f66..29ab1c9b 100644 --- a/esp32-ble-v11-example.yaml +++ b/esp32-ble-v11-example.yaml @@ -3,7 +3,7 @@ substitutions: device_description: "Monitor and control a JK-BMS v11 via bluetooth" external_components_source: github://syssi/esphome-jk-bms@main mac_address: C8:47:8C:E1:E2:E1 - # Defaults to "JK02" (hardware version >= 6.0 and < 11.0) + # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0) # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26) # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) protocol_version: JK02_32S @@ -13,7 +13,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-example-multiple-devices.yaml b/esp32-example-multiple-devices.yaml index 6ecc0c6d..22ffd9a5 100644 --- a/esp32-example-multiple-devices.yaml +++ b/esp32-example-multiple-devices.yaml @@ -14,7 +14,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-example.yaml b/esp32-example.yaml index 91bb71fd..4929529b 100644 --- a/esp32-example.yaml +++ b/esp32-example.yaml @@ -10,7 +10,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp32-heltec-balancer-ble-example.yaml b/esp32-heltec-balancer-ble-example.yaml index 9d1dbd77..b8a3432b 100644 --- a/esp32-heltec-balancer-ble-example.yaml +++ b/esp32-heltec-balancer-ble-example.yaml @@ -9,7 +9,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/esp8266-example.yaml b/esp8266-example.yaml index c0c9fcf2..883947f1 100644 --- a/esp8266-example.yaml +++ b/esp8266-example.yaml @@ -10,7 +10,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp8266: board: d1_mini diff --git a/yaml-snippets/esp32-ble-block-traffic.yaml b/yaml-snippets/esp32-ble-block-traffic.yaml index 25806f6d..46e61f03 100644 --- a/yaml-snippets/esp32-ble-block-traffic.yaml +++ b/yaml-snippets/esp32-ble-block-traffic.yaml @@ -8,7 +8,7 @@ esphome: comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32 diff --git a/yaml-snippets/esp32-ble-energy-dashboard.yaml b/yaml-snippets/esp32-ble-energy-dashboard.yaml index c8d89664..865960f2 100644 --- a/yaml-snippets/esp32-ble-energy-dashboard.yaml +++ b/yaml-snippets/esp32-ble-energy-dashboard.yaml @@ -3,15 +3,17 @@ substitutions: device_description: "Monitor and control a JK-BMS via bluetooth" external_components_source: github://syssi/esphome-jk-bms@main mac_address: C8:47:8C:E1:E2:E1 - # Defaults to "JK02". Please use "JK04" if you have some old JK-BMS version (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) - protocol_version: JK02 + # Please use "JK02_24S" if you own a old JK-BMS < hardware version 11.0 (hardware version >= 6.0 and < 11.0) + # Please use "JK02_32S" if you own a new JK-BMS >= hardware version 11.0 (f.e. JK-B2A8S20P hw 11.XW, sw 11.26) + # Please use "JK04" if you have some old JK-BMS <= hardware version 3.0 (f.e. JK-B2A16S hw 3.0, sw. 3.3.0) + protocol_version: JK02_32S esphome: name: ${name} comment: ${device_description} project: name: "syssi.esphome-jk-bms" - version: 1.5.0 + version: 2.0.0 esp32: board: wemos_d1_mini32