Files
esphome-yambms/packages/bms/bms_errors_bitmask_JK_BLE.yaml
T
2025-12-17 00:42:53 +01:00

99 lines
5.7 KiB
YAML

# Updated : 2025.12.09
# Version : 1.1.4
# GitHub : https://github.com/syssi/esphome-jk-bms
# YamBMS ( Yet another multi-BMS Merging Solution )
# This YAML is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
# +--------------------------------------+
# | JK BLE Errors Bitmask (16bit) |
# +--------------------------------------+
# Bit 0 Charge overtemperature 0000 0000 0000 0001 0x0001
# Bit 1 Charge undertemperature 0000 0000 0000 0010 0x0002
# Bit 2 Coprocessor communication error 0000 0000 0000 0100 0x0004
# Bit 3 Cell undervoltage 0000 0000 0000 1000 0x0008
# Bit 4 Battery pack undervoltage 0000 0000 0001 0000 0x0010
# Bit 5 Discharge overcurrent 0000 0000 0010 0000 0x0020
# Bit 6 Discharge short circuit 0000 0000 0100 0000 0x0040
# Bit 7 Discharge overtemperature 0000 0000 1000 0000 0x0080
# Bit 8 Wire resistance 0000 0001 0000 0000 0x0100
# Bit 9 Mosfet overtemperature 0000 0010 0000 0000 0x0200
# Bit 10 Cell count is not equal to settings 0000 0100 0000 0000 0x0400
# Bit 11 Current sensor anomaly 0000 1000 0000 0000 0x0800
# Bit 12 Cell Overvoltage 0001 0000 0000 0000 0x1000
# Bit 13 Battery pack overvoltage 0010 0000 0000 0000 0x2000
# Bit 14 Charge overcurrent protection 0100 0000 0000 0000 0x4000
# Bit 15 Charge short circuit 1000 0000 0000 0000 0x8000
# +--------------------------------------+
# | YamBMS Errors Bitmask (16bit) |
# +--------------------------------------+
# Bit 0 General alarm 0000 0000 0000 0001 0x0001
# Bit 1 Battery high voltage alarm 0000 0000 0000 0010 0x0002
# Bit 2 Battery low voltage alarm 0000 0000 0000 0100 0x0004
# Bit 3 Battery high temperature alarm 0000 0000 0000 1000 0x0008
# Bit 4 Battery low temperature alarm 0000 0000 0001 0000 0x0010
# Bit 5 Battery high temperature charge alarm 0000 0000 0010 0000 0x0020
# Bit 6 Battery low temperature charge alarm 0000 0000 0100 0000 0x0040
# Bit 7 Battery high discharge current alarm 0000 0000 1000 0000 0x0080
# Bit 8 Battery high charge current alarm 0000 0001 0000 0000 0x0100
# Bit 9 Contactor alarm 0000 0010 0000 0000 0x0200
# Bit 10 Short circuit alarm 0000 0100 0000 0000 0x0400
# Bit 11 BMS internal alarm 0000 1000 0000 0000 0x0800
# Bit 12 Cell imbalance alarm 0001 0000 0000 0000 0x1000
# Bit 13 Reserved 0010 0000 0000 0000 0x2000
# Bit 14 Reserved 0100 0000 0000 0000 0x4000
# Bit 15 Reserved 1000 0000 0000 0000 0x8000
sensor:
- platform: template
id: bms${bms_id}_yambms_errors_bitmask
device_id: bms_${bms_id}
name: "${name} ${bms_name} YamBMS Errors Bitmask"
update_interval: ${bms_update_interval}
accuracy_decimals: 0
icon: mdi:alert-circle-outline
filters:
- or:
- throttle: 10s
- delta: 1
lambda: |-
uint16_t bms_errors_bitmask = id(bms${bms_id}_errors_bitmask).state;
uint16_t yambms_errors_bitmask = 0;
if (bms_errors_bitmask > 0)
{
if (bms_errors_bitmask & 0x0001) yambms_errors_bitmask |= 0x0020;
if (bms_errors_bitmask & 0x0002) yambms_errors_bitmask |= 0x0040;
if (bms_errors_bitmask & 0x0004) yambms_errors_bitmask |= 0x0800;
if (bms_errors_bitmask & 0x0008) yambms_errors_bitmask |= 0x0004;
if (bms_errors_bitmask & 0x0010) yambms_errors_bitmask |= 0x0004;
if (bms_errors_bitmask & 0x0020) yambms_errors_bitmask |= 0x0080;
if (bms_errors_bitmask & 0x0040) yambms_errors_bitmask |= 0x0400;
if (bms_errors_bitmask & 0x0080) yambms_errors_bitmask |= 0x0008;
if (bms_errors_bitmask & 0x0100) yambms_errors_bitmask |= 0x0800;
if (bms_errors_bitmask & 0x0200) yambms_errors_bitmask |= 0x0008;
if (bms_errors_bitmask & 0x0400) yambms_errors_bitmask |= 0x0800;
if (bms_errors_bitmask & 0x0800) yambms_errors_bitmask |= 0x0800;
if (bms_errors_bitmask & 0x1000) yambms_errors_bitmask |= 0x0002;
if (bms_errors_bitmask & 0x2000) yambms_errors_bitmask |= 0x0002;
if (bms_errors_bitmask & 0x4000) yambms_errors_bitmask |= 0x0100;
if (bms_errors_bitmask & 0x8000) yambms_errors_bitmask |= 0x0400;
}
return yambms_errors_bitmask;