Skip to content

Comments

Apply braking relative to active/next price block and expose metadata#190

Merged
JohanAlvedal merged 1 commit intocodex/01from
codex/implement-advanced-braking-logic
Jan 20, 2026
Merged

Apply braking relative to active/next price block and expose metadata#190
JohanAlvedal merged 1 commit intocodex/01from
codex/implement-advanced-braking-logic

Conversation

@JohanAlvedal
Copy link
Owner

Motivation

  • Ensure braking is calculated against the correct block when multiple blocks exist by using the active block when now is inside a block and ramping toward the nearest upcoming block otherwise.
  • Prevent brake_blocked_reason from incorrectly reporting no_price_block when we are in a pre-brake ramp for a next block.

Description

  • Add resolve_active_and_next_blocks to determine active_block and next_block from a block or list of blocks and return a canonical block list.
  • Use resolve_active_and_next_blocks inside compute_price_brake to pick the primary_block (active_block or next_block) and expose active_block and next_block in the returned metadata while ensuring blocks includes them for status reporting.
  • Update sensor control flow to read price_brake["next_block"] and detect the pre-brake window so brake_blocked_reason is not set to no_price_block during pre-brake ramping.
  • Leave rate limiting behavior intact (no changes to apply_rate_limit).

Testing

  • Ran pytest, which failed during collection with an ImportError: cannot import name 'compute_block_window' from custom_components.pumpsteer.sensor.sensor', causing the test run to fail.
  • No further automated tests were executed after the change due to the collection error.

Codex Task

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@JohanAlvedal JohanAlvedal merged commit 77947e0 into codex/01 Jan 20, 2026
1 of 4 checks passed
@JohanAlvedal JohanAlvedal deleted the codex/implement-advanced-braking-logic branch January 29, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant