Skip to content

Gateway fixes for soc chart#3739

Merged
springfall2008 merged 1 commit intomainfrom
fix/gateway5
Apr 4, 2026
Merged

Gateway fixes for soc chart#3739
springfall2008 merged 1 commit intomainfrom
fix/gateway5

Conversation

@springfall2008
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 4, 2026 17:02
Copy link
Copy Markdown
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

Updates GatewayMQTT’s published block_soc data to better support SoC sparkline/chart rendering by providing a consistent per-slot series and adding tests that codify the new behavior.

Changes:

  • Adjust gateway.py to collect block_soc as one SoC value per slot (capped at 24) and ensure at least two points for sparkline rendering.
  • Update/add gateway publishing tests to validate block_soc behavior across state changes, length cap, and single-row plans.
  • Bump PredBat version to v8.35.7.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
apps/predbat/gateway.py Change block_soc accumulation to be per-slot (up to 24) and duplicate single value to guarantee 2 points.
apps/predbat/tests/test_gateway.py Update tests to reflect and validate the new block_soc/block_state semantics and slot cap behavior.
apps/predbat/predbat.py Version bump to v8.35.7.

Comment thread apps/predbat/gateway.py
if slot_idx == 0:
block_state_name = state

if slot_idx < 24:
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

block_soc is now being populated for up to 24 consecutive slots (one SOC value per slot), but the existing inline comment where block_soc is defined still describes it as being for the “current plan block only”. Please update the comment (and/or variable naming) to match the new behavior so future readers don’t assume it stops at state boundaries.

Suggested change
if slot_idx < 24:
if slot_idx < 24:
# Collect one SOC value per slot for up to 24 consecutive plan slots;
# this series can span multiple plan states and is not limited to the
# initial/current plan block only.

Copilot uses AI. Check for mistakes.
Comment thread apps/predbat/gateway.py
if slot_idx == 0:
block_state_name = state

if slot_idx < 24:
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.

Is the usage of 24 here because a day typically has 24 hours? What about DST, wouldn't that cause issues on days that have more than 24 hours?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

It's 24 x 30 minute periods which is only 12 hours?

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.

Ah my bad, so it isn't related to hours but intervals.

@springfall2008 springfall2008 merged commit c22d1b0 into main Apr 4, 2026
5 checks passed
@springfall2008 springfall2008 deleted the fix/gateway5 branch April 4, 2026 19:16
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