Add support for Auto SoC Limit (#255)
This commit is contained in:
1 parent
fc741b942d
commit
78aff46702
10 files changed
+355
-10
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.02.12
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.7.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -326,6 +326,19 @@ views:
|
||||
- entity: number.yambms_demo_yambms_1_auto_eoc_increase_stop_soc
|
||||
name: Stop SoC
|
||||
title: YamBMS - Auto EOC
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: switch.yambms_demo_yambms_1_automatic_soc_limit
|
||||
name: Automatic SoC Limit
|
||||
- entity: number.yambms_demo_yambms_1_auto_soc_limit
|
||||
name: SoC Limit
|
||||
- entity: number.yambms_demo_yambms_1_auto_soc_limit_hysteresis
|
||||
name: SoC Limit Hysteresis
|
||||
- entity: select.yambms_demo_yambms_1_auto_soc_limit_mode
|
||||
name: Auto SoC Limit Mode
|
||||
- entity: sensor.yambms_demo_yambms_1_auto_soc_limit_status
|
||||
name: Auto SoC Limit Status
|
||||
title: YamBMS - Auto SoC Limit
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: number.yambms_demo_yambms_1_rebulk_soc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.02.11
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.7.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -288,6 +288,19 @@ views:
|
||||
- entity: number.yambms_yambms_1_auto_eoc_increase_stop_soc
|
||||
name: Stop SoC
|
||||
title: YamBMS - Auto EOC
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: switch.yambms_yambms_1_automatic_soc_limit
|
||||
name: Automatic SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit
|
||||
name: SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit_hysteresis
|
||||
name: SoC Limit Hysteresis
|
||||
- entity: select.yambms_yambms_1_auto_soc_limit_mode
|
||||
name: Auto SoC Limit Mode
|
||||
- entity: sensor.yambms_yambms_1_auto_soc_limit_status
|
||||
name: Auto SoC Limit Status
|
||||
title: YamBMS - Auto SoC Limit
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: number.yambms_yambms_1_rebulk_soc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.02.11
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.7.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -288,6 +288,19 @@ views:
|
||||
- entity: number.yambms_yambms_1_auto_eoc_increase_stop_soc
|
||||
name: Stop SoC
|
||||
title: YamBMS - Auto EOC
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: switch.yambms_yambms_1_automatic_soc_limit
|
||||
name: Automatic SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit
|
||||
name: SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit_hysteresis
|
||||
name: SoC Limit Hysteresis
|
||||
- entity: select.yambms_yambms_1_auto_soc_limit_mode
|
||||
name: Auto SoC Limit Mode
|
||||
- entity: sensor.yambms_yambms_1_auto_soc_limit_status
|
||||
name: Auto SoC Limit Status
|
||||
title: YamBMS - Auto SoC Limit
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: number.yambms_yambms_1_rebulk_soc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.02.11
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.7.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -288,6 +288,19 @@ views:
|
||||
- entity: number.yambms_yambms_1_auto_eoc_increase_stop_soc
|
||||
name: Stop SoC
|
||||
title: YamBMS - Auto EOC
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: switch.yambms_yambms_1_automatic_soc_limit
|
||||
name: Automatic SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit
|
||||
name: SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit_hysteresis
|
||||
name: SoC Limit Hysteresis
|
||||
- entity: select.yambms_yambms_1_auto_soc_limit_mode
|
||||
name: Auto SoC Limit Mode
|
||||
- entity: sensor.yambms_yambms_1_auto_soc_limit_status
|
||||
name: Auto SoC Limit Status
|
||||
title: YamBMS - Auto SoC Limit
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: number.yambms_yambms_1_rebulk_soc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.02.11
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.7.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -288,6 +288,19 @@ views:
|
||||
- entity: number.yambms_yambms_1_auto_eoc_increase_stop_soc
|
||||
name: Stop SoC
|
||||
title: YamBMS - Auto EOC
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: switch.yambms_yambms_1_automatic_soc_limit
|
||||
name: Automatic SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit
|
||||
name: SoC Limit
|
||||
- entity: number.yambms_yambms_1_auto_soc_limit_hysteresis
|
||||
name: SoC Limit Hysteresis
|
||||
- entity: select.yambms_yambms_1_auto_soc_limit_mode
|
||||
name: Auto SoC Limit Mode
|
||||
- entity: sensor.yambms_yambms_1_auto_soc_limit_status
|
||||
name: Auto SoC Limit Status
|
||||
title: YamBMS - Auto SoC Limit
|
||||
- type: entities
|
||||
entities:
|
||||
- entity: number.yambms_yambms_1_rebulk_soc
|
||||
|
||||
@@ -195,6 +195,45 @@ At about 18:08 the battery is 100% after a short balancing period.
|
||||

|
||||
|
||||
|
||||
## Auto SoC Limit
|
||||
|
||||

|
||||
|
||||
When to use: You want to charge your battery up to a specific SoC value.
|
||||
|
||||
This function allows to set a target SoC when charging. Upon reaching this limit, it can either switch to `Float`, limit the `Requested Charge Current (CCL)` or both.
|
||||
|
||||
There are some configuration options to adjust the behaviour:
|
||||
|
||||
- `Automatic SoC Limit`: This switch enables or disables the function.
|
||||
- `Auto SoC Limit`: The SoC limit value.
|
||||
- `Auto SoC Limit Mode`: The mode to use when the limit is reached.
|
||||
- `Auto SoC Hysteresis`: Configurable hysteresis value when to stop limiting `Requested Charge Current (CCL)`.
|
||||
- `Auto SoC Limit CCL`: The value that will be used for `Requested Charge Current (CCL)` when the limit is reached and `Auto SoC Limit` is set to `CCL` or `Float + CCL`.
|
||||
|
||||
The text sensor `Auto SoC Limit Status` will show the current status of the function:
|
||||
- `Stop: Disabled`: Function is disabled.
|
||||
- `Stop: SoC limit reached`: The configured SoC limit was reached.
|
||||
- `Run`: Function enabled, SoC limit not reached.
|
||||
|
||||
Modes:
|
||||
- `Float`: Will set the charging mode from `Bulk` to `Float`. If already at `Float`, nothing will happen.
|
||||
- `CCL`: Limits the `Requested Charge Current (CCL)` to the value set by `Auto SoC Limit CCL`. The limit will be removed once the `SoC` is below `Auto SoC Limit` - `Auto SoC Hysteresis`.
|
||||
- `Float + CCL`: Will use both previously described methods. However while the `Requested Charge Current (CCL)` will be removed, the charging mode will not be reset to `Bulk`. For this, `Rebulk SoC` is available.
|
||||
|
||||
Note: Some inverters may not like `0A` for `Requested Charge Current (CCL)`. `Auto SoC Limit CCL` allows to set a small value to effectively limit the charging process.
|
||||
|
||||
Example:
|
||||
- `Auto SoC Limit` is set to `80%`
|
||||
- `Auto SoC Limit Mode` is set to `CCL`
|
||||
- `Auto SoC Hysteresis` is set to `5%`
|
||||
|
||||
The current `SoC` is `70%`. When it reaches `80%` during charging, `Requested Charge Current (CCL)` is set to `Auto SoC Limit CCL`.
|
||||
Afterwards the battery is then discharged, however `Requested Charge Current (CCL)` will stay at `Auto SoC Limit CCL` until `SoC` reaches
|
||||
`Auto SoC Limit` - `Auto SoC Hysteresis` = `80%` - `5%` = `75%`. Without this, the `SoC` would oscillate between
|
||||
`79%` and `80%`, stressing components unnecessary.
|
||||
|
||||
|
||||
## Inverter Heartbeat Monitoring
|
||||
|
||||

|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -1,5 +1,5 @@
|
||||
# Updated : 2026.01.30
|
||||
# Version : 1.1.3
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.1.4
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
# YamBMS ( Yet another multi-BMS Merging Solution )
|
||||
@@ -27,5 +27,6 @@ packages:
|
||||
yambms_auto_float: !include yambms_auto_float.yaml
|
||||
yambms_auto_eoc: !include yambms_auto_eoc.yaml
|
||||
yambms_auto_temp-based_current: !include yambms_auto_temp_ccl_dcl.yaml
|
||||
yambms_auto_soc: !include yambms_auto_soc_limit.yaml
|
||||
# Update service
|
||||
yambms_service: !include yambms_service.yaml
|
||||
@@ -0,0 +1,233 @@
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.1.1
|
||||
# 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>.
|
||||
|
||||
esphome:
|
||||
on_boot:
|
||||
- priority: -100.0
|
||||
then:
|
||||
- lambda: |-
|
||||
id(${yambms_id}_var_auto_ccl_functions_count)++;
|
||||
|
||||
globals:
|
||||
# Last SoC value
|
||||
- id: ${yambms_id}_var_auto_soc_last_value
|
||||
type: int
|
||||
restore_value: no
|
||||
initial_value: '0'
|
||||
- id: ${yambms_id}_var_auto_soc_target_reached
|
||||
type: bool
|
||||
restore_value: no
|
||||
initial_value: 'false'
|
||||
|
||||
switch:
|
||||
- platform: template
|
||||
name: ${name} ${yambms_name} Automatic SoC Limit
|
||||
id: ${yambms_id}_switch_auto_soc_limit
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
optimistic: true
|
||||
entity_category: config
|
||||
|
||||
number:
|
||||
- platform: template
|
||||
name: "${name} ${yambms_name} Auto SoC Limit"
|
||||
id: "${yambms_id}_auto_soc_limit"
|
||||
step: 5
|
||||
min_value: 40
|
||||
max_value: 95
|
||||
restore_value: true
|
||||
mode: "${yambms_input_number_mode}"
|
||||
initial_value: 80
|
||||
unit_of_measurement: '%'
|
||||
icon: mdi:battery-charging-80
|
||||
optimistic: true
|
||||
entity_category: config
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
// Reset last SoC value and target reached flag
|
||||
id(${yambms_id}_var_auto_soc_last_value) = 0;
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = false;
|
||||
- platform: template
|
||||
name: "${name} ${yambms_name} Auto SoC Limit Hysteresis"
|
||||
id: "${yambms_id}_auto_soc_hysteresis"
|
||||
step: 5
|
||||
min_value: 5
|
||||
max_value: 40
|
||||
restore_value: true
|
||||
mode: "${yambms_input_number_mode}"
|
||||
initial_value: 5
|
||||
unit_of_measurement: '%'
|
||||
icon: mdi:battery-minus
|
||||
optimistic: true
|
||||
entity_category: config
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
// Reset last SoC value and target reached flag
|
||||
id(${yambms_id}_var_auto_soc_last_value) = 0;
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = false;
|
||||
- platform: template
|
||||
name: "${name} ${yambms_name} Auto SoC Limit CCL"
|
||||
id: "${yambms_id}_auto_soc_ccl"
|
||||
step: 1
|
||||
min_value: 0
|
||||
max_value: 10
|
||||
restore_value: true
|
||||
mode: "${yambms_input_number_mode}"
|
||||
initial_value: 1
|
||||
unit_of_measurement: 'A'
|
||||
icon: mdi:current-dc
|
||||
optimistic: true
|
||||
entity_category: config
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
// Reset last SoC value and target reached flag
|
||||
id(${yambms_id}_var_auto_soc_last_value) = 0;
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = false;
|
||||
|
||||
select:
|
||||
- platform: template
|
||||
name: "${name} ${yambms_name} Auto SoC Limit Mode"
|
||||
id: ${yambms_id}_auto_soc_limit_mode
|
||||
options:
|
||||
- "Float"
|
||||
- "CCL"
|
||||
- "Float + CCL"
|
||||
restore_value: true
|
||||
initial_option: "Float"
|
||||
optimistic: true
|
||||
entity_category: config
|
||||
set_action:
|
||||
then:
|
||||
- lambda: |-
|
||||
// Reset last SoC value and target reached flag
|
||||
id(${yambms_id}_var_auto_soc_last_value) = 0;
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = false;
|
||||
|
||||
text_sensor:
|
||||
# +--------------------------------------+
|
||||
# | Auto SoC Status |
|
||||
# +--------------------------------------+
|
||||
- platform: template
|
||||
name: "${name} ${yambms_name} Auto SoC Limit Status"
|
||||
id: ${yambms_id}_auto_soc_limit_status
|
||||
update_interval: never
|
||||
icon: mdi:information-outline
|
||||
entity_category: diagnostic
|
||||
|
||||
interval:
|
||||
- interval: ${yambms_update_interval}
|
||||
then:
|
||||
# +------------------------------------------+
|
||||
# | Auto SoC Charge Current Limit |
|
||||
# +------------------------------------------+
|
||||
- lambda: |-
|
||||
// Check if we are in the correct step
|
||||
int cc_step = id(${yambms_id}_var_charge_current_step);
|
||||
if ((cc_step < 1) || (cc_step >= (id(${yambms_id}_var_auto_ccl_functions_count) + 1))) {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGD("yambms_debug", "Entering Auto SoC Limit...");
|
||||
|
||||
// Check if enabled
|
||||
if (!id(${yambms_id}_switch_auto_soc_limit).state ||
|
||||
!id(${yambms_id}_battery_soc).has_state() ||
|
||||
!id(${yambms_id}_max_charge_current).has_state()) {
|
||||
// Auto SoC Charging disabled
|
||||
id(${yambms_id}_var_auto_soc_limit) = 0;
|
||||
id(${yambms_id}_auto_soc_limit_status).publish_state("Stop: Disabled");
|
||||
id(${yambms_id}_var_auto_soc_last_value) = 0;
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = false;
|
||||
id(${yambms_id}_var_charge_current_step)++;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update in 60s intervals only
|
||||
static uint32_t last_execution_ms = 0;
|
||||
uint32_t current_ms = millis();
|
||||
|
||||
if ((current_ms - last_execution_ms) < 60000) {
|
||||
id(${yambms_id}_var_charge_current_step)++;
|
||||
return;
|
||||
}
|
||||
|
||||
last_execution_ms = current_ms;
|
||||
|
||||
// Check if SoC has changed since last execution, if not, skip calculations
|
||||
int soc = id(${yambms_id}_battery_soc).state;
|
||||
|
||||
if (soc == id(${yambms_id}_var_auto_soc_last_value)) {
|
||||
id(${yambms_id}_var_charge_current_step)++;
|
||||
return;
|
||||
}
|
||||
|
||||
id(${yambms_id}_var_auto_soc_last_value) = soc;
|
||||
|
||||
// Check if target SoC was already reached
|
||||
int target_soc = id(${yambms_id}_auto_soc_limit).state;
|
||||
|
||||
if (id(${yambms_id}_var_auto_soc_target_reached)) {
|
||||
// If target was reached but SoC has dropped below target - hysteresis, allow increasing charge current again
|
||||
float soc_hysteresis = target_soc - id(${yambms_id}_auto_soc_hysteresis).state;
|
||||
if (soc <= soc_hysteresis) {
|
||||
ESP_LOGD("yambms_debug", "Auto SoC Limit: Activating again, SoC dropped below target - hysteresis");
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = false;
|
||||
id(${yambms_id}_var_auto_soc_limit) = 0;
|
||||
id(${yambms_id}_auto_soc_limit_status).publish_state("Run");
|
||||
}
|
||||
|
||||
id(${yambms_id}_var_charge_current_step)++;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if target SoC is reached or exceeded
|
||||
if (soc >= target_soc) {
|
||||
id(${yambms_id}_var_auto_soc_target_reached) = true;
|
||||
id(${yambms_id}_auto_soc_limit_status).publish_state("Stop: SoC limit reached");
|
||||
ESP_LOGD("yambms_debug", "Auto SoC Limit: Target SoC reached");
|
||||
|
||||
// Get mode
|
||||
const auto mode = id(${yambms_id}_auto_soc_limit_mode).active_index();
|
||||
|
||||
if (mode == 0) {
|
||||
// Float mode
|
||||
ESP_LOGD("yambms_debug", "Auto SoC Limit: Applying Float mode");
|
||||
id(${yambms_id}_var_charge_status) = "Float";
|
||||
id(${yambms_id}_var_auto_soc_limit) = 0;
|
||||
} else if (mode == 1) {
|
||||
// CCL mode
|
||||
ESP_LOGD("yambms_debug", "Auto SoC Limit: Applying CCL mode");
|
||||
id(${yambms_id}_var_auto_soc_limit) = -(id(${yambms_id}_max_charge_current).state - id(${yambms_id}_auto_soc_ccl).state);
|
||||
} else if (mode == 2) {
|
||||
// Float + CCL mode
|
||||
ESP_LOGD("yambms_debug", "Auto SoC Limit: Applying Float + CCL mode");
|
||||
id(${yambms_id}_var_charge_status) = "Float";
|
||||
id(${yambms_id}_var_auto_soc_limit) = -(id(${yambms_id}_max_charge_current).state - id(${yambms_id}_auto_soc_ccl).state);
|
||||
} else {
|
||||
// Default case (should not happen)
|
||||
ESP_LOGD("yambms_debug", "Auto SoC Limit: Unknown mode");
|
||||
}
|
||||
} else {
|
||||
id(${yambms_id}_auto_soc_limit_status).publish_state("Run");
|
||||
id(${yambms_id}_var_auto_soc_limit) = 0;
|
||||
}
|
||||
|
||||
id(${yambms_id}_var_charge_current_step)++;
|
||||
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.03.10
|
||||
# Updated : 2026.03.11
|
||||
# Version : 1.7.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -290,6 +290,10 @@ globals:
|
||||
type: float
|
||||
restore_value: no
|
||||
initial_value: '0.0'
|
||||
- id: ${yambms_id}_var_auto_soc_limit
|
||||
type: float
|
||||
restore_value: no
|
||||
initial_value: '0.0'
|
||||
- id: ${yambms_id}_var_eoc
|
||||
type: bool
|
||||
restore_value: no
|
||||
@@ -915,7 +919,8 @@ interval:
|
||||
id(${yambms_id}_var_auto_ccl),
|
||||
id(${yambms_id}_var_auto_eoc),
|
||||
id(${yambms_id}_var_auto_temperature_ccl),
|
||||
id(${yambms_id}_var_auto_ccl_soft_landing)
|
||||
id(${yambms_id}_var_auto_ccl_soft_landing),
|
||||
id(${yambms_id}_var_auto_soc_limit),
|
||||
});
|
||||
|
||||
requested_charge_current = round(id(${yambms_id}_max_charge_current).state + auto_limit);
|
||||
@@ -1961,14 +1966,16 @@ text_sensor:
|
||||
float limit_2 = id(${yambms_id}_var_auto_eoc);
|
||||
float limit_3 = id(${yambms_id}_var_auto_ccl);
|
||||
float limit_4 = id(${yambms_id}_var_auto_ccl_soft_landing);
|
||||
float limit_5 = id(${yambms_id}_var_auto_soc_limit);
|
||||
|
||||
float min_val = std::min({limit_1, limit_2, limit_3, limit_4});
|
||||
float min_val = std::min({limit_1, limit_2, limit_3, limit_4, limit_5});
|
||||
|
||||
if (min_val == 0.0f) return {"No Derating"};
|
||||
if (min_val == limit_1) return {"Temperature Derating"};
|
||||
if (min_val == limit_2) return {"EOC Derating"};
|
||||
if (min_val == limit_3) return {"AutoCCL Derating"};
|
||||
if (min_val == limit_4) return {"Soft Landing Derating"};
|
||||
if (min_val == limit_5) return {"SoC Limit Derating"};
|
||||
return {"Unknown"};
|
||||
|
||||
# +----------------------------------------+
|
||||
|
||||
Reference in new issue
Block a user