Skip to content

Show the snail icon on low power charge slots in the plan - #5353

Open
springfall2008 wants to merge 2 commits into
mainfrom
feat/slow-charge-snail-icon-5352
Open

springfall2008 wants to merge 2 commits into
mainfrom
feat/slow-charge-snail-icon-5352

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

This is an automated draft PR generated from issue #5352 — a maintainer should review it before merging.

Fixes #5352

Summary

A Chrg slot in the plan now carries the snail (🐌) that a slow export slot already shows, when low power charging (switch.predbat_set_charge_low_power) is asking for less than the maximum charge rate in that slot.

Export stores its reduced rate in the limit, so the existing check is a simple decode. Charge has no such encoding - the rate is worked out by find_charge_rate() as the slot runs - so Output.get_charge_rate_kw(), which already recomputes that rate for the slot's description text, now also returns whether the requested rate is below battery_rate_max_charge. publish_html_plan() appends the snail on that flag.

docs/predbat-plan-card.md already promised the snail for a slow charge; the sentence is reworded to match what the code does (the snail follows the State, and the limit.tens_of_percentage_rate_reduction form is export-only and only shown with plan debug on).

Testing

  • ./run_pre_commit (from coverage/): all hooks passed.
  • tools/triage_test.sh plan_why_reason: fails without the fix, passes with it. With output.py stashed the run fails on the new assertion only (Chrg low power state cell should show the snail like a slow export does (#5352), got: Chrg↗); with the fix restored it passes.
  • New assertions in test_plan_why_reason.py: the throttled low power slot's state_html is exactly Chrg↗🐌; a full rate charge with low power off shows no snail; and low power on but a target too far away to throttle (so find_charge_rate() falls back to the maximum rate) shows no snail. The two no-snail cases pass either way by construction - they are there to pin the behaviour, the first is the one that proves the change.
  • tools/triage_test.sh debug_cases: passed (golden plan JSON unchanged).

Notes

  • What counts as slow. The snail keys on the rate low power mode requests, not the rate achieved after the battery charge curve. A full rate charge that the curve tapers near the top of the battery therefore gets no snail, which mirrors export, where the snail marks a planned reduced rate rather than a physical limit. The issue says "when the power is less than the maximum"; if the taper should count too, the comparison in get_charge_rate_kw() is the one line to change.
  • Per-row, from predicted SoC. Like the rate_kw in the description text, the flag is recomputed for each plan row from the predicted SoC at the start of that row, so a long charge window can show the snail on some rows and not others (e.g. once the remaining window is too short to throttle).
  • get_charge_rate_kw() keeps its name but now returns a (rate_kw, low_power) tuple. GitNexus impact() reports LOW risk: one caller, publish_html_plan(), updated here.
  • The snail is appended to the same state string as the export one, so it flows into state_html / state_text in the plan JSON the same way; state (raw Chrg) is unchanged.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@springfall2008 springfall2008 self-assigned this Oct 2, 2026
@springfall2008 springfall2008 added BOT_REVIEW Trigger an autotriage BOT_CLEANUP Trigger: bot should address PR review feedback and CI failures, then commit and push labels Oct 2, 2026
Comment thread apps/predbat/output.py Outdated
Comment thread apps/predbat/output.py Outdated
Comment thread apps/predbat/output.py Outdated
Comment thread apps/predbat/tests/test_plan_why_reason.py
Comment thread apps/predbat/output.py
@springfall2008 springfall2008 removed the BOT_REVIEW Trigger an autotriage label Oct 2, 2026
…ndow in the plan's charge rate

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@springfall2008 springfall2008 removed the BOT_CLEANUP Trigger: bot should address PR review feedback and CI failures, then commit and push label Oct 2, 2026
@springfall2008
springfall2008 marked this pull request as ready for review October 9, 2026 19:23
Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Partial-row charge windows can be incorrectly marked as low power because rate calculation begins before the charge window.

1 open finding
What changed in this PR

Adds a snail indicator to plan rows where low-power charging requests a reduced rate.

Changes:

  • Returns charge rate and low-power status from get_charge_rate_kw().
  • Displays and tests the snail indicator.
  • Clarifies plan-card documentation.
File Description
apps/​predbat/​output.py Calculates and displays reduced-charge status.
apps/​predbat/​tests/​test_plan_why_reason.py Adds charge-rate and snail regression cases.
docs/​predbat-plan-card.md Documents slow-charge and slow-export indicators.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread apps/predbat/output.py
Comment on lines +1095 to 1097
# The window end is floored to a step boundary, as the prediction engine does
window_end_rel = min(max(((window["end"] - self.minutes_now) // PREDICT_STEP) * PREDICT_STEP, minute_relative_start), self.forecast_minutes)
pv_window_kwh = sum(pv_forecast_minute_step.get(m, 0.0) for m in range(minute_relative_start, window_end_rel, PREDICT_STEP))

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show snail icon for slow charge slots

3 participants