bms_base_charging_cycles.yaml coerced a NaN raw reading to 0 before adding
the user offset, instead of letting NaN propagate like the sensors fixed
in dee203e4 ("Sensors published to NAN when no BMS is combined"). *_raw is
NaN until the first trusted BMS frame arrives after a reboot, so both
`charging cycles` and `total charging cycle capacity` published a literal
0 during that transient - with `state_class: total`, that 0 also landed
in Home Assistant's long-term statistics.
Fix is to drop the two `if (isnan(...)) = 0;` coercions and let
`NaN + offset == NaN` propagate, so both sensors go unavailable through
the transient instead of reporting 0.
Both sensors also moved from `or: [throttle: 10s, delta: 1]` to the
NaN-safe rate-limit filter already used throughout yambms_core.yaml, since
the built-in `delta` filter drops a NaN transition without updating its
reference and would otherwise freeze the sensor on its last value for up
to 10s.
That filter is extracted from yambms_core.yaml into
packages/base/device_base.yaml, which every node loads via its board_*.yaml
regardless of whether it runs the YamBMS engine - unlike yambms_core.yaml,
which is absent from a multi-node Modbus-server node that only exposes
BMS/Shunt packages. Renamed yambms_rate_limit_filter to rate_limit_filter
now that it is no longer engine-specific.
77 lines
2.5 KiB
YAML
77 lines
2.5 KiB
YAML
# Updated : 2026.08.29
|
|
# Version : 1.1.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: "Charging Cycles Offset"
|
|
id: bms${bms_id}_charging_cycles_offset
|
|
device_id: bms_${bms_id}
|
|
step: 1
|
|
min_value: 0
|
|
max_value: 3000
|
|
initial_value: 0
|
|
restore_value: true
|
|
icon: mdi:counter
|
|
optimistic: true
|
|
entity_category: config
|
|
|
|
sensor:
|
|
# +--------------------------------------+
|
|
# | Charging Cycles |
|
|
# +--------------------------------------+
|
|
- platform: template
|
|
name: "charging cycles"
|
|
id: bms${bms_id}_charging_cycles
|
|
device_id: bms_${bms_id}
|
|
update_interval: ${bms_update_interval}
|
|
state_class: total
|
|
icon: mdi:counter
|
|
accuracy_decimals: 0
|
|
lambda: |-
|
|
return id(bms${bms_id}_charging_cycles_raw).state +
|
|
id(bms${bms_id}_charging_cycles_offset).state;
|
|
filters:
|
|
- lambda: |-
|
|
const float delta = 1.0f;
|
|
${rate_limit_filter}
|
|
|
|
# +--------------------------------------+
|
|
# | Charging Cycle Capacity |
|
|
# +--------------------------------------+
|
|
- platform: template
|
|
name: "total charging cycle capacity"
|
|
id: bms${bms_id}_cycle_capacity
|
|
device_id: bms_${bms_id}
|
|
update_interval: ${bms_update_interval}
|
|
unit_of_measurement: Ah
|
|
state_class: total
|
|
icon: mdi:car-battery
|
|
accuracy_decimals: 0
|
|
lambda: |-
|
|
return id(bms${bms_id}_cycle_capacity_raw).state +
|
|
id(bms${bms_id}_charging_cycles_offset).state *
|
|
id(bms${bms_id}_battery_capacity).state;
|
|
filters:
|
|
- lambda: |-
|
|
const float delta = 1.0f;
|
|
${rate_limit_filter}
|