diff --git a/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml b/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml index 1f8c6d1d..1f9861db 100644 --- a/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml +++ b/components/jk_rs485_bms/home_assistant_dashboards/batteries.yaml @@ -2095,66 +2095,132 @@ views: {% endif %} {% endfor %} - title: BMS0 (PROTECTION) - path: protection0 + path: protection_bms0 badges: [] cards: - type: entities entities: - entity: sensor.rs485_bms0_mos_overtemperature_protection + name: mos_overtemperature_protection - entity: sensor.rs485_bms0_mos_overtemperature_protection_recovery + name: mos_overtemperature_protection_recovery - entity: sensor.rs485_bms0_charging_overtemperature_protection + name: charging_overtemperature_protection - entity: sensor.rs485_bms0_discharging_overtemperature_protection + name: discharging_overtemperature_protection - entity: sensor.rs485_bms0_charging_overtemperature_protection_recovery + name: charging_overtemperature_protection_recovery - entity: sensor.rs485_bms0_discharging_overtemperature_protection_recovery + name: discharging_overtemperature_protection_recovery - entity: sensor.rs485_bms0_charging_lowtemperature_protection_recovery + name: charging_lowtemperature_protection_recovery - entity: sensor.rs485_bms0_charging_lowtemperature_protection + name: charging_lowtemperature_protection title: TEMPERATURE - type: entities entities: - entity: sensor.rs485_bms0_max_charging_current + name: max_charging_current - entity: sensor.rs485_bms0_charging_overcurrent_protection_delay + name: charging_overcurrent_protection_delay - entity: sensor.rs485_bms0_charging_overcurrent_protection_recovery_delay + name: charging_overcurrent_protection_recovery_delay + - entity: sensor.rs485_bms0_charging_overcurrent_protection_release_time + name: charging_overcurrent_protection_release_time + - entity: sensor.rs485_bms0_charging_short_circuit_protection_release_time + name: charging_short_circuit_protection_release_time + - entity: sensor.rs485_bms0_precharging_time_from_discharge + name: precharging_time_from_discharge + title: CHARGING + - type: entities + entities: - entity: sensor.rs485_bms0_max_discharging_current + name: max_discharging_current - entity: sensor.rs485_bms0_discharging_overcurrent_protection_delay + name: discharging_overcurrent_protection_delay - entity: >- sensor.rs485_bms0_discharging_overcurrent_protection_recovery_delay - - entity: sensor.rs485_bms0_short_circuit_protection_recovery_delay - - entity: sensor.rs485_bms0_max_balancing_current - - entity: sensor.rs485_bms0_charging_overcurrent_protection_release_time - - entity: sensor.rs485_bms0_charging_short_circuit_protection_release_time + name: discharging_overcurrent_protection_recovery_delay - entity: sensor.rs485_bms0_discharging_overcurrent_protection_release_time + name: discharging_overcurrent_protection_release_time - entity: >- sensor.rs485_bms0_discharging_short_circuit_protection_release_time - title: CURRENT + name: discharging_short_circuit_protection_release_time + title: DISCHARGING + - type: entities + entities: + - entity: sensor.rs485_bms0_short_circuit_protection_delay + name: short_circuit_protection_delay + - entity: sensor.rs485_bms0_short_circuit_protection_recovery_delay + name: short_circuit_protection_recovery_delay + title: SHORT CIRCUIT + - type: entities + entities: + - entity: sensor.rs485_bms0_max_balancing_current + name: max_balancing_current + title: BALANCING - title: BMS1 (PROTECTION) - path: protection1 + path: protection_bms1 badges: [] cards: - type: entities entities: - entity: sensor.rs485_bms1_mos_overtemperature_protection + name: mos_overtemperature_protection - entity: sensor.rs485_bms1_mos_overtemperature_protection_recovery + name: mos_overtemperature_protection_recovery - entity: sensor.rs485_bms1_charging_overtemperature_protection + name: charging_overtemperature_protection - entity: sensor.rs485_bms1_discharging_overtemperature_protection + name: discharging_overtemperature_protection - entity: sensor.rs485_bms1_charging_overtemperature_protection_recovery + name: charging_overtemperature_protection_recovery - entity: sensor.rs485_bms1_discharging_overtemperature_protection_recovery + name: discharging_overtemperature_protection_recovery - entity: sensor.rs485_bms1_charging_lowtemperature_protection_recovery + name: charging_lowtemperature_protection_recovery - entity: sensor.rs485_bms1_charging_lowtemperature_protection + name: charging_lowtemperature_protection title: TEMPERATURE - type: entities entities: - entity: sensor.rs485_bms1_max_charging_current + name: max_charging_current - entity: sensor.rs485_bms1_charging_overcurrent_protection_delay + name: charging_overcurrent_protection_delay - entity: sensor.rs485_bms1_charging_overcurrent_protection_recovery_delay + name: charging_overcurrent_protection_recovery_delay + - entity: sensor.rs485_bms1_charging_overcurrent_protection_release_time + name: charging_overcurrent_protection_release_time + - entity: sensor.rs485_bms1_charging_short_circuit_protection_release_time + name: charging_short_circuit_protection_release_time + - entity: sensor.rs485_bms1_precharging_time_from_discharge + name: precharging_time_from_discharge + title: CHARGING + - type: entities + entities: - entity: sensor.rs485_bms1_max_discharging_current + name: max_discharging_current - entity: sensor.rs485_bms1_discharging_overcurrent_protection_delay + name: discharging_overcurrent_protection_delay - entity: >- sensor.rs485_bms1_discharging_overcurrent_protection_recovery_delay - - entity: sensor.rs485_bms1_short_circuit_protection_recovery_delay - - entity: sensor.rs485_bms1_max_balancing_current - - entity: sensor.rs485_bms1_charging_overcurrent_protection_release_time - - entity: sensor.rs485_bms1_charging_short_circuit_protection_release_time + name: discharging_overcurrent_protection_recovery_delay - entity: sensor.rs485_bms1_discharging_overcurrent_protection_release_time + name: discharging_overcurrent_protection_release_time - entity: >- sensor.rs485_bms1_discharging_short_circuit_protection_release_time - title: CURRENT + name: discharging_short_circuit_protection_release_time + title: DISCHARGING + - type: entities + entities: + - entity: sensor.rs485_bms1_short_circuit_protection_delay + name: short_circuit_protection_delay + - entity: sensor.rs485_bms1_short_circuit_protection_recovery_delay + name: short_circuit_protection_recovery_delay + title: SHORT CIRCUIT + - type: entities + entities: + - entity: sensor.rs485_bms1_max_balancing_current + name: max_balancing_current + title: BALANCING diff --git a/components/jk_rs485_bms/jk_rs485_bms.cpp b/components/jk_rs485_bms/jk_rs485_bms.cpp index 59e0237e..99f5a45c 100644 --- a/components/jk_rs485_bms/jk_rs485_bms.cpp +++ b/components/jk_rs485_bms/jk_rs485_bms.cpp @@ -576,134 +576,142 @@ void JkRS485Bms::decode_jk02_settings_(const std::vector &data) { // 0 4 0x55 0xAA 0xEB 0x90 Header // 4 1 0x01 Frame type // 5 1 0x4F Frame counter - // 6 4 0x58 0x02 0x00 0x00 ** [JK-PB2A16S-20P v14] VOLTAGE SMART SLEEP + // 6 [0] 4 0x58 0x02 0x00 0x00 ** [JK-PB2A16S-20P v14] VOLTAGE SMART SLEEP ESP_LOGV(TAG, " Voltage Smart Sleep: %f", (float) jk_get_32bit(6) * 0.001f); this->publish_state_(this->cell_smart_sleep_voltage_sensor_, (float) jk_get_32bit(6) * 0.001f); - // 10 4 0x54 0x0B 0x00 0x00 Cell UVP + + // 10 [4] 4 0x54 0x0B 0x00 0x00 Cell UVP ESP_LOGV(TAG, " Cell UVP: %f V", (float) jk_get_32bit(10) * 0.001f); this->publish_state_(this->cell_undervoltage_protection_sensor_, (float) jk_get_32bit(10) * 0.001f); - // 14 4 0x80 0x0C 0x00 0x00 Cell UVP Recovery + // 14 [8] 4 0x80 0x0C 0x00 0x00 Cell UVP Recovery ESP_LOGV(TAG, " Cell UVPR: %f V", (float) jk_get_32bit(14) * 0.001f); this->publish_state_(this->cell_undervoltage_protection_recovery_sensor_, (float) jk_get_32bit(14) * 0.001f); - // 18 4 0xCC 0x10 0x00 0x00 Cell OVP + // 18 [12] 4 0xCC 0x10 0x00 0x00 Cell OVP ESP_LOGV(TAG, "%02X%02X%02X%02X Cell OVP: %f V", data[18], data[19], data[20], data[21], (float) jk_get_32bit(18)); this->publish_state_(this->cell_overvoltage_protection_sensor_, (float) jk_get_32bit(18) * 0.001f); - // 22 4 0x68 0x10 0x00 0x00 Cell OVP Recovery + // 22 [16] 4 0x68 0x10 0x00 0x00 Cell OVP Recovery ESP_LOGV(TAG, " Cell OVPR: %f V", (float) jk_get_32bit(22) * 0.001f); this->publish_state_(this->cell_overvoltage_protection_recovery_sensor_, (float) jk_get_32bit(22) * 0.001f); - // 26 4 0x0A 0x00 0x00 0x00 Balance trigger voltage + // 26 [20] 4 0x0A 0x00 0x00 0x00 Balance trigger voltage ESP_LOGV(TAG, " Balance trigger voltage: %f V", (float) jk_get_32bit(26) * 0.001f); this->publish_state_(this->balancing_trigger_voltage_sensor_, (float) jk_get_32bit(26) * 0.001f); - // 30 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] SOC-100% VOLTAGE + // 30 [24] 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] SOC-100% VOLTAGE ESP_LOGV(TAG, " SOC-100 VOLTAGE: %f V", (float) jk_get_32bit(30) * 0.001f); this->publish_state_(this->cell_soc100_voltage_sensor_, (float) jk_get_32bit(30) * 0.001f); - // 34 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] SOC-0% VOLTAGE + + // 34 [28] 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] SOC-0% VOLTAGE ESP_LOGV(TAG, " SOC-0 VOLTAGE: %f V", (float) jk_get_32bit(34) * 0.001f); this->publish_state_(this->cell_soc0_voltage_sensor_, (float) jk_get_32bit(34) * 0.001f); - // 38 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] VOLTAGE CELL REQUEST CHARGE VOLTAGE [RCV] + + // 38 [32] 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] VOLTAGE CELL REQUEST CHARGE VOLTAGE [RCV] ESP_LOGV(TAG, " CELL REQUEST CHARGE VOLTAGE [RCV]: %f V", (float) jk_get_32bit(38) * 0.001f); this->publish_state_(this->cell_request_charge_voltage_sensor_, (float) jk_get_32bit(38) * 0.001f); - // 42 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] VOLTAGE CELL REQUEST FLOAT VOLTAGE + + // 42 [36] 4 0x00 0x00 0x00 0x00 ** [JK-PB2A16S-20P v14] VOLTAGE CELL REQUEST FLOAT VOLTAGE ESP_LOGV(TAG, " CELL REQUEST FLOAT VOLTAGE [RFV]: %f V", (float) jk_get_32bit(42) * 0.001f); this->publish_state_(this->cell_request_float_voltage_sensor_, (float) jk_get_32bit(42) * 0.001f); - // 46 4 0xF0 0x0A 0x00 0x00 Power off voltage + + // 46 [40] 4 0xF0 0x0A 0x00 0x00 Power off voltage ESP_LOGV(TAG, " Sys Power off voltage: %f V", (float) jk_get_32bit(46) * 0.001f); this->publish_state_(this->cell_power_off_voltage_sensor_, (float) jk_get_32bit(46) * 0.001f); - // 50 4 0xA8 0x61 0x00 0x00 Max. charge current CurBatCOC + // 50 [44] 4 0xA8 0x61 0x00 0x00 Max. charge current CurBatCOC ESP_LOGV(TAG, " Max. charging current: %f A", (float) jk_get_32bit(50) * 0.001f); this->publish_state_(this->max_charging_current_sensor_, (float) jk_get_32bit(50) * 0.001f); - // 54 4 0x1E 0x00 0x00 0x00 Charge OCP delay TIMBatCOCPDly Charging Overcurrent + // 54 [48] 4 0x1E 0x00 0x00 0x00 Charge OCP delay TIMBatCOCPDly Charging Overcurrent // Protection Delay (s) ESP_LOGV(TAG, " Charge OCP delay: %f s", (float) jk_get_32bit(54)); this->publish_state_(this->charging_overcurrent_protection_delay_sensor_, (float) jk_get_32bit(54) * 0.001f); - // 58 4 0x3C 0x00 0x00 0x00 Charge OCP recovery time TIMBatCOCPRDly Charging Overcurrent + + // 58 [52] 4 0x3C 0x00 0x00 0x00 Charge OCP recovery time TIMBatCOCPRDly Charging Overcurrent // Protection Release Delay (s) ESP_LOGV(TAG, " Charge OCP recovery delay: %f s", (float) jk_get_32bit(58)); this->publish_state_(this->charging_overcurrent_protection_recovery_delay_sensor_, (float) jk_get_32bit(58) * 0.001f); - // 62 4 0xF0 0x49 0x02 0x00 Max. discharge current CurBatDcOC + + // 62 [56] 4 0xF0 0x49 0x02 0x00 Max. discharge current CurBatDcOC ESP_LOGV(TAG, " Max. discharging current: %f A", (float) jk_get_32bit(62) * 0.001f); this->publish_state_(this->max_discharging_current_sensor_, (float) jk_get_32bit(62) * 0.001f); - // 66 4 0x2C 0x01 0x00 0x00 Discharge OCP delay TIMBatDcOCPDly Discharge Overcurrent - // Protection Delay + // 66 [60] 4 0x2C 0x01 0x00 0x00 Discharge OCP delay TIMBatDcOCPDly Discharge Overcurrent Protection Delay ESP_LOGV(TAG, " Discharge OCP delay: %f s", (float) jk_get_32bit(66)); this->publish_state_(this->discharging_overcurrent_protection_delay_sensor_, (float) jk_get_32bit(66) * 0.001f); - // 70 4 0x3C 0x00 0x00 0x00 Discharge OCP recovery time TIMBatDcOCPRDly Discharge Overcurrent + + // 70 [64] 4 0x3C 0x00 0x00 0x00 Discharge OCP recovery time TIMBatDcOCPRDly Discharge Overcurrent // Protection Release Delay ESP_LOGV(TAG, " Discharge OCP recovery time: %f s", (float) jk_get_32bit(70)); - this->publish_state_(this->discharging_overcurrent_protection_recovery_delay_sensor_, - (float) jk_get_32bit(70) * 0.001f); - // 74 4 0x3C 0x00 0x00 0x00 SCPR delay TIMBatSCPRDly Short Circuit Protection - // Recovery Delay + this->publish_state_(this->discharging_overcurrent_protection_recovery_delay_sensor_, (float) jk_get_32bit(70) * 0.001f); + + // 74 [68] 4 0x3C 0x00 0x00 0x00 SCPR delay TIMBatSCPRDly Short Circuit Protection Recovery Delay ESP_LOGV(TAG, " SCP recovery time: %f s", (float) jk_get_32bit(74)); this->publish_state_(this->short_circuit_protection_recovery_delay_sensor_, (float) jk_get_32bit(74) * 0.001f); - // 78 4 0xD0 0x07 0x00 0x00 Max balance current + + // 78 [72] 4 0xD0 0x07 0x00 0x00 Max balance current ESP_LOGV(TAG, " Max. balance current: %f A", (float) jk_get_32bit(78) * 0.001f); this->publish_state_(this->max_balancing_current_sensor_, (float) jk_get_32bit(78) * 0.001f); - // 82 4 0xBC 0x02 0x00 0x00 Charge OTP TMPBatCOT Charging Over Temperature - // Protection + // 82 [76] 4 0xBC 0x02 0x00 0x00 Charge OTP TMPBatCOT Charging Over Temperature Protection ESP_LOGV(TAG, " Charging OTP: %f °C", (float) jk_get_32bit(82) * 0.1f); this->publish_state_(this->charging_overtemperature_protection_sensor_, (float) jk_get_32bit(82) * 0.1f); - // 86 4 0x58 0x02 0x00 0x00 Charge OTP Recovery TMPBatCOTPR Charging Over Temperature - // Protection Recovery + + // 86 [80] 4 0x58 0x02 0x00 0x00 Charge OTP Recovery TMPBatCOTPR Charging Over Temperature Protection Recovery ESP_LOGV(TAG, " Charge OTP recovery: %f °C", (float) jk_get_32bit(86) * 0.1f); this->publish_state_(this->charging_overtemperature_protection_recovery_sensor_, (float) jk_get_32bit(86) * 0.1f); - // 90 4 0xBC 0x02 0x00 0x00 Discharge OTP TMPBatDcOT + + // 90 [84] 4 0xBC 0x02 0x00 0x00 Discharge OTP TMPBatDcOT ESP_LOGV(TAG, " Discharge OTP: %f °C", (float) jk_get_32bit(90) * 0.1f); this->publish_state_(this->discharging_overtemperature_protection_sensor_, (float) jk_get_32bit(90) * 0.1f); - // 94 4 0x58 0x02 0x00 0x00 Discharge OTP Recovery TMPBatDcOTPR + + // 94 [88] 4 0x58 0x02 0x00 0x00 Discharge OTP Recovery TMPBatDcOTPR ESP_LOGV(TAG, " Discharge OTP recovery: %f °C", (float) jk_get_32bit(94) * 0.1f); this->publish_state_(this->discharging_overtemperature_protection_recovery_sensor_, (float) jk_get_32bit(94) * 0.1f); - // 98 4 0x38 0xFF 0xFF 0xFF Charge UTP TMPBatCUT Charging Low Temperature - // Protection + // 98 [92] 4 0x38 0xFF 0xFF 0xFF Charge UTP TMPBatCUT Charging Low Temperature Protection ESP_LOGV(TAG, " Charge UTP: %f °C", (float) ((int32_t) jk_get_32bit(98)) * 0.1f); this->publish_state_(this->charging_lowtemperature_protection_sensor_, (float) ((int32_t) jk_get_32bit(98)) * 0.1f); - // 102 4 0x9C 0xFF 0xFF 0xFF Charge UTP Recovery TMPBatCUTPR Charging Low Temperature - // Protection Recovery + + // 102 [96] 4 0x9C 0xFF 0xFF 0xFF Charge UTP Recovery TMPBatCUTPR Charging Low Temperature Protection Recovery ESP_LOGV(TAG, " Charge UTP recovery: %f °C", (float) ((int32_t) jk_get_32bit(102)) * 0.1f); - this->publish_state_(this->charging_lowtemperature_protection_recovery_sensor_, - (float) ((int32_t) jk_get_32bit(102)) * 0.1f); - // 106 4 0x84 0x03 0x00 0x00 MOS OTP TMPMosOT MOS Overtemperature - // Protection + this->publish_state_(this->charging_lowtemperature_protection_recovery_sensor_,(float) ((int32_t) jk_get_32bit(102)) * 0.1f); + + // 106 [100] 4 0x84 0x03 0x00 0x00 MOS OTP TMPMosOT MOS Overtemperature Protection ESP_LOGV(TAG, " MOS OTP: %f °C", (float) ((int32_t) jk_get_32bit(106)) * 0.1f); this->publish_state_(this->mos_overtemperature_protection_sensor_, (float) jk_get_32bit(106) * 0.1f); - // 110 4 0xBC 0x02 0x00 0x00 MOS OTP Recovery + + // 110 [104] 4 0xBC 0x02 0x00 0x00 MOS OTP Recovery ESP_LOGV(TAG, " MOS OTP recovery: %f °C", (float) ((int32_t) jk_get_32bit(110)) * 0.1f); this->publish_state_(this->mos_overtemperature_protection_recovery_sensor_, (float) jk_get_32bit(110) * 0.1f); - // 114 4 0x0D 0x00 0x00 0x00 cell count settings + // 114 [108] 4 0x0D 0x00 0x00 0x00 cell count settings ESP_LOGV(TAG, " cell count settings: %f", (float) jk_get_32bit(114)); this->publish_state_(this->cell_count_settings_sensor_, (float) data[114]); - // 118 4 0x01 0x00 0x00 0x00 Charge switch BatChargeEN + // 118 [112] 4 0x01 0x00 0x00 0x00 Charge switch BatChargeEN // ESP_LOGI(TAG, " Charge switch: %s", ((bool) data[118]) ? "on" : "off"); this->publish_state_(this->charging_switch_, (bool) data[118]); - // 122 4 0x01 0x00 0x00 0x00 Discharge switch + // 122 [116] 4 0x01 0x00 0x00 0x00 Discharge switch // ESP_LOGI(TAG, " Discharge switch: %s", ((bool) data[122]) ? "on" : "off"); this->publish_state_(this->discharging_switch_, (bool) data[122]); - // 126 4 0x01 0x00 0x00 0x00 Balancer switch + // 126 [120] 4 0x01 0x00 0x00 0x00 Balancer switch // ESP_LOGI(TAG, " Balancer switch: %s", ((bool) data[126]) ? "on" : "off"); this->publish_state_(this->balancer_switch_, (bool) (data[126])); - // 130 4 0x88 0x13 0x00 0x00 Nominal battery capacity CapBatCell + // 130 [124] 4 0x88 0x13 0x00 0x00 Nominal battery capacity CapBatCell [Nominal_Capacity] (CellInfo) // ESP_LOGI(TAG, " Nominal battery capacity: %f Ah", (float) jk_get_32bit(130) * 0.001f); - // this->publish_state_(this->total_battery_capacity_number_, (float) jk_get_32bit(130) * 0.001f); + // this->publish_state_(this->battery_capacity_total_setting_sensor_, (float) jk_get_32bit(130) * 0.001f); + + // 134 [128] 4 0xDC 0x05 0x00 0x00 SCP DELAY (us) + // ESP_LOGI(TAG, " SCP DELAY: %f us", (float) jk_get_32bit(134) * 0.001f); + this->publish_state_(this->short_circuit_protection_delay_sensor_, (float) jk_get_32bit(134) * 0.001f); - // 134 4 0xDC 0x05 0x00 0x00 SCP DELAY (us) - // ESP_LOGI(TAG, " SCP DELAY??: %f us", (float) jk_get_32bit(134) * 0.001f); - // this->publish_state_(this->scp_delay_number_, (float) jk_get_32bit(134) * 0.001f); - // 138 4 0xE4 0x0C 0x00 0x00 Start balance voltage + // 138 [132] 4 0xE4 0x0C 0x00 0x00 Start balance voltage // ESP_LOGI(TAG, " Start balance voltage: %f V", (float) jk_get_32bit(138) * 0.001f); this->publish_state_(this->cell_balancing_starting_voltage_sensor_, (float) jk_get_32bit(138) * 0.001f); @@ -751,15 +759,19 @@ void JkRS485Bms::decode_jk02_settings_(const std::vector &data) { // ESP_LOGI(TAG, " 262: %02X%02X%02X%02X",data[262],data[263],data[264],data[265]); // 266 4 0x00 0x00 0x00 0x00 // ESP_LOGI(TAG, " 266: %02X%02X%02X%02X",data[266],data[267],data[268],data[269]); - // 270 4 0x00 0x00 0x00 0x00 + // 270 [264] 4 0x00 0x00 0x00 0x00 (USED BY SNIFFER) // ESP_LOGI(TAG, " Device address: 0x%02X", data[270]); // ESP_LOGI(TAG, " 270: %02X%02X%02X%02X",data[270],data[271],data[272],data[273]); - // 274 4 0x00 0x00 0x00 0x00 TIMProdischarge + + // 274 [268] 4 0x00 0x00 0x00 0x00 TIMProdischarge: Discharge pre-charging time // ESP_LOGI(TAG, " 274: %02X%02X%02X%02X",data[274],data[275],data[276],data[277]); + ESP_LOGI(TAG, " Precharging time from discharged: %f s", (float) ((int32_t) jk_get_32bit(274))); + this->publish_state_(this->precharging_time_from_discharge_sensor_,(float) ((int32_t) jk_get_32bit(274))); + // 278 4 0x00 0x00 0x00 0x00 //60 e3 16 00 10023c3218feffffffbfe90102000000000001 - // ESP_LOGI(TAG, " 278: %02X%02X%02X%02X",data[278],data[279],data[280],data[281]); + ESP_LOGI(TAG, " 278: %02X%02X%02X%02X",data[278],data[279],data[280],data[281]); - // 282 [27?] 1 0x00 New controls bitmask + // 282 [276] 1 0x00 New controls bitmask // ** [JK-PB2A16S-20P v14] // bit0: HEATING_SWITCH_ENABLED 1 // bit1: DISABLE_TEMP_SENSOR_SWITCH_ENABLED 2 diff --git a/components/jk_rs485_bms/jk_rs485_bms.h b/components/jk_rs485_bms/jk_rs485_bms.h index 48769ab8..1eb6d7ca 100644 --- a/components/jk_rs485_bms/jk_rs485_bms.h +++ b/components/jk_rs485_bms/jk_rs485_bms.h @@ -239,6 +239,9 @@ class JkRS485Bms : public PollingComponent, public jk_rs485_sniffer::JkRS485Snif void set_discharging_overcurrent_protection_recovery_delay_sensor(sensor::Sensor *discharging_overcurrent_protection_recovery_delay_sensor) { discharging_overcurrent_protection_recovery_delay_sensor_ = discharging_overcurrent_protection_recovery_delay_sensor; } + void set_short_circuit_protection_delay_sensor(sensor::Sensor *short_circuit_protection_delay_sensor) { + short_circuit_protection_delay_sensor_ = short_circuit_protection_delay_sensor; + } void set_short_circuit_protection_recovery_delay_sensor(sensor::Sensor *short_circuit_protection_recovery_delay_sensor) { short_circuit_protection_recovery_delay_sensor_ = short_circuit_protection_recovery_delay_sensor; } @@ -267,6 +270,9 @@ class JkRS485Bms : public PollingComponent, public jk_rs485_sniffer::JkRS485Snif mos_overtemperature_protection_recovery_sensor_ = mos_overtemperature_protection_recovery_sensor; } + void set_precharging_time_from_discharge_sensor(sensor::Sensor *precharging_time_from_discharge_sensor) { + precharging_time_from_discharge_sensor_ = precharging_time_from_discharge_sensor; + } void set_discharging_overcurrent_protection_release_time_sensor(sensor::Sensor *discharging_overcurrent_protection_release_time_sensor) { @@ -713,6 +719,7 @@ class JkRS485Bms : public PollingComponent, public jk_rs485_sniffer::JkRS485Snif sensor::Sensor *charging_overcurrent_protection_recovery_delay_sensor_; sensor::Sensor *discharging_overcurrent_protection_delay_sensor_; sensor::Sensor *discharging_overcurrent_protection_recovery_delay_sensor_; + sensor::Sensor *short_circuit_protection_delay_sensor_; sensor::Sensor *short_circuit_protection_recovery_delay_sensor_; sensor::Sensor *charging_overtemperature_protection_sensor_; sensor::Sensor *charging_overtemperature_protection_recovery_sensor_; @@ -807,6 +814,7 @@ class JkRS485Bms : public PollingComponent, public jk_rs485_sniffer::JkRS485Snif sensor::Sensor *cell_request_charge_voltage_time_sensor_; sensor::Sensor *cell_request_float_voltage_time_sensor_; + sensor::Sensor *precharging_time_from_discharge_sensor_; switch_::Switch *precharging_switch_; diff --git a/components/jk_rs485_bms/sensor.py b/components/jk_rs485_bms/sensor.py index 326c48c0..37fb3c21 100644 --- a/components/jk_rs485_bms/sensor.py +++ b/components/jk_rs485_bms/sensor.py @@ -145,6 +145,8 @@ CONF_CHARGING_SHORT_CIRCUIT_PROTECTION_RELEASE_TIME = "charging_short_circuit_protection_release_time"; CONF_CELL_UNDERVOLTAGE_PROTECTION_RELEASE_TIME = "cell_undervoltage_protection_release_time"; CONF_CELL_OVERVOLTAGE_PROTECTION_RELEASE_TIME = "cell_overvoltage_protection_release_time"; +CONF_PRECHARGING_TIME_FROM_DISCHARGE = "precharging_time_from_discharge"; + CONF_CELL_PRESSURE_DIFFERENCE_PROTECTION = "cell_pressure_difference_protection" @@ -194,6 +196,7 @@ CONF_CHARGING_OVERCURRENT_PROTECION_RECOVERY_DELAY = "charging_overcurrent_protection_recovery_delay" CONF_DISCHARGING_OVERCURRENT_PROTECION_DELAY = "discharging_overcurrent_protection_delay" CONF_DISCHARGING_OVERCURRENT_PROTECION_RECOVERY_DELAY = "discharging_overcurrent_protection_recovery_delay" +CONF_SHORT_CIRCUIT_PROTECTION_DELAY ="short_circuit_protection_delay" CONF_SHORT_CIRCUIT_PROTECTION_RECOVERY_DELAY ="short_circuit_protection_recovery_delay" CONF_CHARGING_OVERTEMPERATURE_PROTECION = "charging_overtemperature_protection" CONF_CHARGING_OVERTEMPERATURE_PROTECION_RECOVERY = "charging_overtemperature_protection_recovery" @@ -236,6 +239,7 @@ ICON_HIGH_TEMPERATURE = "mdi:weather-sunny" ICON_LOW_TEMPERATURE = "mdi:snowflake" +UNIT_MICROSECONDS = "us" UNIT_SECONDS = "s" UNIT_HOURS = "h" UNIT_OHM = "Ω" @@ -352,6 +356,7 @@ CONF_CHARGING_OVERCURRENT_PROTECION_RECOVERY_DELAY, CONF_DISCHARGING_OVERCURRENT_PROTECION_DELAY, CONF_DISCHARGING_OVERCURRENT_PROTECION_RECOVERY_DELAY, + CONF_SHORT_CIRCUIT_PROTECTION_DELAY, CONF_SHORT_CIRCUIT_PROTECTION_RECOVERY_DELAY, CONF_CHARGING_OVERTEMPERATURE_PROTECION, CONF_CHARGING_OVERTEMPERATURE_PROTECION_RECOVERY, @@ -403,7 +408,7 @@ CONF_CHARGING_SHORT_CIRCUIT_PROTECTION_RELEASE_TIME, CONF_CELL_UNDERVOLTAGE_PROTECTION_RELEASE_TIME, CONF_CELL_OVERVOLTAGE_PROTECTION_RELEASE_TIME, - + CONF_PRECHARGING_TIME_FROM_DISCHARGE, ] # pylint: disable=too-many-function-args @@ -1128,6 +1133,13 @@ device_class=DEVICE_CLASS_EMPTY, state_class=STATE_CLASS_MEASUREMENT, ), + cv.Optional(CONF_SHORT_CIRCUIT_PROTECTION_DELAY): sensor.sensor_schema( + unit_of_measurement=UNIT_MICROSECONDS, + icon=ICON_TIMELAPSE, + accuracy_decimals=0, + device_class=DEVICE_CLASS_EMPTY, + state_class=STATE_CLASS_MEASUREMENT, + ), cv.Optional(CONF_SHORT_CIRCUIT_PROTECTION_RECOVERY_DELAY): sensor.sensor_schema( unit_of_measurement=UNIT_SECONDS, icon=ICON_TIMELAPSE, @@ -1474,7 +1486,14 @@ accuracy_decimals=0, device_class=DEVICE_CLASS_EMPTY, state_class=STATE_CLASS_MEASUREMENT, - ), + ), + cv.Optional(CONF_PRECHARGING_TIME_FROM_DISCHARGE): sensor.sensor_schema( + unit_of_measurement=UNIT_SECONDS, + icon=ICON_CLOCK, + accuracy_decimals=0, + device_class=DEVICE_CLASS_EMPTY, + state_class=STATE_CLASS_MEASUREMENT, + ), } ) diff --git a/components/jk_rs485_sniffer/jk_rs485_sniffer.cpp b/components/jk_rs485_sniffer/jk_rs485_sniffer.cpp index 8747409a..8b37f3b6 100644 --- a/components/jk_rs485_sniffer/jk_rs485_sniffer.cpp +++ b/components/jk_rs485_sniffer/jk_rs485_sniffer.cpp @@ -11,6 +11,7 @@ static const char *const TAG = "jk_rs485_sniffer"; static const uint16_t JKPB_RS485_RESPONSE_SIZE = 308; static const uint16_t JKPB_RS485_NUMBER_OF_ELEMENTS_TO_COMPUTE_CHECKSUM = 299; static const uint16_t JKPB_RS485_FRAME_TYPE_ADDRESS = 4; +static const uint16_t JKPB_RS485_FRAME_TYPE_ADDRESS_FOR_FRAME_TYPE_x01 = 264; static const uint16_t JKPB_RS485_FRAME_COUNTER_ADDRESS = 5; static const uint16_t JKPB_RS485_CHECKSUM_INDEX = 299; static const uint16_t JKPB_RS485_ADDRESS_OF_RS485_ADDRESS = 300; @@ -21,9 +22,9 @@ static const uint16_t MIN_SILENCE_NEEDED_BEFORE_SPEAKING_MILLISECONDS = 250; static const uint32_t TIME_BETWEEN_DEVICE_INFO_REQUESTS_MILLISECONDS = 300000; static const uint32_t TIME_BETWEEN_CELL_INFO_REQUESTS_MILLISECONDS = 10000; -static const uint32_t TIME_BETWEEN_DEVICE_SETTINGS_REQUESTS_MILLISECONDS=600000; +static const uint32_t TIME_BETWEEN_DEVICE_SETTINGS_REQUESTS_MILLISECONDS=3600000; -static const uint16_t SILENCE_BEFORE_ACTING_AS_MASTER = 2000; +static const uint16_t SILENCE_BEFORE_ACTING_AS_MASTER = 5000; static const uint16_t SILENCE_BEFORE_REUSING_NETWORK_ACTING_AS_MASTER=250; static const uint16_t TIME_BETWEEN_NETWORK_SCAN_MILLISECONDS=500; // mejorar @@ -578,7 +579,13 @@ uint8_t JkRS485Sniffer::manage_rx_buffer_(void) { uint8_t computed_checksum = chksum(raw, JKPB_RS485_NUMBER_OF_ELEMENTS_TO_COMPUTE_CHECKSUM); uint8_t remote_checksum = raw[JKPB_RS485_CHECKSUM_INDEX]; - address=raw[JKPB_RS485_ADDRESS_OF_RS485_ADDRESS]; + if (raw[JKPB_RS485_FRAME_TYPE_ADDRESS]==1){ + address=raw[JKPB_RS485_FRAME_TYPE_ADDRESS_FOR_FRAME_TYPE_x01+6]; + } else { + address=raw[JKPB_RS485_ADDRESS_OF_RS485_ADDRESS]; + } + //ESP_LOGI(TAG, "(at:%03d) [address 0x%02X] Frame Type 0x%02X ",at,address,raw[JKPB_RS485_FRAME_TYPE_ADDRESS]); + if (computed_checksum != remote_checksum) { ESP_LOGW(TAG, "CHECKSUM failed! 0x%02X != 0x%02X", computed_checksum, remote_checksum); return(10); @@ -587,7 +594,7 @@ uint8_t JkRS485Sniffer::manage_rx_buffer_(void) { if (address==0){ last_master_activity=now; } else if (address>15){ - ESP_LOGD(TAG, "(at:%03d) [address 0x%02X] Frame Type 0x%02X | CHECKSUM is correct",at,address,raw[JKPB_RS485_FRAME_TYPE_ADDRESS]); + ESP_LOGV(TAG, "(at:%03d) [address 0x%02X] Frame Type 0x%02X | CHECKSUM is correct",at,address,raw[JKPB_RS485_FRAME_TYPE_ADDRESS]); //printBuffer(0); this->rx_buffer_.clear(); return(11); diff --git a/esp32-example-jkpb-rs485_1master_1slave.yaml b/esp32-example-jkpb-rs485_1master_1slave.yaml index 18c7e096..3b8f9678 100644 --- a/esp32-example-jkpb-rs485_1master_1slave.yaml +++ b/esp32-example-jkpb-rs485_1master_1slave.yaml @@ -443,8 +443,12 @@ sensor: name: "${bms0_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms0_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms0_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms0_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms0_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms0_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -697,8 +701,12 @@ sensor: name: "${bms1_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms1_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms1_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms1_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms1_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms1_name} charging overtemperature protection" charging_overtemperature_protection_recovery: diff --git a/esp32-example-jkpb-rs485_1master_6slaves.yaml b/esp32-example-jkpb-rs485_1master_6slaves.yaml index 90380114..87f79d21 100644 --- a/esp32-example-jkpb-rs485_1master_6slaves.yaml +++ b/esp32-example-jkpb-rs485_1master_6slaves.yaml @@ -835,8 +835,12 @@ sensor: name: "${bms0_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms0_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms0_name} short circuit protection delay" short_circuit_protection_recovery_delay: - name: "${bms0_name} short circuit protection recovery delay" + name: "${bms0_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms0_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms0_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -1088,8 +1092,12 @@ sensor: name: "${bms1_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms1_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms1_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms1_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms1_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms1_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -1342,8 +1350,12 @@ sensor: name: "${bms2_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms2_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms2_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms2_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms2_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms2_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -1595,8 +1607,12 @@ sensor: name: "${bms3_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms3_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms3_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms3_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms3_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms3_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -1848,8 +1864,12 @@ sensor: name: "${bms4_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms4_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms4_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms4_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms4_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms4_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -2101,8 +2121,12 @@ sensor: name: "${bms5_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms5_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms5_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms5_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms5_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms5_name} charging overtemperature protection" charging_overtemperature_protection_recovery: @@ -2354,8 +2378,12 @@ sensor: name: "${bms6_name} discharging overcurrent protection delay" discharging_overcurrent_protection_recovery_delay: name: "${bms6_name} discharging overcurrent protection recovery delay" + short_circuit_protection_delay: + name: "${bms6_name} short circuit protection delay" short_circuit_protection_recovery_delay: name: "${bms6_name} short circuit protection recovery delay" + precharging_time_from_discharge: + name: "${bms6_name} precharging time from discharge" charging_overtemperature_protection: name: "${bms6_name} charging overtemperature protection" charging_overtemperature_protection_recovery: