tliu93
4284bd40a7
M6-T04: add EnergyContract CRUD + versions + profile validation API
...
- app/services/contracts.py: create_contract, add_version (append-only,
auto-closes prior version), activate_contract (mutex), and
active_contract_version_at (half-open [from, to)) for the billing engine.
- app/schemas/energy_contract.py + routes/api/energy_contracts.py: 6 endpoints
(GET/POST contracts, GET/PATCH contracts/{id}, POST .../versions, GET profiles).
Values validated against pricing profiles (422 on mismatch); no DELETE.
- main.py registers router; OpenAPI re-exported; tests for CRUD/version/activate.
2026-06-23 21:19:25 +02:00
tliu93
45d87f36f7
M5-T12: add expose toggle API and Home Assistant Expose settings panel
2026-06-22 15:50:49 +02:00
tliu93
9d05f5ea62
M5-T10: add paho MQTT client with lifespan connect/reconnect and mqtt/test endpoint
2026-06-22 15:06:30 +02:00
tliu93
68165f0e01
M5-T07: add latest-reading cards and Recharts trend charts; readings return most-recent rows
2026-06-22 14:17:59 +02:00
tliu93
702a1cec00
M5-T05: add Modbus JSON API (device CRUD, readings, metrics, test)
2026-06-22 13:37:48 +02:00
tliu93
81bd32f613
M4-T06: add TOTP second factor to login (totp_code + recovery codes)
2026-06-21 22:08:55 +02:00
tliu93
ee3031013e
M4-T05: add TOTP service and setup/enable/disable/status API
2026-06-21 21:55:17 +02:00
tliu93
e480a84a44
M4-T02: add exponential login back-off service and wire into login endpoint
2026-06-21 21:20:28 +02:00
tliu93
a9830c42d8
M2-T11: serve React SPA from FastAPI and remove Jinja pages
...
- app/main.py serves the SPA build (SPA_DIST_DIR, default frontend/dist):
mounts /assets and a GET catch-all returning index.html for client routes;
catch-all 404s on /api/*, never swallows /docs, /openapi.json, /static, assets,
ingestion/ticktick/status; skips SPA serving when dist absent (backend-only CI)
- delete app/api/routes/pages.py, app/api/routes/auth.py, app/templates/
(all replaced by /api/* + SPA; auth service layer kept)
- remove/replace Jinja page tests (JSON coverage already in test_api_*);
add tests/test_spa_hosting.py for the fallback contract
- regenerate openapi/ (Jinja paths gone) and frontend schema.d.ts
2026-06-13 15:20:50 +02:00
tliu93
2bc5d6ea9a
M2-T05: add SMTP test action API (POST /api/config/smtp/test)
...
- reuses send_smtp_test_email; tri-state result success(200)/config-error(400)/failed(502)
- session + CSRF protected; never echoes SMTP secrets
- SmtpTestResponse schema; regenerate openapi/
- extend tests/test_api_config.py (3 states + 401 + missing-CSRF 403)
2026-06-13 15:20:50 +02:00
tliu93
048414c5cb
M2-T04: add single-row record CRUD API (patch/delete)
...
- PATCH/DELETE /api/locations/{person}/{datetime} and /api/poo/{timestamp}
- update only non-PK fields (PK immutable); 404 on missing PK
- delete scoped to exact full PK with rowcount guard (0->404, 1->ok);
no batch/truncate/drop path
- session + CSRF protected; bare ingestion endpoints untouched
- service helpers in app/services/location.py and poo.py; regenerate openapi/
- tests/test_api_record_crud.py
2026-06-12 23:33:08 +02:00
tliu93
0fba7cfe11
M2-T03: add read-only data JSON API
...
- GET /api/locations (inclusive time window start/end, pagination, cap 5000)
- GET /api/poo (pagination, cap 1000, newest first)
- GET /api/public-ip (current state + recent history, cap 1000)
- all session-protected, read-only, bounded (no full-table export)
- typed response schemas; register router; regenerate openapi/
- tests/test_api_data.py
2026-06-12 23:24:17 +02:00
tliu93
8da1f13e60
M2-T02: add session/auth JSON API for the SPA
...
- GET /api/session (user + csrf_token, 401 when unauthenticated)
- POST /api/auth/login (sets HttpOnly session cookie; 401 on bad creds; no CSRF)
- POST /api/auth/logout (session+CSRF; revokes session, clears cookie; 204)
- POST /api/auth/password (session+CSRF; reuses change_password; 400 on failure; 204)
- reuses app/services/auth.py and shared require_session/require_csrf deps
- register router in app/main.py; regenerate openapi/
- tests/test_api_session.py
2026-06-12 23:15:56 +02:00
tliu93
c2b1b7b751
M2-T01: add config JSON API (GET/PUT /api/config)
...
- new app/api/routes/api/ package with shared require_session (401) and
require_csrf (presence-only X-CSRF-Token, 403) dependencies
- GET /api/config returns masked config sections; PUT /api/config reuses
save_config_updates (blank secret keeps old; invalid -> 422, no write)
- session-protected; PUT also CSRF-protected
- register router in app/main.py; regenerate openapi/
- tests/test_api_config.py
2026-06-12 23:08:14 +02:00
tliu93
2f634006d2
M1-T07: align docs to single-DB reality and re-export OpenAPI
...
Rewrite README (single app.db + one alembic_app chain, legacy data moved
once via scripts.migrate_legacy_data, accurate test list) and remove the
Grafana Provisioning section. Update architecture-overview to the unified
data layer (one Base, app-DB engine with WAL) and retire the
alembic_location / alembic_poo sections. Mark M1 done in the roadmap.
Re-export openapi/, which catches the spec up to the already-existing
/config/smtp/test and /public-ip/check endpoints (purely additive; M1's
DB-session dependency swap produced no schema change).
pytest 95 passed; ruff clean (pre-existing only); OpenAPI export idempotent.
2026-06-12 17:13:28 +02:00
tliu93
1805d5d8ea
Finalize first Python release
pytest / test (push) Successful in 40s
pytest / test (pull_request) Successful in 41s
2026-04-20 20:40:04 +02:00
tliu93
179aae264e
Persist runtime config in app db and seed from env
2026-04-20 15:56:10 +02:00
tliu93
e1aad408ab
Add auth foundation and app DB management
2026-04-20 15:16:47 +02:00
tliu93
044b47c573
Migrate poo recorder and align Alembic naming
2026-04-20 11:48:48 +02:00
tliu93
e334df992f
Add Home Assistant inbound gateway
2026-04-20 10:42:35 +02:00
tliu93
eb487ccb46
Track exported OpenAPI schema
2026-04-19 23:25:13 +02:00