Rollback : don't reset Auto functions vars in core

This commit is contained in:
Sleeper85 committed 2026-11-08 23:08:33 +01:00
1 parent 803c84d7da
commit 23384f4677
2 files changed
+26 -38

No files matched your search

@@ -1,5 +1,5 @@
# Updated : 2026.08.11
# Version : 1.1.2
# Updated : 2026.08.21
# Version : 1.1.3
# GitHub : https://github.com/Sleeper85/esphome-yambms
# YamBMS ( Yet another multi-BMS Merging Solution )
@@ -27,10 +27,13 @@
# Contract with yambms_core.yaml (upstream/dev):
# - Participates in Auto CCL STEP pipeline
# - Writes: id(yambms${yambms_id}_var_auto_ccl_current_taper) (<= 0 when tapering)
# on its own turn only. The core resets this var to 0 every cycle before
# restarting the pipeline at step 1, so staying silent (feature disabled,
# gated out, or not our turn yet) is equivalent to writing 0.
# on its own turn. The core does NOT reset this var: it holds the last value
# written until this package overwrites it. Every path that takes its turn
# must therefore write it explicitly, 0 included (feature disabled, gated
# out, data not ready), otherwise a stale derating sticks forever.
# Staying silent is only allowed when it is not our turn (Gate #1).
# - Advances pipeline via: id(yambms${yambms_id}_var_charge_current_step)++
# exactly once per turn, on every path that passed Gate #1.
#--------------------------------------------------------------------------------------------
substitutions:
@@ -226,14 +229,18 @@ interval:
const int n_funcs = id(yambms${yambms_id}_var_auto_ccl_functions_count);
if (cc_step < 1 || cc_step > n_funcs) return; // Not our pipeline turn — core resets the pipeline var
ESP_LOGD("yambms_debug", "Entering Auto CCL Current Taper...");
//--------------------------------------------------------------------
// Gate #2: Feature enabled ?
//--------------------------------------------------------------------
if (!id(yambms${yambms_id}_switch_auto_ccl_current_taper).state) {
active = false;
bulk_latched = false;
id(yambms${yambms_id}_var_auto_ccl_current_taper) = 0.0f;
id(yambms${yambms_id}_auto_ccl_ct_delta).publish_state(0.0f);
id(yambms${yambms_id}_var_charge_current_step)++;
ESP_LOGD("yambms_debug", "Auto CCL CT : Disabled => Exit");
return;
}
@@ -278,8 +285,10 @@ interval:
if (isnan(V_knee) || isnan(V_bulk) || isnan(V_pack)) {
active = false;
bulk_latched = false;
id(yambms${yambms_id}_var_auto_ccl_current_taper) = 0.0f;
id(yambms${yambms_id}_auto_ccl_ct_delta).publish_state(0.0f);
id(yambms${yambms_id}_var_charge_current_step)++;
ESP_LOGD("yambms_debug", "Auto CCL CT : Critical data is missing => Exit");
return;
}
@@ -290,8 +299,10 @@ interval:
if (V_knee >= (V_bulk - V_hyst)) {
active = false;
bulk_latched = false;
id(yambms${yambms_id}_var_auto_ccl_current_taper) = 0.0f;
id(yambms${yambms_id}_auto_ccl_ct_delta).publish_state(0.0f);
id(yambms${yambms_id}_var_charge_current_step)++;
ESP_LOGD("yambms_debug", "Auto CCL CT : Knee >= Bulk => Exit");
return;
}
@@ -340,7 +351,8 @@ interval:
I_target = I_max;
}
// Write custom_ccl every baton turn (0 when inactive so a prior taper cannot stick)
// Nominal path: write the var on every baton turn (0 when inactive,
// so a taper from a previous session cannot stick)
id(yambms${yambms_id}_var_auto_ccl_current_taper) = delta;
id(yambms${yambms_id}_auto_ccl_ct_delta).publish_state(delta);
+8 -32
View File
@@ -1223,14 +1223,8 @@ interval:
// Publish the sensor
id(yambms${yambms_id}_requested_charge_current).publish_state(requested_charge_current);
if (id(yambms${yambms_id}_var_charge_status) != "Init")
id(yambms${yambms_id}_var_requested_ccl_init) = true;
// +-----------------------------------------------+
// | Derating reason |
// +-----------------------------------------------+
// Must run BEFORE the reset below: the reason lambda reads the same
// auto vars, and would only ever see zeros ("No Derating") otherwise.
// Derating reason update and log
id(yambms${yambms_id}_ccl_derating_reason).update();
ESP_LOGD("yambms_debug", "CCL limits : temp=%.1f auto=%.1f taper=%.1f soc=%.1f eoc=%.1f custom=%.1f => CCL=%.1f A",
id(yambms${yambms_id}_var_auto_temperature_ccl),
id(yambms${yambms_id}_var_auto_ccl),
@@ -1239,17 +1233,9 @@ interval:
id(yambms${yambms_id}_var_auto_eoc),
id(yambms${yambms_id}_var_auto_custom_ccl),
requested_charge_current);
id(yambms${yambms_id}_ccl_derating_reason).update();
// +-----------------------------------------------+
// | Global vars reset |
// +-----------------------------------------------+
id(yambms${yambms_id}_var_auto_temperature_ccl) = 0;
id(yambms${yambms_id}_var_auto_ccl) = 0;
id(yambms${yambms_id}_var_auto_ccl_current_taper) = 0;
id(yambms${yambms_id}_var_auto_soc_limit) = 0;
id(yambms${yambms_id}_var_auto_eoc) = 0;
id(yambms${yambms_id}_var_auto_custom_ccl) = 0;
if (id(yambms${yambms_id}_var_charge_status) != "Init")
id(yambms${yambms_id}_var_requested_ccl_init) = true;
id(yambms${yambms_id}_var_charge_current_step) = 1;
}
@@ -1280,26 +1266,16 @@ interval:
// Publish the sensor
id(yambms${yambms_id}_requested_discharge_current).publish_state(requested_discharge_current);
id(yambms${yambms_id}_var_requested_dcl_init) = true;
// +-----------------------------------------------+
// | Derating reason |
// +-----------------------------------------------+
// Must run BEFORE the reset below: the reason lambda reads the same
// auto vars, and would only ever see zeros ("No Derating") otherwise.
// Derating reason update and log
id(yambms${yambms_id}_dcl_derating_reason).update();
ESP_LOGD("yambms_debug", "DCL limits : temp=%.1f auto=%.1f custom=%.1f => DCL=%.1f A",
id(yambms${yambms_id}_var_auto_temperature_dcl),
id(yambms${yambms_id}_var_auto_dcl),
id(yambms${yambms_id}_var_auto_custom_dcl),
requested_discharge_current);
id(yambms${yambms_id}_dcl_derating_reason).update();
// +-----------------------------------------------+
// | Global vars reset |
// +-----------------------------------------------+
id(yambms${yambms_id}_var_auto_temperature_dcl) = 0;
id(yambms${yambms_id}_var_auto_dcl) = 0;
id(yambms${yambms_id}_var_auto_custom_dcl) = 0;
id(yambms${yambms_id}_var_requested_dcl_init) = true;
id(yambms${yambms_id}_var_discharge_current_step) = 1;
}
}