Skip to content

Encode battery charge source in action states - #13

Merged
LordMike merged 2 commits into
mainfrom
codex/battery-action-source-states
Apr 15, 2026
Merged

Encode battery charge source in action states#13
LordMike merged 2 commits into
mainfrom
codex/battery-action-source-states

Conversation

@LordMike

@LordMike LordMike commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

This PR changes battery action states so they encode charge source directly in the public contract instead of exposing a generic charge state plus a separate charge_source field.

It changes battery schedule/action outputs from:

  • charge + charge_source=grid|pv|grid_pv

to:

  • charge_grid
  • charge_pv
  • charge_grid_pv

hold and discharge remain unchanged.

What this changes

  • Updates public battery action/state outputs across optimizer, projection, snapshot, and sensor surfaces
  • Removes the emitted charge_source attribute/field from:
    • battery schedule points
    • coordinator snapshot / planner projection outputs
    • battery action sensor attributes
  • Converts battery action sensors to enum sensors with explicit allowed options
  • Updates compact plan_details battery action codes to preserve source information:
    • c_g
    • c_p
    • c_gp
    • d
    • h
  • Changes mixed hourly rollups in projection.py to join multiple non-hold compact action codes with + to avoid ambiguous strings

Tests

Validated with targeted pytest runs:

  • tests/optimizer/test_optimizer_scenarios.py
  • tests/integration/test_integration_runtime.py
  • tests/integration/test_integration_e2e.py

Result: 61 passed

Docs

Updates entity/service and optimizer API docs to reflect the new battery action contract and compact action encoding.

Notes

  • Removes regression-style test wording focused on charge_source as a legacy field; tests assert the positive contract only
  • Leaves internal optimizer helper naming such as _charge_source_permissions unchanged because it is not part of the public API

@LordMike
LordMike force-pushed the codex/battery-action-source-states branch from 4189427 to e53e170 Compare April 15, 2026 07:54
@LordMike
LordMike merged commit 2ea5997 into main Apr 15, 2026
1 check passed
@LordMike
LordMike deleted the codex/battery-action-source-states branch April 15, 2026 08:23
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.

1 participant