Bug
Line 3028 in batpred/apps/predbat/plan.py logs the battery cycle metric using the wrong variable. dp0(best_carbon) is used for both the cycle and carbon positions — the actual best_cycle value never reaches the log.
self.log(
"Second pass optimisation finished metric {} cost {} metric_keep {} cycle {} carbon {} import {}".format(best_metric, dp2(best_cost), dp2(best_keep), dp0(best_carbon), dp2(best_import), dp2(best_carbon))
)
Format placeholders: {}, {}, {}, cycle {}, carbon {}, import {} — 6 slots.
Args passed: best_metric, dp2(best_cost), dp2(best_keep), dp0(best_carbon), dp2(best_import), dp2(best_carbon)
So position 4 (labeled cycle) gets carbon, and position 5 (labeled carbon) also gets carbon. The real best_cycle value is completely lost from this log output.
Impact
- Monitoring dashboards/alerts that parse this log will see the wrong cycle count
- Battery wear estimation from logging becomes inaccurate
- Developer debugging of battery degradation is unreliable
Fix
Pass dp2(best_cycle) at position 4:
self.log(
"Second pass optimisation finished metric {} cost {} metric_keep {} cycle {} carbon {} import {}".format(
best_metric, dp2(best_cost), dp2(best_keep), dp2(best_cycle), dp0(best_carbon), dp2(best_import))
)
Bug
Line 3028 in
batpred/apps/predbat/plan.pylogs the battery cycle metric using the wrong variable.dp0(best_carbon)is used for both the cycle and carbon positions — the actualbest_cyclevalue never reaches the log.Format placeholders:
{},{},{},cycle {},carbon {},import {}— 6 slots.Args passed:
best_metric,dp2(best_cost),dp2(best_keep),dp0(best_carbon),dp2(best_import),dp2(best_carbon)So position 4 (labeled cycle) gets carbon, and position 5 (labeled carbon) also gets carbon. The real
best_cyclevalue is completely lost from this log output.Impact
Fix
Pass
dp2(best_cycle)at position 4: