Files
esphome-yambms/documents/README/dev
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
..