Repository navigation
Conversation
Frontend-only prototype of the planned schedule tile; the backend simulation and the /forecast/schedule endpoint follow separately. - 25 hour boxes (current hour + 24), mode colours: grid charge amber, discharge blocked red, charge limited turquoise, discharge green. - Two views: marker (majority, tie to the more important mode, bar for a more important mode that lost) on phones, quarters (four stripes per hour) on desktops. A resize across the 820 px breakpoint switches the view; a view picked by hand is remembered per width class. - Popover per hour with the four quarters (mouse and tap), SoC line above the boxes, "plan until" marker at the end of the forecast, hours with less than 4 h lookahead dimmed. - fixtures/schedule.js generates the plan around the current local time; scenarios schedule-short-horizon and schedule-startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Changes are needed because the review evidence identifies an unresolved moderate compatibility issue with MediaQueryList change listeners lacking an addListener/removeListener fallback, alongside smaller maintainability and ASCII-convention nits in the schedule time calculations and template output.
3 open issues
What changed in this PR
Adds a frontend-only prototype of the “Schedule 24h” dashboard tile, backed by generated fixtures and tests, and gated so it stays hidden until the backend schedule endpoint exists.
Changes:
- Implement schedule-to-UI helpers (hour aggregation/boxing, SoC line, quarter details) and integrate optional schedule fetching/normalization.
- Add the new
SchedulePanelcomponent with responsive marker/quarters variants and per-hour popover details. - Introduce generator-driven schedule fixtures (plus scenarios) and unit/component test coverage.
| File | Description |
|---|---|
| frontend/vite.fixtures.js | Adds support for generating and serving forecast/schedule fixture data via a $generate: "schedule" entry in the Vite fixtures dev server. |
| frontend/src/lib/schedule.test.js | Introduces unit tests covering schedule aggregation, hour-box logic, SoC line generation, and quarter-detail formatting behavior. |
| frontend/src/lib/schedule.js | Implements schedule transformation utilities used by the UI, including hour aggregation/boxing, SoC polyline computation, and per-quarter detail formatting. |
| frontend/src/lib/api.test.js | Updates API-layer tests to mirror dev fixture behavior by generating schedule responses when fixtures request $generate: "schedule". |
| frontend/src/lib/api.js | Wires optional schedule fetching and normalization into the frontend API layer so schedule data can be consumed when present. |
| frontend/src/components/SchedulePanel.vue | Adds the Schedule 24h tile component UI, including responsive marker/quarters rendering, horizon markers/dimming, and a per-hour popover with quarter details. |
| frontend/src/components/SchedulePanel.test.js | Adds component tests for variant selection defaults and persistence across breakpoint changes. |
| frontend/src/App.vue | Integrates the schedule panel into the app layout and gates rendering so it remains hidden until schedule data is available. |
| frontend/fixtures/schedule.js | Adds a synthetic schedule generator that produces a realistic-looking schedule around the current local time for fixtures and tests. |
| frontend/fixtures/schedule-startup.json | Adds a fixture scenario representing a mid-hour startup with an active override note for UI verification. |
| frontend/fixtures/schedule-short-horizon.json | Adds a fixture scenario with a shortened forecast horizon to exercise end-of-plan UI behavior. |
| frontend/fixtures/README.md | Documents how to run and use the new schedule fixtures and generator-driven scenarios. |
| frontend/fixtures/default.json | Extends the default fixture configuration to include a generated forecast/schedule response entry. |
Review effort: Balanced (adaptive)
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
…ouch) From a local review of #528: - hourStart() works from the instant: setMinutes(0) resolved the repeated hour at the end of DST to its first occurrence, so box 0 was the hour already past and the plan reached only 23.5 h ahead. Same fix in the fixture generator. - A schedule payload without a slot list is "no plan" instead of an exception in normalize() that marked every tile stale. - The popover is keyed by the start of the hour, not by the box position, so it no longer jumps to the next hour on the hour; Escape and an outside click also close a hover preview. - Touch: the whole column of an hour is the target (about 10 x 80 px instead of 10 x 26), a tap pins it, dragging a finger scrubs across the hours. Keyboard still works through the box buttons. - No NaN for an empty schedule, the "plan until" line only inside the chart, SoC line starts at soc_start_percent (fallback: derived from the energy, never off the chart without a capacity). - Quarters bucketed by position (60-minute slots fill four quarters, millisecond jitter is tolerated). - aria-expanded/aria-controls, labels with every planned mode per hour. - ?variant= and ?open= only on the dev server; dead "no schedule yet" branch removed. - Tests: DST and 30/45-minute zones, malformed payloads, 404 on today's backend, popover open/close/rollover, touch, storage errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
A moderate accessibility issue remains in SchedulePanel.vue where aria-controls is always bound to popId even when the popover isn’t rendered or the box isn’t expanded, leading to potentially incorrect assistive-technology relationships that should be fixed before approval.
4 open issues
Review effort: Balanced (adaptive)
New schedule_simulation.py: from the current SoC, every upcoming slot runs through the default logic (a fresh instance per slot, fed with the remaining forecast from that slot on); the decided mode moves the slot's energy on an ideal battery within MIN/MAX SoC. The plan covers the current hour plus 24 and keeps the past quarters of the current hour as planned. Isolation from the control loop: - The cycle publishes one frozen ScheduleInputs under the control lock; the simulation reads only that object - no inverter, no lock. - Each logic instance gets a private CommonLogic copy (new optional `common` argument of DefaultLogic / Logic.create_logic), so the loop's singleton is never written from the scheduler thread. - The DecisionTrace is discarded: no journal entry, no MQTT. - Logic log output is filtered on the simulating thread only. - Active interventions (API mode, evcc block / peak shaving suspension, grid charge lock) are ignored and named in `overrides`. core.py builds the logic parameters in one place for the cycle and the preview, and the scheduler recomputes the plan on every new quarter hour. A failing simulation is logged and keeps the last plan. About 25 ms per plan on a desktop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- REST /api/v1/schedule and MCP batcontrol_get_schedule through
service.schedule(): per slot mode, SoC at start and end, battery and
grid energy in Wh, charge rate / PV limit in W, lookahead in hours;
503 before the first plan and once every slot has passed. Not on
MQTT (maintainer decision).
- /schedule instead of /forecast/schedule, which the existing
/forecast/{series} route would have answered with not_found.
- Dashboard reads the real contract: `_wh` field names, overrides as a
list ("preview ignores: API mode"), the SoC line starts each slot at
its reported soc_start_percent and breaks where the plan jumps from
the planned past quarters to the real SoC.
- Fixture generator emits the API shape (checked field by field against
the Pydantic models).
- Docs: dashboard tile, REST and MCP references, dashboard and MCP
specs, threading model.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The change is blocked by an unresolved moderate bug where refresh_schedule_plan() can clobber the existing schedule_plan with None when the forecast expires (breaking the documented behavior and causing incorrect API status), alongside several ASCII-only policy violations from non-ASCII characters in frontend and schedule strings.
7 open issues
Keep last schedule plan when simulation returns None · New aria-controls is set even when popover is collapsed Add legacy addListener fallback for MediaQueryList Replace non-ASCII arrow in CSS comment · New Replace non-ASCII bullet in user-visible string · New Use ASCII hyphen for the time range Make the PV sampling offset explicit
Review effort: Balanced (adaptive)
- Keep the last plan when the simulation has nothing to plan with (e.g. the forecast ran out), so the API reports forecast_expired instead of no_data_yet. Regression test. - MediaQueryList: fall back to addListener/removeListener (Safari < 14). - aria-controls only on the expanded hour box. - Fixture generator: the PV sampling offset is a named slot middle. - docs/assets/dashboard.png shows the SCHEDULE 24H tile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
A source-level guideline violation remains in SchedulePanel.vue where a UI string contains a non-ASCII en dash, which must be replaced with an ASCII hyphen to comply with the repo’s ASCII-only requirement.
No open issues 🎉
7 resolved since last review
Keep last schedule plan when simulation returns None aria-controls is set even when popover is collapsed Add legacy addListener fallback for MediaQueryList Replace non-ASCII bullet in user-visible string Replace non-ASCII arrow in CSS comment Use ASCII hyphen for the time range Make the PV sampling offset explicit
Review effort: Max (adaptive)
…er hours - log_everything: false now also raises `mcp` (and everything below it, one INFO line per MCP request) and `sse_starlette.sse` to WARNING. The list moved into NOISY_LOGGERS / quiet_noisy_loggers() in __main__.py; template comment and docs list every logger. - The schedule preview ran as a job every minute that only computed on a new quarter hour, writing two INFO lines per minute. It is now four hourly jobs at :00/:15/:30/:45 plus a startup job that retries every 10 s until the first plan exists and then drops itself. New scheduler helpers schedule_hourly_at() and schedule_until_done() log their runs at debug level only. - A computed plan is logged at debug level (slot count, plan end). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request due to rate limiting. Please try again later. See Usage limits for GitHub Copilot for details.
There was a problem hiding this comment.
Copilot was unable to review this pull request due to rate limiting. Please try again later. See Usage limits for GitHub Copilot for details.



Summary
What batcontrol is expected to do over the next 24 hours - as a dashboard tile, a REST endpoint and an MCP tool (feature F-01). The plan is computed by running the real logic once per upcoming slot, starting from the current SoC.
Simulation (
schedule_simulation.py)schedule_hourly_at()/schedule_until_done(), runs logged at debug level only). About 25 ms per plan on a desktop.Isolation from the control loop (the key requirement):
ScheduleInputsunder the control lock. The simulation reads only that object: no inverter, no control lock.CommonLogiccopy (new optionalcommonargument), so the singleton is never written from another thread.overrides.core.pybuilds the logic parameters in one place for the cycle and the preview, so the preview cannot drift from what the loop decides with.API
GET /api/v1/scheduleand the MCP toolbatcontrol_get_schedule, both throughservice.schedule(). Per slot: mode, SoC at start and end, battery and grid energy in Wh, charge rate or PV limit in W,lookahead_hours.no_data_yetbefore the first plan andforecast_expiredonce every slot has passed./schedule, not/forecast/schedule: the existing/forecast/{series}route would have answered that path withnot_found.Dashboard tile "SCHEDULE 24H"
marker, the default on phones: majority mode, a tie goes to the more important mode, and a bar marks a more important mode that lost.quarters, the default on desktops: four stripes per hour.Logging
log_everything: falsenow also quietsmcp(and allmcp.*loggers, one INFO line per MCP request) andsse_starlette.sseto WARNING. The list lives inNOISY_LOGGERSin__main__.py; the config template comment and docs name every logger.Local review fixes (in this PR)
Test plan
pytest: 2951 passed. New:test_schedule_simulation.py(plan window, energy balance, SoC limits, grid charge clamp, isolation from CommonLogic, journal, inverter and log; core wiring; grid lock and API mode ignored),web/test_schedule_api.py(REST, MCP, 503 cases)npm test: 128 passed, also under TZ St. John's, Kathmandu, Chatham, UTC (DST and 30/45-minute offsets)schedule_simulation.py10/10, package 9.74 (was 9.73)mkdocs build --strict,npm run buildincl. offline checkpython -m batcontrolwith the dummy inverter and the API enabled./api/v1/schedulereturns 56 slots up to midnight (morning, no day-ahead prices yet). The dashboard renders it at 390 px and 1100 px. No logic log lines from the 56 simulated runs.🤖 Generated with Claude Code