Files
esphome-yambms/packages/bms/bms_base.yaml
T

124 lines
4.2 KiB
YAML

# Updated : 2025.06.15
# Version : 1.2.4
# GitHub : https://github.com/Sleeper85/esphome-yambms
# 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>.
number:
# +--------------------------------------+
# | Charging Cycles Offset |
# +--------------------------------------+
- platform: template
name: "${name} ${bms_name} Charging Cycles Offset"
id: bms${bms_id}_charging_cycles_offset
step: 1
min_value: 0
max_value: 3000
initial_value: 0
restore_value: true
icon: mdi:counter
optimistic: true
entity_category: config
sensor:
# +--------------------------------------+
# | Total Daily Energy |
# +--------------------------------------+
- platform: total_daily_energy
name: "${name} ${bms_name} Daily Charging Energy"
power_id: bms${bms_id}_charging_power
unit_of_measurement: 'kWh'
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
- platform: total_daily_energy
name: "${name} ${bms_name} Daily Discharging Energy"
power_id: bms${bms_id}_discharging_power
unit_of_measurement: 'kWh'
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
# +--------------------------------------+
# | Battery State of Charge (SOC) |
# +--------------------------------------+
- platform: template
name: ${name} ${bms_name} Battery SoC
id: bms${bms_id}_battery_soc
update_interval: ${bms_update_interval}
unit_of_measurement: "%"
device_class: battery
accuracy_decimals: 0
filters:
- or:
- throttle: 10s
- delta: 1
lambda: |-
float soc = id(bms${bms_id}_state_of_charge).state;
float min_cell_v = id(bms${bms_id}_min_cell_voltage).state;
float cell_low_v = id(bms${bms_id}_cell_uvp).state + 0.2;
if (min_cell_v <= cell_low_v) return 0; // Real 0% => return 0%
else if (soc < 1) return 2; // False 0% => return 2%
else return soc; // Else => return BMS SoC
# +--------------------------------------+
# | Charging Cycles |
# +--------------------------------------+
- platform: template
name: "${name} ${bms_name} charging cycles"
id: bms${bms_id}_charging_cycles
update_interval: ${bms_update_interval}
state_class: total
icon: mdi:counter
accuracy_decimals: 0
filters:
- or:
- throttle: 10s
- delta: 1
lambda: |-
float cycles_raw = id(bms${bms_id}_charging_cycles_raw).state;
if (isnan(cycles_raw)) cycles_raw = 0;
return cycles_raw + id(bms${bms_id}_charging_cycles_offset).state;
# +--------------------------------------+
# | Charging Cycle Capacity |
# +--------------------------------------+
- platform: template
name: "${name} ${bms_name} total charging cycle capacity"
id: bms${bms_id}_cycle_capacity
update_interval: ${bms_update_interval}
unit_of_measurement: Ah
state_class: total
icon: mdi:car-battery
accuracy_decimals: 0
filters:
- or:
- throttle: 10s
- delta: 1
lambda: |-
float capacity_raw = id(bms${bms_id}_cycle_capacity_raw).state;
if (isnan(capacity_raw)) capacity_raw = 0;
return capacity_raw +
id(bms${bms_id}_charging_cycles_offset).state *
id(bms${bms_id}_battery_capacity).state;