Skip to content

feat: add rate adjust indicators to JSON plan#3662

Merged
springfall2008 merged 2 commits intomainfrom
feat/plan-json-rate-adjust-symbols
Mar 26, 2026
Merged

feat: add rate adjust indicators to JSON plan#3662
springfall2008 merged 2 commits intomainfrom
feat/plan-json-rate-adjust-symbols

Conversation

@mgazza
Copy link
Collaborator

@mgazza mgazza commented Mar 26, 2026

Summary

  • Adds import_rate_adjust and export_rate_adjust fields to each row in the JSON raw plan data (plan_html.attributes.raw)
  • Updates the built-in web UI plan renderer to show italic text with the appropriate symbol for estimated/replicated rates
  • Symbols match the existing adjust_symbol() behaviour from the legacy HTML plan: ? for copied, ? ⚖ for future rates, ? ⅆ for offset, = for user-set, ȣ for manual, ± for increment, $ for saving sessions

The JSON plan was missing this information — the legacy HTML plan showed it via adjust_symbol() but the JSON rows only had the rate values. Both the built-in web UI and external consumers (SaaS frontend) now have access to the adjust type.

Test plan

  • Verify rates beyond the 24h API window show italic with ? symbol in the web UI plan table
  • Verify confirmed rates (within API window) show normal text with no symbol
  • Verify plan_html.attributes.raw JSON rows contain import_rate_adjust / export_rate_adjust fields
  • Verify saving sessions, manual overrides show their respective symbols

🤖 Generated with Claude Code

The JSON raw plan data was missing the rate adjust type that the legacy
HTML plan used to show estimated/replicated rates (? symbols, italic).
Both the built-in web UI and SaaS frontend consume the JSON plan but
had no way to indicate which rates are confirmed vs estimated.

Adds import_rate_adjust and export_rate_adjust fields to each JSON row,
and updates the web UI renderer to display italic text with the
appropriate symbol (matching output.py adjust_symbol behaviour).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mgazza mgazza requested a review from springfall2008 March 26, 2026 07:03
@mgazza
Copy link
Collaborator Author

mgazza commented Mar 26, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds rate-adjustment metadata to the JSON plan output so the built-in web UI (and external consumers) can display the same “rate source/adjustment” indicators that previously only existed in the legacy HTML plan.

Changes:

  • Add import_rate_adjust / export_rate_adjust fields to each JSON plan row (plan_html.attributes.raw.rows).
  • Update the built-in JSON plan renderer JS to display the corresponding symbol (matching Output.adjust_symbol) and italicize adjusted/replicated rates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/predbat/output.py Emits per-row rate-adjust “type” fields into the JSON raw plan output.
apps/predbat/web_helper.py Renders the new adjust-type fields in the web UI plan table via symbol mapping + italics.

1. Rename import_rate_adjust/export_rate_adjust to import_rate_adjust_type/
   export_rate_adjust_type to avoid confusion with numeric *_rate_adjusted fields

2. Omit adjust_type keys when None to reduce HA state attribute bloat
   (16KB limit on plan_html attributes)

3. Add test_plan_json_rate_adjust unit test validating adjust_symbol mapping,
   field presence when adjusted, and key omission when not adjusted

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@springfall2008 springfall2008 merged commit ff5bff2 into main Mar 26, 2026
1 check passed
@springfall2008 springfall2008 deleted the feat/plan-json-rate-adjust-symbols branch March 26, 2026 19:40
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.

3 participants