Installed Battery Capacity now follows a capacity change at runtime
The installed total was accumulated once per BMS per boot, latched by bms<id>_combined_once, so a BMS reconfigured with a different capacity kept contributing its boot value until the next reboot. Each BMS now remembers the last capacity it contributed in bms<id>_installed_capacity and applies only the difference to the total. - the update runs in the can_be_combined branch, so an offline BMS simply stops updating its contribution, which stays in the total : the installed capacity still never shrinks on an uncombine, as before - a BMS coming back with a different capacity is applied as a delta, with no double counting - combined_once had no other reader and is removed The total is deliberately not turned into a per-round accumulator reset in the Global vars reset block like the other totals : its sensor is polled independently of STEP 2 and its state is written straight into CAN frame 0x379 with no has_state() guard, so a transient zero would announce 0 Ah of installed capacity to the inverter. See Design_decisions.md.
This commit is contained in:
1 parent
bf044c159d
commit
cb3b0eedba
2 files changed
+26
-12
No files matched your search
@@ -46,17 +46,25 @@ Note that the checks are not uniform. Most use `has_state()`, but `total_voltage
|
||||
`battery_capacity`, `max_charge_current` and `max_discharge_current` use `> 0` — a BMS reporting
|
||||
zero for those is treated as not ready rather than as a valid reading.
|
||||
|
||||
### Combined once, combined continuously, uncombined
|
||||
### Combined by contribution, combined continuously, uncombined
|
||||
|
||||
Three distinct scopes in the same lambda, and they are not interchangeable:
|
||||
|
||||
- **Once** — `total_installed_battery_capacity` accumulates a single time per BMS, for the
|
||||
lifetime of the boot. It represents the *installed* capacity and deliberately does not shrink
|
||||
when a BMS drops offline.
|
||||
- **By contribution** — `total_installed_battery_capacity` is a maintained total, not a per-round
|
||||
accumulator. Each BMS remembers the last capacity it contributed in
|
||||
`bms${bms_id}_installed_capacity` and applies only the *difference* to the total. So the
|
||||
installed capacity follows a capacity change made at runtime, without a reboot, while an
|
||||
offline BMS simply stops updating its contribution — which stays in the total. It represents
|
||||
the *installed* capacity and deliberately does not shrink when a BMS drops offline.
|
||||
- **Not continuously** — the combined counter is incremented on the transition into the combined
|
||||
state, not on every tick.
|
||||
- **Continuously** — the totals, bitmasks and min/max values are recomputed every round.
|
||||
|
||||
`total_installed_battery_capacity` must never be turned into a per-round accumulator reset in the
|
||||
`Global vars reset` block like the other totals. Its sensor is polled independently of STEP 2 and
|
||||
its state is written straight into CAN frame `0x379` with no `has_state()` guard, so a transient
|
||||
zero would announce 0 Ah of installed capacity to the inverter.
|
||||
|
||||
### `bms_seen_online_bitmask` is never cleared
|
||||
|
||||
It records that a BMS has been online at least once since boot. `shunt_combine.yaml` uses it to
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Updated : 2026.08.14
|
||||
# Updated : 2026.08.26
|
||||
# Version : 1.8.0
|
||||
# GitHub : https://github.com/Sleeper85/esphome-yambms
|
||||
|
||||
@@ -20,10 +20,11 @@ substitutions:
|
||||
bms_protocol: "Unknown"
|
||||
|
||||
globals:
|
||||
- id: bms${bms_id}_combined_once
|
||||
type: bool
|
||||
# Last valid battery_capacity this BMS contributed to the installed total
|
||||
- id: bms${bms_id}_installed_capacity
|
||||
type: float
|
||||
restore_value: no
|
||||
initial_value: "false"
|
||||
initial_value: "0.0"
|
||||
- id: bms${bms_id}_combined
|
||||
type: bool
|
||||
restore_value: no
|
||||
@@ -93,13 +94,18 @@ interval:
|
||||
if (id(bms${bms_id}_can_be_combined).state)
|
||||
{
|
||||
// +-----------------------------------------------+
|
||||
// | Combine once only |
|
||||
// | Installed battery capacity contribution |
|
||||
// +-----------------------------------------------+
|
||||
// The installed total tracks a hot capacity change, but is never
|
||||
// reduced when a BMS is uncombined : an offline BMS simply stops
|
||||
// updating its contribution, which stays in the total.
|
||||
|
||||
if (id(bms${bms_id}_combined_once) == false)
|
||||
float capacity = id(bms${bms_id}_battery_capacity).state;
|
||||
|
||||
if (capacity != id(bms${bms_id}_installed_capacity))
|
||||
{
|
||||
id(yambms${yambms_id}_var_total_installed_battery_capacity) += id(bms${bms_id}_battery_capacity).state;
|
||||
id(bms${bms_id}_combined_once) = true;
|
||||
id(yambms${yambms_id}_var_total_installed_battery_capacity) += capacity - id(bms${bms_id}_installed_capacity);
|
||||
id(bms${bms_id}_installed_capacity) = capacity;
|
||||
}
|
||||
|
||||
// +-----------------------------------------------+
|
||||
|
||||
Reference in new issue
Block a user