203 Commits
Author SHA1 Message Date
Sleeper85 25727029f6 Fake Equalizing - Disabled by default
The inferred balancing flag stops the Cut-Off timer while the cell spread
stays above bms_balance_trigger_voltage. A pack that does not actually
balance (no balancer, balancing disabled, or a balancer too weak for the
pack) never closes its spread, so the charge stayed in Cut-Off until the
EOC timer ended it, or indefinitely with the EOC timer switch off.

bms_fake_equalizing_enabled now defaults to 'false' for every BMS that
includes the package (EG4 LL V2, Seplos V1/V2, Seplos V3, JK RS485
DISPLAY, Fake/Demo BMS): the flag reports the constant false these
packages used to hardcode. Set it to 'true' per BMS to enable it.

Charging_logic.md and Changelog_Fake_Equalizing.md describe the new
default and the warning.
2026-11-19 02:31:42 +01:00
Andrew Rankin a7e190b8e1 EG4 LL-V2: no General alarm for a full pack, component v1.1.4 (#349)
Fixes #342

* EG4 LL-V2: no General alarm for a full pack, component v1.1.2

EG4 packs hold protection bit 12 ("Low Capacity") while they are full and
have stopped charging, and it clears once they discharge. It was mapped to
General alarm, so every full charge raised a YamBMS alarm and sent it to
the inverter over CAN (#342). It is no longer mapped.

Discharge over temperature (0x0200) and discharge under temperature
(0x0800) protection were not mapped; they now raise the high and low
temperature alarms, as charge OT/UT already raise the charge ones.

Component v1.1.2 tracks each register block on its own
(RAR/esphome-eg4-bms#9): a pack goes offline when either block stops
giving valid replies, and that block's sensors publish NaN, so the
bitmask lambda now reads a NaN bitmask as no bits.

* EG4 LL-V2: component v1.1.3 (bus turnaround gap)

v1.1.2 took packs offline on a shared bus: a request sent right after
another pack's reply was often not answered. v1.1.3 waits a turnaround
time (50 ms) after each reply (RAR/esphome-eg4-bms#9).

* EG4 LL-V2: update date and version of the changed YAMLs
* EG4 LL-V2: component v1.1.4 (only the awaited reply ends the wait)
2026-11-16 20:50:55 +01:00
Sleeper85 bb071e6565 JK RS485 - Load the components 1.2 from @dev and remove protocol_version
The sniffer packages load the JK RS485 components from the dev branch of
Sleeper85/esphome-components (JK RS485 1.2) until it is tested and merged
into main ; they will then go back to @main.

JK RS485 1.2 removes the protocol_version key of jk_rs485_sniffer (the
JK-PB RS485 protocol has only one version) and refuses it, while 1.1
requires it : both changes have to be made together. The sniffer packages
no longer pass it, and the sniffer_protocol var is removed from the JK-B
and JK-PB RS485 YAML and examples. A user YAML that still defines
sniffer_protocol keeps working, the var is simply unused.
2026-11-13 08:02:20 +01:00
Sleeper85 6940efb357 JK RS485 - Remove the precharging, operation status and battery type entities
The JK RS485 component never published a value for them : the
"precharging" switch had no register and wrote nothing, and the
"operation status" and "battery type" text sensors were never decoded.
They stayed unknown in Home Assistant and are removed from the component
in JK RS485 1.2.

The "status precharging" binary sensor, which works, is kept.
2026-11-12 17:52:48 +01:00
Sleeper85 8ade0b4ce6 JK RS485 - The sniffer dev package declares its UART
Same declaration as the other sniffer packages: the UART comes from
board_options_itf_${sniffer_uart_id}.yaml, with sniffer_uart_baud_rate
(default 115200).
2026-11-12 17:52:43 +01:00
Sleeper85 77237e7c6c Reject NaN values in the BMS and shunt can_be_combined conditions
The BMS condition tested most sensors with has_state(), which ESPHome sets
on every publication, NaN included. A BMS that had published NaN once on a
mandatory sensor (for example the PACE power template, which returns NaN
when the current is unknown) stayed combinable, and the NaN corrupted the
totals that drive the inverter.

- Sensors are tested with !std::isnan(): a sensor's state starts at NaN,
  so it also covers a sensor that never published.
- cell_ovp and cell_uvp use > 0, like total_voltage and battery_capacity.
  JK, KS and PACE packages declare them as a number, whose state starts
  at 0, so isnan() alone would combine the BMS before its protection
  settings are read.
- Binary sensors keep has_state(), a bool cannot be NaN.

The shunt condition only checked the switch and online_status. It now
also checks the four values the combiner reads: voltage > 0, and current,
power and soc with isnan(). A combined shunt replaces the BMS values, so a
NaN there reached the inverter directly.

Both conditions move from the binary sensor lambda to STEP 1, on the
device's turn, and are published to "Can be combined". A template binary
sensor with a lambda runs it on every loop, about 60 times per second per
device, for a value read once per round.

Design_decisions documents which test applies to which entity type, that
every entity in the conditions is mandatory, and why they are evaluated in
STEP 1.
2026-11-10 22:54:46 +01:00
Andrew Rankin 8b24872878 Update EG4 LL-V2 component to v1.1.1 (builds on ESPHome 2026.11) (#341)
Update EG4 LL-V2 component to v1.1.1 (builds on ESPHome 2026.11)

ESPHome 2026.11 removed format_hex_pretty(), which v1.1.0 used in its frame
logs, so every EG4 LL-V2 config failed to compile on dev:
'format_hex_pretty' was not declared in this scope. v1.1.1 uses its own
formatter (same output) and changes nothing else.

Checked with the EG4 LL-V2 example (3 BMS, ESP32) on ESPHome 2026.11.0b3.
2026-11-09 23:19:31 +01:00
Sleeper85 67b6892e24 Set ESPHome min_version to 2026.11.0 and declare sub-device relation
ESPHome 2026.11 makes `relation` a required option for every entry under
`esphome: devices:`, and 2026.10 rejects that key. Both changes have to
land together, so raise min_version to 2026.11.0 in the same commit.

Use `relation: via` on all ten device declarations (BMS, sniffer, shunt,
balancer, Deye stack, board, YamBMS instance, CAN and RS485 links). It is
the value the API assumed before the key existed, so Home Assistant keeps
showing the devices exactly as before. `child` would fit the board, the
YamBMS instance and the inverter links better, but it is left for later:
a Home Assistant release that reads the field without supporting `child`
drops those devices and their entities.

Docs: ESPHome 2026.11.0 in README and Installation_procedure (which still
said 2025.11.0), Design_decisions no longer equates min_version with the
flow_control requirement, and Coding_conventions documents the
`relation: via` rule.
2026-11-09 00:06:28 +01:00
Sleeper85 4fd0bd796c Set YamBMS version to 1.8.2 2026-11-08 23:45:59 +01:00
Sebastian 61424486c0 Round daily energy sensors to 10 Wh (#339)
Daily Charging/Discharging Energy (YamBMS and per BMS) were published
with 1 Wh resolution. Home Assistant records every float change, so a
new state was written every few seconds while charging or discharging.

- Add a round: 2 filter and set accuracy_decimals to 2 (0.01 kWh).
- bms_base_daily_energy 1.1.4, changelog updated.
2026-11-08 23:08:34 +01:00
Sleeper85 58c03ac83f Packages: Declare each CAN node in the package that consumes it
yambms_canbus.yaml and the Deye top packages now import their node from
canbus_platform (esp32_can, mcp2515 or external). canbus_bitrate replaces
esp32_canbus_bitrate and mcp2515_canbus_bitrate. Breaking change.
2026-11-08 23:08:34 +01:00
Sleeper85 e3f35aedb0 Packages: Declare each UART in the package that consumes it
Each package now imports its UART from its *_uart_id var and keeps its own baud
rate key. WK2168 channels work the same way, uart_flow_control_pin replaces the
flow control include, and min_version moves to 2026.10.0. Breaking change.
2026-11-08 23:08:34 +01:00
Sleeper85 5c171aea14 Docs: Explain the 0 A limit in the combiner
Document why the combiner accepts 0 A as a valid charge and discharge limit.
2026-11-08 23:08:34 +01:00
Sleeper85 668b50d7a0 Set YamBMS version to 1.8.1 2026-11-08 23:08:33 +01:00
Sebastian c7e498d5ca Improve Deye support (#337)
* Fix Deye power update interval
* Keep batteries the report CCL/DCL 0A

A battery that reports a charge limit (CCL) or discharge limit (DCL) of 0 A now stays in the combine. Before, a full Deye at 0 A CCL, or an empty one at 0 A DCL, dropped out of capacity, SoC and the totals.

- Missing values are still caught: a CCL or DCL with no value yet still fails >= 0, because comparisons with NaN are always false.
- No effect on the limits: CCL and DCL are added up, so a battery at 0 A adds 0 A to the total.
- All BMS models are affected

https://github.com/Sleeper85/esphome-yambms/issues/335
2026-11-08 23:08:33 +01:00
Sleeper85 abcc715d33 BMS: PACE word_from_hex_str moved to modbus::helpers (ESPHome 2026.10) 2026-11-08 23:08:33 +01:00
Sleeper85 35332227a4 BMS: PACE Modbus compatibility with ESPHome 2026.10 #332 2026-11-08 23:08:33 +01:00
Sebastian 4a23cb6b47 BMS: Fix sensor device_class and state_class (#331)
Several sensors had a device_class that did not match their unit, so
Home Assistant shows warnings and handles them wrongly (unit
conversion, statistics).

- Power sensors in W used device_class 'current'; now 'power'
  (BASEN RS485, DEYE CAN module full/minimal, FAKE).
- Ah sensors had a device_class that does not accept Ah ('battery',
  'energy', 'energy_storage'). Removed it, since Home Assistant has no
  device_class for Ah (BASEN RS485, DEYE CAN module/top full/minimal,
  JK RS485 Display, Modbus client).
- DEYE battery capacity used state_class 'total_increasing', but the
  value is not a counter. Changed to 'measurement'.
2026-11-08 23:08:33 +01:00
Sleeper85 0fb9cc8116 Refresh 60min 2026-11-08 23:08:33 +01:00
Sleeper85 7d00721dfe Charging cycles published 0 instead of NaN when no BMS is combined
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.
2026-11-08 23:08:33 +01:00
Sleeper85 9dd22fa56b Inferred equalizing for BMS that do not report a balancing flag
Some BMS balance their cells but never expose a balancing flag, so
`bms_equalizing` stays false and the core cannot tell a pack that is still
balancing from one that has finished. This is not cosmetic : while
equalizing is true, yambms_core.yaml stops the Cut-Off timer and lets the
charge run to the EOC timer instead of terminating early.

bms_options_fake_equalizing.yaml infers that flag from the pack itself. No
absolute cell voltage is hardcoded : the anchor is bulk_voltage / cell
count, the same derivation as cell_bulk_v in yambms_core.yaml, so it
follows `yambms_battery_chemistry`, the cell count and the configured bulk
voltage automatically.

  START when BOTH are true
    max cell >= cell_bulk_v                     the pack is at the setpoint
    AND (max - min) >= trigger voltage          its own balancing threshold

  STOP when EITHER is true
    max cell <  cell_bulk_v - hysteresis        the pack dropped off the setpoint
    OR (max - min) <  trigger - delta hyst.     the spread closed back below it

Only two deltas and one offset are configurable, and none of the three
depends on the chemistry - LFP, Li-ion and LTO all want the same few tens
of mV. The absolute anchor they hang off comes from the core, for free.

The delta condition is what keeps this honest : a pack that reaches the
setpoint perfectly balanced has nothing to equalize, so it reports false
and the Cut-Off timer does its job. A plain voltage comparison would report
balancing forever and terminate every charge on the EOC timer.

It extends bms<id>_bms_equalizing, the raw BMS flag, and not the combined
bms<id>_equalizing sensor. bms_base_balancer.yaml is therefore neither
modified nor duplicated, and keeps giving an external balancer priority
whenever one is online : the inference only applies when no balancer
reports for this pack.

This commit only adds the package. Nothing includes it yet, so no existing
configuration changes behaviour. Candidates sharing the same case are
Seplos V3, Seplos V1/V2, EG4 LL V2 and JK RS485 DISPLAY, whose
bms_equalizing is a hardcoded `return false;`.
2026-11-08 23:08:33 +01:00
Sleeper85 0783bc8ab0 Added battery_capacity number 2026-11-08 23:08:33 +01:00
Sleeper85 cb3b0eedba 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.
2026-11-08 23:08:33 +01:00
Sleeper85 39febc31d4 Support of the new errors_bitmask_hex from JK-BLE 2026-11-08 23:08:33 +01:00
Sleeper85 0f7bf94111 Added KS BMS support #151 2026-11-08 23:08:33 +01:00
Andrew Rankin 40daa229b5 Update EG4 LL-V2 component to v1.1.0 (fixes zero-value BMS readings) (#315)
* Update EG4 LL-V2 component to v1.1.0

Fixes RAR/esphome-eg4-bms#7: some EG4 LL-V2 units intermittently answer
with a CRC-valid function-03 response whose register data area is
entirely zero. The component published those zeroes as a real reading,
collapsing SoC, pack voltage and capacity for one poll cycle.

v1.1.0 rejects implausible blocks and no longer lets them refresh the
online tracker, so a unit stuck returning zeroes now goes offline
instead of reporting a flat-zero battery.

No YamBMS-side changes are required: neither EG4 package uses the
removed designed_capacity sensor, and both already use the
cell_average_voltage key.
2026-11-08 23:08:32 +01:00
Sleeper85 fa9f101d1b Move vars bms_model & bms_protocol 2026-11-08 23:08:32 +01:00
Sleeper85 31314847d9 YamBMS core 1.8.0 - CVL, CCL and DCL code improvements 2026-11-08 23:08:32 +01:00
Sleeper85 9b2787ecca Improved PACE BMS modbus (esphome >= 2026.7.0) 2026-11-08 23:08:32 +01:00
Sleeper85 c82af08d3c Updated multi-node modbus default settings + documentation #310 2026-11-08 23:08:32 +01:00
Sleeper85 cd385bc462 Removal of max_dishcarge_current limit (processed in yambms_core) 2026-11-08 23:08:31 +01:00
Sleeper85 277cfd49bc Compliance with esphome PR_11969 (modbus_server send_wait_time) 2026-07-11 00:29:11 +02:00
Sleeper85 7d76d7c991 Compliance with esphome 2026.6.0 (modbus_server) 2026-07-11 00:16:36 +02:00
Sleeper85 69ac0294e1 Compliance with esphome PR_11781 (modbus_controller) 2026-07-11 00:05:53 +02:00
Sleeper85 f186f53da3 Uncomment cell balancing trigger voltage name 2026-07-02 11:37:46 +02:00
Sleeper85 ef06261150 Fixed ${yambms_id} 2026-06-29 16:07:07 +02:00
Sleeper85 3da758fe00 Fixed yambms_id 2026-06-29 12:21:16 +02:00
Sleeper85 9bcb4d7177 New yambms_id format 2026-06-28 00:09:39 +02:00
Sleeper85 683499c8d7 Alignment of sensor names for component JK V3 2026-06-22 16:16:06 +02:00
Sleeper85 bee5abec64 Using a fake sensor instead of errors_bitmask_hex 2026-06-20 00:15:26 +02:00
Sleeper85 3d1ea45eb6 JK BLE - Sync latest changes from @syssi git 2026-06-18 23:40:19 +02:00
Sleeper85 f117319007 Improved Sub-Devices and entity names 2026-03-24 00:37:48 +01:00
Sebastian be772ab1fc Throttle/filter BMS sensors (#242) 2026-03-16 17:52:54 +01:00
Sleeper85 ef5bd4a45e Updated Current min_value 2026-03-07 18:38:17 +01:00
Sebastian 0817a13485 Add fault registry calls to Modbus clients (#239) 2026-02-19 23:54:28 +01:00
Sebastian 1969f14892 Basen: Add "Enable communication" switch (#235)
Add switch to enable/disable communication with Basen BMS. For example
this can be used during maintenance to disable communication with the
selected battery.
2026-02-16 21:01:05 +01:00
Sleeper85 040da87739 Set SEPLOS V3 extended as the default version #216 2026-02-16 15:18:29 +01:00
Andrew Rankin 500d7fa8f6 Add Ecoworthy BMS integration for YamBMS (#199) 2026-02-15 22:49:43 +01:00
Sleeper85 247643195b Create bms_combine_DEMO.yaml 2026-02-15 13:33:09 +01:00
Sleeper85 f70359c0a8 SEPLOS V3 extended version 2026-02-13 16:15:19 +01:00