Conversation
There was a problem hiding this comment.
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.pyto collectblock_socas 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_socbehavior 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. |
| if slot_idx == 0: | ||
| block_state_name = state | ||
|
|
||
| if slot_idx < 24: |
There was a problem hiding this comment.
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.
| 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. |
| if slot_idx == 0: | ||
| block_state_name = state | ||
|
|
||
| if slot_idx < 24: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
It's 24 x 30 minute periods which is only 12 hours?
There was a problem hiding this comment.
Ah my bad, so it isn't related to hours but intervals.
No description provided.