WattPlan is the source of truth for the WattPlan Home Assistant custom integration and its in-repo optimizer. Optimize for clean integration behavior, reliable Home Assistant tests, and release artifacts that stay HACS-compatible. Prefer updating the integration, tests, and docs together when behavior changes.
- Do: treat
WattPlanas the canonical repo andhass-coreas the runtime/test harness via symlink. - Do: keep
custom_components/wattplan/optimizer/free ofhomeassistantimports. - Do: update docs when workflows, release behavior, or architecture changes.
- Don't: edit the backup copies under
hass-core/*/wattplan.pre-symlink-backup-*. - Don't: reintroduce
vendor_poweroptim; the optimizer lives underoptimizer/. - Don't: assume
hass-coreis clean before changing symlinks or running migrations.
- Before starting new projects or automation, evaluate whether the effort is justified and push back if build time exceeds the time it would save.
- If a request would introduce hacks, unclear behavior, or long-term maintenance risk, push back and propose a safer alternative.
- Avoid obvious performance pitfalls; call them out and offer a better approach.
- Prefer clear, simple code over clever or verbose implementations.
- Build:
python scripts/build_hacs_zip.py - Test:
pytest - Run:
PYTHONPATH=. pytest testsorPYTHONPATH=. ../hass-core/.venv/bin/pytest tests - Release: use
docs/release.mdas the authoritative runbook for all release questions, preparation, tag handling, release text, and artifact publication.
- When running pytest from Codex, request elevated execution for each test run instead of using the default sandbox.
- Current issue: Home Assistant pytest bootstrap can hang inside the sandbox, while the same tests complete normally outside it.
- Treat sandboxed pytest hangs as environment noise unless the same failure reproduces in an elevated run.
- At the end state of a code change, especially before committing, run the full test suite unless there is a clear reason not to; if skipping it, state the reason explicitly.
- When this repo is on a mounted or network-backed filesystem, prefer placing Codex-managed test virtualenvs on a native local filesystem under
/tmpinstead of a repo-local.venv;uvinstalls on the mounted path can leave the Home Assistant package incomplete. - The default
./scripts/run_tests.shwrapper already uses worktree-specific paths under/tmpfor both the virtualenv and pytest--basetemp. Reuse that convention for Codex-created envs to avoid collisions across parallel worktrees.
- Integration code lives in
custom_components/wattplan/. - Optimizer code lives in
custom_components/wattplan/optimizer/. - Home Assistant integration tests live in
tests/integration/. - Optimizer-only tests live in
tests/optimizer/. hass-core/config/custom_components/wattplanandhass-core/tests/custom_components/wattplanare symlinks into this repo.- Keep release packaging focused on the integration tree under
custom_components/wattplan/. - The HA integration acquires four planner input series: import price, export price, usage, and PV.
- Each source uses one configured provider mode, then passes through normalization/fixup to produce one value per planner slot before the optimizer runs.
- Keep source acquisition behavior centered in
source_pipeline.py,source_provider.py,source_fixup.py, andcoordinator.py; preserve the rule thatoptimizer/stays free ofhomeassistantimports.
README.md— keep quickstart, release flow, and repo purpose aligned with the current structuredocs/development.md— update when local workflow, symlink setup, or test commands changedocs/architecture.md— update when code boundaries or planning/runtime flow changesdocs/release.md— update when tag, prerelease, or artifact behavior changesdocs/optimizer-api.md— update when optimizer import paths or request/response models change
If this file grows beyond a page, or if the repo has distinct task areas (for example docs/release vs integration/runtime), ask whether to split into AGENTS.<TASK>.md files.