Skip to content

Fix plan slot durations and split-state rendering - #5

Merged
mimikm merged 3 commits into
mimikm:mainfrom
graememorgan:fix-plan-slots-and-split-states
Oct 30, 2026
Merged

mimikm merged 3 commits into
mimikm:mainfrom
graememorgan:fix-plan-slots-and-split-states

Conversation

@graememorgan

Copy link
Copy Markdown
Contributor

I noticed that some slots which should occupy the full 30 minutes were occasionally being shortened to 20 minutes or so. This happened when a short initial slot caused the card to infer an incorrect slot duration. This PR fixes the issue by using the start time of the next slot as the end time, rather than relying on that inference (except for the final slot, which still requires some guesswork).

I've also added better support for split-state slots. Where Predbat provides an explicit transition time, the card uses it. Where a slot contains both charging and exporting without a specified transition time, it's displayed as a hatched region rather than assuming an arbitrary division:

image

@mimikm

mimikm commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Hi @graememorgan, thanks a lot for this, nice work!
The slot length fix is spot on, and the split slots and hatching look great. A few things before I merge:

  1. Split time is ignored outside UTC (needs fixing)

Predbat writes split_time in its own local clock time (the timezone set in apps.yaml), the same clock as each row's time. The PR compares it against the slot's UTC hour, so the split only will work when local time is the same as UTC i believe.

I tested a slot that splits

  • Europe/London (winter): splits correctly
  • Europe/Warsaw: no split, the whole slot shows as Export
  • America/New_York: no split, the whole slot shows as Export

UK users would also lose it every summer during BST. The slot's start time needs to be taken in Predbat local clock, for example from the row's own time text, rather than UTC.

  1. New text isn't translated
    The card is translated into English, Polish and Spanish, but "Charge + Export (mixed)", the mixed-slot tooltip and "Hold for car" are written straight into the code in English. Polish and Spanish users would see English there. Please add them as translation keys and use t() like the rest of the card, in all three languages if you can. If not, English only is fine and I'll add the other two.

  2. Tidy-up

  • A few lines in _planBands are indented one space too many.
  • Please leave CARD_VERSION and the README as they are. I'll bump the version and credit you in the release note.

Thanks again! Let me know how do you want to approach it.
Dom

@mimikm
mimikm merged commit 81197b9 into mimikm:main Oct 30, 2026
2 checks passed
mimikm pushed a commit that referenced this pull request Oct 30, 2026
@graememorgan

Copy link
Copy Markdown
Contributor Author

Ah, I meant to reply! Thanks for the detailed review. :)

That timezone issue is vexing. It's a shame JS doesn't have any super-easy-to-use libraries for civil time calculations. I've used Temporal for it in the past, and would not describe it as easy.

@mimikm

mimikm commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thank you Sir! New version has just been released. Full credit to You for this one.
Regards
Dom

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.

2 participants