Commit Graph
8 Commits
Author SHA1 Message Date
bonaminandClaude Opus 5.5 8029468fb1 feat(api): shared view settings, recent readings, last production run
Groundwork for the dashboard settings page and the five-inverter contract:

- GET/PUT /api/settings stores display options (comparison averaging,
  scale and reference, power chart range and smoothing, voltage display,
  default language) in the meta table. Shared by every viewer since there
  are no accounts; PUT needs the API key so a public visitor can't change
  everyone's view. Unknown keys are ignored, missing ones take defaults.
- /api/summary returns each inverter's last few readings (recent_power) so
  the comparison can average out one reading taken under a passing cloud.
- Offline is now judged per inverter: a couple of missed cycles at the
  unit's own cadence (INV5 is cloud-polled every ~5 min), never below
  ONLINE_WINDOW_SECONDS. Before, INV5 flapped offline between reports.
- /api/power?last_run=true covers the latest production run, split at
  night silences; units reporting 0 W overnight don't join runs.
- Issues carry params so clients can render them in Greek.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 17:59:33 +03:00
bonaminandClaude Opus 5.5 c725b748c7 fix(db): allow a request's SQLite connection to cross threads
FastAPI runs a sync dependency's setup, the endpoint and the teardown on
whichever threadpool worker is free, so a connection opened on one thread
was used/closed on another and sqlite3 raised ProgrammingError — 500s on
/api/power, /api/energy/daily and /api/summary under concurrent requests
(the dashboard fires three at once). Each request still gets its own
connection, used by one thread at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:55:48 +03:00
bonaminandClaude Opus 5.5 42c7d18207 docs: record the verified register map and inverter IDs
P06D is a latched 21450 (not power), P052/P05A static, P063 frozen; power
is computed V*I. Lists what's sent, what isn't, the unmapped diagnostics,
the INV1-INV5 IP assignments, and that timestamps must be real UTC. The
simulator now sends the same payload shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:43:56 +03:00
bonaminandClaude Opus 5.5 d01cef991f feat: match the verified on-site poller payload
The on-site agent found that the DC (P052/P054/P05A/P05C) and energy (P063)
registers are static/frozen and ac_power_total_w is now computed V*I, so
the backend and dashboard have to cope with those fields being absent.

- Feeding/Standby from status_code (FEEDING_STATUS_CODES, default 7 and 8:
  INV1's OEM board uses 7). Online but not feeding = Standby; a standby
  inverter while peers produce is still caught by the underperformance
  check. Missing error_code stays "no fault".
- Daily energy falls back to AC power integrated between readings, flagged
  estimated (≈ in the UI); out-of-order (spooled) readings recompute the
  day. Existing databases get the column and a rebuild on startup.
- Totals are null instead of 0 when there's no energy data; lifetime shows
  "not available yet". Parameters the poller doesn't send are hidden on the
  detail page, DC lines only drawn when DC data exists.
- Timestamps more than 5 min in the future are stored at receive time and
  counted in clamped_future — the example payload carried local Athens time
  labelled +00:00.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:43:55 +03:00
bonaminandClaude Opus 5.5 0b0e4b7d6d docs(poller): test the endpoint with a real inverter id, not TEST
Any id posted becomes a permanent inverter card, and there's no delete yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:02:22 +03:00
bonaminandClaude Opus 5.5 9d41c77668 docs(poller): brief for the agent building the on-site poller
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:02:12 +03:00
bonaminandClaude Opus 5.5 b5c7663fd7 fix(deploy): run deploy-host.sh from its own checkout, any clone path
The hard-coded /home/bonamin/refusol-datalogger didn't match the real
clone (repo is refusol-datalogging). README clone URL updated too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:53:54 +03:00
bonaminandClaude Opus 5.5 d4b584e364 feat: solar inverter monitor — FastAPI + SQLite backend, React PWA dashboard
Monitoring for the Refusol 020K inverters. The on-site poller POSTs each
60 s cycle to /api/readings; the dashboard answers first whether every
inverter is operating and whether one is producing far less than its peers
(string fuse / breaker problems).

- Backend: FastAPI + SQLite. Parameters defined once in fields.py (columns
  auto-added on start); unknown poller keys are kept in `extra` since the
  parameter map is still being researched. Idempotent ingest, daily energy
  rollup in site-local days, history downsampling, 2-year retention.
- Health: Offline vs Sleeping (sun elevation) vs No data (datalogger
  silent, detected via empty-batch heartbeats), Fault from error_code,
  underperformance vs fleet median (per kWp when sizes set), MPPT imbalance.
- Frontend: mobile-first React + Tailwind, installable PWA, comparison bars,
  24 h power / 30 day energy charts, detail page with all parameters.
- Docker: backend + frontend + nginx on one port for NPM, as in
  bellsystems-cp; deploy-host.sh pulls main and rebuilds.
- poller/backend_client.py: stdlib client with offline spool for
  refusol_poller.py; fake_poller.py simulates the site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 07:42:48 +03:00