From eee476340d9e63af1fd90603317a61acb2a65801 Mon Sep 17 00:00:00 2001 From: Sleeper85 Date: Sat, 14 Nov 2026 20:24:19 +0100 Subject: [PATCH] YamBMS - Stop the Cut-Off and EOC timers in Wait and while no BMS is combined The cut-off timer (180s) and the EOC timer (30min) were only stopped when the Bulk phase was re-entered. While the charging logic was suspended (no BMS combined) or in Wait (charging not allowed), they kept running, so a dropout or a charge block during the Cut-Off phase could declare an EOC with no BMS data to confirm it: the status went to Float or EOC, SoC 100% could be sent and the rebulk days counter was reset. Both timers are now stopped while the logic is suspended and whenever the status is set to Wait. With bms_options_charging_logic.yaml, Wait is only entered when the Charging switch is off, so the Cut-Off performed by YamBMS itself is not affected. When charging is allowed again after a Wait in Cut-Off, a new Bulk starts and the Cut-Off phase is run again. Charging_logic.md is updated accordingly. Reported in #352 --- documents/README/Charging_logic.md | 5 +++-- packages/yambms/yambms_core.yaml | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/documents/README/Charging_logic.md b/documents/README/Charging_logic.md index fd2f5a9..89b423e 100644 --- a/documents/README/Charging_logic.md +++ b/documents/README/Charging_logic.md @@ -23,6 +23,7 @@ The charging voltage and current correspond to the default values in the YAML sc While no BMS is combined (boot, reboot, OTA update, RS485 or BLE dropout), the charging logic is suspended: - the `Charging Status` keeps its value: a battery in `Float` or `EOC` stays there and is not sent back to `Bulk` when the BMS returns; +- the cut-off timer and the EOC timer are stopped: a dropout during the `Cut-Off` phase cannot declare an EOC with no BMS to confirm it; - the `Charging Instruction` is `Stop`, the `Discharging Instruction` is off, and the requested values (CVL, DVL, CCL, DCL) are unknown; - nothing is sent to the inverter until YamBMS is initialized again. @@ -35,7 +36,7 @@ While at least one BMS is combined, the `Charging Status` goes to `Wait` when ch - without `bms_options_charging_logic.yaml`: when the `Charging` switch is off, or when no combined BMS allows charging (protection, charge switch off); - with `bms_options_charging_logic.yaml`: only when the `Charging` switch is off. In that mode YamBMS turns the BMS charge switch off itself at Cut-Off, and that block must not change the status. -In `Wait` the `Charging Instruction` is `Stop`. +In `Wait` the `Charging Instruction` is `Stop`, and the cut-off timer and the EOC timer are stopped: an EOC is only declared while charging is allowed. When charging is allowed again: @@ -99,7 +100,7 @@ Once the **Cut-Off phase** is entered: - otherwise the **cut-off timer** starts (`180s` default): if the Cut-Off conditions still hold when it expires, the **EOC** (End Of Charge) is declared; - in parallel, if the `EOC timer` switch is enabled, the **EOC timer** (`30min` default) guarantees that the Cut-Off phase ends at the latest when it expires, even if cells are still equalizing. -Returning to the Bulk phase stops both timers. +Returning to the Bulk phase, going to `Wait` or a BMS dropout stops both timers. Some BMS balance their cells but never expose a balancing flag. YamBMS infers it for them, from the max cell reaching the bulk setpoint together with a cell spread that has diff --git a/packages/yambms/yambms_core.yaml b/packages/yambms/yambms_core.yaml index fa32be5..68d5812 100644 --- a/packages/yambms/yambms_core.yaml +++ b/packages/yambms/yambms_core.yaml @@ -1119,11 +1119,15 @@ interval: // Charging not allowed (BMS or YamBMS) // The status before Wait is kept, to go back to Float or EOC when charging // is allowed again (see "Charging allowed again after Wait"). + // The Cut-Off and EOC timers are stopped: an EOC is only declared while + // charging, so a Wait during the Cut-Off phase does not count as a full charge. else if (id(yambms${yambms_id}_var_bms_charging_logic) == true) { ESP_LOGD("yambms_debug", "Charging not allowed !"); if (!id(yambms${yambms_id}_switch_charging).state) { + if (id(yambms${yambms_id}_script_eoc_timer).is_running()) id(yambms${yambms_id}_script_eoc_timer).stop(); + if (id(yambms${yambms_id}_script_cutoff_timer).is_running()) id(yambms${yambms_id}_script_cutoff_timer).stop(); if (id(yambms${yambms_id}_var_charge_status) != "Wait") id(yambms${yambms_id}_var_charge_status_before_wait) = id(yambms${yambms_id}_var_charge_status); id(yambms${yambms_id}_var_charge_status) = "Wait"; @@ -1132,6 +1136,8 @@ interval: else { ESP_LOGD("yambms_debug", "Charging not allowed !"); + if (id(yambms${yambms_id}_script_eoc_timer).is_running()) id(yambms${yambms_id}_script_eoc_timer).stop(); + if (id(yambms${yambms_id}_script_cutoff_timer).is_running()) id(yambms${yambms_id}_script_cutoff_timer).stop(); if (id(yambms${yambms_id}_var_charge_status) != "Wait") id(yambms${yambms_id}_var_charge_status_before_wait) = id(yambms${yambms_id}_var_charge_status); id(yambms${yambms_id}_var_charge_status) = "Wait"; @@ -1339,11 +1345,14 @@ interval: } // No BMS combined or invalid data: the charging logic is suspended. // var_charge_status keeps its value, so a dropout in Float or EOC does not - // restart a Bulk. The instructions and requested values are cleared so that - // Home Assistant does not show stale ones; the inverter links stop on - // var_initialized. + // restart a Bulk. The Cut-Off and EOC timers are stopped, so a dropout during + // the Cut-Off phase cannot declare an EOC with no BMS to confirm it. The + // instructions and requested values are cleared so that Home Assistant does + // not show stale ones; the inverter links stop on var_initialized. else { + if (id(yambms${yambms_id}_script_eoc_timer).is_running()) id(yambms${yambms_id}_script_eoc_timer).stop(); + if (id(yambms${yambms_id}_script_cutoff_timer).is_running()) id(yambms${yambms_id}_script_cutoff_timer).stop(); id(yambms${yambms_id}_charging_instruction).publish_state("Stop"); id(yambms${yambms_id}_discharging_instruction).publish_state(false); id(yambms${yambms_id}_requested_charge_voltage).publish_state(NAN);