134 lines
4.1 KiB
YAML
134 lines
4.1 KiB
YAML
# Updated : 2026.07.31
|
|
# Version : 1.2.0
|
|
# 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>.
|
|
|
|
substitutions:
|
|
balancer_model: "YamBMS"
|
|
balancer_protocol: "Modbus"
|
|
|
|
packages:
|
|
balancer_base: !include balancer_base.yaml
|
|
|
|
# +--------------------------------------+
|
|
# | Component settings |
|
|
# +--------------------------------------+
|
|
|
|
modbus_controller:
|
|
- id: modbus_controller_balancer${bms_id}
|
|
modbus_id: modbus_client_${modbus_id}
|
|
setup_priority: -10
|
|
address: 10${bms_id}
|
|
update_interval: ${modbus_update_interval}
|
|
max_cmd_retries: 1
|
|
offline_skip_updates: 5 # Server re-polled every 30s with an update_interval of 5s (fixed with PR #11781)
|
|
on_online:
|
|
then:
|
|
- logger.log: "Balancer ${bms_id} modbus server back online !"
|
|
on_offline:
|
|
then:
|
|
- logger.log: "Balancer ${bms_id} modbus server goes offline !"
|
|
- lambda: |-
|
|
id(balancer${bms_id}_online_status).publish_state(false);
|
|
id(balancer${bms_id}_equalizing).publish_state(false);
|
|
- lambda: |-
|
|
// Pass the current state to the update function
|
|
id(global_update_fault)(${CAT_BALANCER}, ${bms_id}, 1);
|
|
|
|
# +--------------------------------------+
|
|
# | Component entities |
|
|
# +--------------------------------------+
|
|
|
|
binary_sensor:
|
|
# online_status
|
|
- platform: modbus_controller
|
|
modbus_controller_id: modbus_controller_balancer${bms_id}
|
|
id: balancer${bms_id}_online_status
|
|
device_id: balancer_${bms_id}
|
|
name: "Online status"
|
|
register_type: read
|
|
address: 1
|
|
trigger_on_initial_state: true
|
|
on_state:
|
|
then:
|
|
- lambda: |-
|
|
id(bms${bms_id}_var_ext_balancer_online) = x;
|
|
- lambda: |-
|
|
// Pass the current state to the update function
|
|
id(global_update_fault)(${CAT_BALANCER}, ${bms_id}, !x);
|
|
# equalizing
|
|
- platform: modbus_controller
|
|
modbus_controller_id: modbus_controller_balancer${bms_id}
|
|
id: balancer${bms_id}_equalizing
|
|
device_id: balancer_${bms_id}
|
|
name: "balancing"
|
|
register_type: read
|
|
address: 2
|
|
trigger_on_initial_state: true
|
|
on_state:
|
|
then:
|
|
- lambda: |-
|
|
id(bms${bms_id}_var_ext_balancer_equalizing) = x;
|
|
|
|
sensor:
|
|
# balance_trigger_voltage
|
|
- platform: modbus_controller
|
|
modbus_controller_id: modbus_controller_balancer${bms_id}
|
|
id: balancer${bms_id}_balance_trigger_voltage
|
|
device_id: balancer_${bms_id}
|
|
name: "Balance Trigger Voltage"
|
|
register_type: read
|
|
address: 3
|
|
value_type: U_WORD
|
|
accuracy_decimals: 3
|
|
unit_of_measurement: V
|
|
device_class: voltage
|
|
filters:
|
|
- multiply: 0.001
|
|
- clamp:
|
|
min_value: 0
|
|
max_value: 5
|
|
ignore_out_of_range: true
|
|
- or:
|
|
- throttle: 10s
|
|
- delta: 0.001
|
|
on_value:
|
|
then:
|
|
- lambda: |-
|
|
id(bms${bms_id}_var_ext_balancer_trigger_voltage) = x;
|
|
# balance_starting_voltage
|
|
- platform: modbus_controller
|
|
modbus_controller_id: modbus_controller_balancer${bms_id}
|
|
id: balancer${bms_id}_balance_starting_voltage
|
|
device_id: balancer_${bms_id}
|
|
name: "Balance Starting Voltage"
|
|
register_type: read
|
|
address: 4
|
|
value_type: U_WORD
|
|
accuracy_decimals: 3
|
|
unit_of_measurement: V
|
|
device_class: voltage
|
|
filters:
|
|
- multiply: 0.001
|
|
- clamp:
|
|
min_value: 0
|
|
max_value: 5
|
|
ignore_out_of_range: true
|
|
- or:
|
|
- throttle: 10s
|
|
- delta: 0.001
|