Commit Graph
15 Commits
Author SHA1 Message Date
Sleeper85 fcbe5023af Suspend the charging logic while no BMS is combined
The STEP 3 guard tested its values with has_state(), which ESPHome sets on
every publication, NaN included. STEP 2 publishes NaN when no BMS is
combined, so STEP 3 ran on every tick of a boot or a BMS dropout. The
charging logic then saw "Charging allowed" false and set the status to
Wait, and the Init/Wait -> Bulk rebulk rule restarted a Bulk on a full
battery as soon as the BMS came back.

- The guard follows the can_be_combined rules: isnan() or a comparison
  for sensors, has_state() for binary sensors. It reads the live
  var_to_combine_bms_counter rather than bms_combined, which STEP 2 only
  publishes once per round.
- The inner "At least one BMS combined" check is removed: the guard is
  now the single test. CVL, DVL, CCL, DCL and Requested Force Charge
  move up one level.
- A new else branch suspends the logic: var_charge_status keeps its
  value, the instructions and requested values are cleared for Home
  Assistant, and var_initialized is set to false.
- The end of STEP 3 no longer tests bms_combined and total_voltage,
  already guaranteed by the guard.

This fixes the dropout case of #343. A BMS that blocks charging while
combined still goes through Wait.

Charging_logic documents the BMS dropout behaviour, Design_decisions the
guard and its else branch.

Refs #343
2026-11-11 00:20:09 +01:00
Sleeper85 2fcfc4f44f Silence the Voltronic LIB link until YamBMS is initialized
The CAN and PYLON links only send data while var_initialized is true and
at least one BMS is combined. The LIB link only checked its protocol, so
it kept answering the inverter during a boot or a BMS dropout, and its
read_lambdas converted the NaN values to integers, which is undefined.

The 100 ms interval now moves the Modbus server to address 248, the
mechanism already used for Disabled, until YamBMS is initialized. The
status mirroring still follows the protocol only: an active link left
silent serves no request, its Status goes false and raises the fault,
like the other links during a dropout.

Design_decisions documents the second condition.
2026-11-11 00:00:27 +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
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 cb9638653d Docs: The CCL/DCL divider counts declared links
Document that every declared CAN or RS485 inverter link divides the requested
CCL/DCL, including a link whose protocol is `Disabled` or left on `Automatic`
with no brand, and that only links actually wired to an inverter should be
declared.

Design_decisions.md records why the divider must not be restricted to active
links: a disabled link usually still has an inverter drawing from the bank, an
unconfigured link is the state every link starts in after 1.8.0, and a lost
link must never raise the current sent to the remaining inverters.

YamBMS_functions.md: fix the RS485 package name (`yambms_rs485.yaml`).
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 ee12380087 YamBMS: Inverter brand registry and RS485 entry point
Rename the inverter registry to yambms_brand_registry.yaml and add the new brands.
yambms_rs485.yaml becomes the file to include, with a rs485_protocol var that
selects PYLON or Voltronic LIB.
2026-11-08 23:08:34 +01:00
Sleeper85 281d39ac18 New inverter brand select drives the CAN and RS485 protocol
BREAKING CHANGE: both inverter link selects are renamed, so their stored value is
reset. The link stays inactive until an inverter brand is selected. See
documents/README/changelog/Changelog_Inverter_brand_and_protocol.md

New `Inverter brand` select (16 brands) and reworked `Protocol` select, now
defaulting to `Automatic`. Selecting the brand is enough, the protocol follows;
an explicit protocol still takes priority over the brand.

The protocol is resolved once, at boot and on every select change, into
`canbus${canbus_id}_active_protocol` / `rs485${rs485_id}_active_protocol`.
Everything else reads that integer instead of dispatching on `active_index()`,
where `== 5` meant LuxPower purely by convention of the option order.

New shared `yambms_inverter_registry.yaml`: protocol dictionary (`YB_PROTO_*`),
brand to protocol mapping, and the battery mode and note of each couple.

Removed the `YamBMS name` select: the manufacturer name sent on CAN frame 0x35E
now derives from the protocol in use, which is what `Automatic` already did.

Removed the `canbus_extended_ack` substitution: both the 11-bit and the 29-bit
ACK triggers are registered, so the Schneider XW Pro needs no configuration.

Renamed CAN `PYLON 1.2` to `PYLON V1` and RS485 `Pylontech` to `PYLON`.

New per-link diagnostics `Inverter link protocol`, `Inverter battery mode` and
`Note`, with a markdown card in the dashboards, alongside a system fault card.

Telemetry: `comm_bus` / `comm_protocol` replaced by `inverter_brand`,
`inverter_bus`, `inverter_protocol` and `inverter_protocol_source`, one slot per
declared link instead of a single value overwritten by the last one.

RS485 packages split: `yambms_rs485.yaml` is the entry point carrying the selects,
`yambms_rs485_pylon.yaml` the protocol implementation. The baud rate is applied
with `set_baud_rate()` + `load_settings()` instead of extending the uart
component, so boards using a UART expander no longer need their own include.

Fixes:
- the CAN bus kept re-emitting the last frame every 100 ms when the protocol was
  set to `Disabled` at runtime
- the RS485 link kept answering the inverter with stale data on `Disabled`, the
  proxy sensors it reads are now invalidated
- a `Disabled` link no longer lights the fault LED, it is unregistered from the
  fault registry instead of being reported as failing
- the reported bus and protocol were overwritten when a node declares several
  inverter links
- changing the protocol restarts the CAN frames immediately instead of waiting up
  to 30 s for the next retry tick
2026-11-08 23:08:33 +01:00
Sleeper85 3e596ea82a Reworked the update and telemetry services
- update and telemetry are now gated independently by substitution;
  var_service and its Update service switch are removed
- the uptime text sensor is published by its source instead of polling
  it, which fixes the 24855d readings that reached the telemetry, and
  the raw seconds are now sent instead of the formatted string
- the MAC address is replaced by a salted SHA-256, derived identically
  server side so no pairing window is needed
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 e4b8aacc0a Fixed 6h reboot on networks that filter the ESP32 outbound traffic
http_request runs on the loop task, which has a 4s budget before the
5s task WDT panics. A dropped connect() blocks for 4.5s (the ESPHome
default timeout) and a filtered port 53 blocks for a fixed 7s, which
timeout does not cover.

- timeout 3s and watchdog_timeout 60s cover the two blocking paths
- a failure counter stops the service after 3 network-level failures,
  instead of freezing the loop 14s every 6h forever
- the POST is now skipped when the GET failed

Reproduced and measured on OPNsense.
See Design_decisions.md.
2026-11-08 23:08:33 +01:00
Sleeper85 4d4d11e832 Auto CVL - Float / Stop (suspended) 2026-11-08 23:08:32 +01:00
Sleeper85 bfa36fb15f Added dev README 2026-11-08 23:08:32 +01:00