feat(plan): show the actual planned charge/export rate in the hover text - #4608
Merged
Conversation
Adds {rate_kw} to the charge_low_rate and export_high_rate "why" reason
templates, so the plan tooltip shows what rate will actually be used,
not just the price. Requested in #4596, gcoan agreed hover text over
cluttering the state cell.
Export reuses the existing fractional-limit encoding (the same one
that drives the snail symbol) - battery_rate_max_export scaled by
1 - (limit - int(limit)).
Charging has no equivalent fixed encoding: low power charging
(set_charge_low_power) throttles the rate dynamically per-minute
rather than storing a reduced rate per window, so the non-low-power
case is a straight nameplate-rate lookup but the low-power case needs
recomputing via find_charge_rate() (added get_charge_rate_kw()) to
avoid showing a misleadingly-high number during a throttled slot.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances Predbat’s HTML plan “why” (hover/click) text by including the planned charge/export power rate (kW) alongside the existing price-rate (p/kWh), improving visibility when slow/limited modes are active.
Changes:
- Added
rate_kwto thecharge_low_rateandexport_high_ratereason templates and per-slot reason params. - Introduced
get_charge_rate_kw()to recompute the effective charge rate (including low-power throttling) viafind_charge_rate(). - Extended
test_plan_why_reasonto assert the newrate_kwparam and to cover slow export + low-power charge scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/predbat/output.py | Adds rate_kw into plan reason templates/params; introduces get_charge_rate_kw() and computes export rate_kw from fractional export limit encoding. |
| apps/predbat/tests/test_plan_why_reason.py | Updates assertions to include rate_kw and adds scenarios for throttled charge and fractional-limit export. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #4596. Adds the planned charge/export rate (kW) to the plan's per-slot hover/click text, alongside the existing rate (p/kWh) info. gcoan agreed hover text over cluttering the state cell/snail symbol.
limit's fractional part = tens-of-percent rate reduction) -battery_rate_max_export * (1 - (limit - int(limit))). No new computation, just surfacing a value the code already derives elsewhere (execute.py/prediction.py).set_charge_low_power) throttles the rate dynamically per-minute rather than storing a reduced value per window. Addedget_charge_rate_kw()inoutput.py, which recomputes the actual rate viafind_charge_rate()(the same function the prediction engine itself uses) so the low-power case shows the real throttled rate rather than the nameplate max, which would otherwise be actively misleading during a slow-charge slot.Test plan
./run_all --test plan_why_reason- extended with two new scenarios: a fractional/slow export limit showing the reduced rate, and a low-power charge slot showing a throttled rate below the nameplate max (not just the simple full-rate case)Chrg/Expreason-param assertions updated to include the newrate_kwparam./run_all --quickpasses./run_pre_commitpasses🤖 Generated with Claude Code