Commit Graph

10 Commits

Author SHA1 Message Date
f176cae360 fix: make gaja ssh calls immune to broken system ssh config
Every ssh client call on this box fails with 'Bad owner or permissions'
on /etc/ssh/ssh_config.d (owned by nobody), which silently broke Gaja's
online check on every tick. Pass -F /dev/null so the checks use no
system/user ssh config at all; host key verification via known_hosts is
unaffected.
2026-09-02 20:30:39 +02:00
7071cb7c34 fix: curfew boundary math, HTTP blocking, state file robustness, budget API hardening
- curfew_status: rewrite next-transition calculation to scan up to 7 days
  ahead; old branching showed wrong 'blocked until' for Friday nights
  (assumed next day = weekday schedule) and Sunday nights (off by 2 days).
  Verified against a minute-by-minute reference for a full week: 10080/10080.
- server: ThreadingHTTPServer so slow /status (pings/ssh) no longer blocks
  the TURN OFF button and /budget requests.
- devices: atomic state file writes (tmp + os.replace) and tolerant
  _load_state so a crash mid-write can't silently kill the whole system.
- server: /budget takes _timer_lock (no lost updates vs the budget tick)
  and rejects unknown device ids instead of creating junk state entries.
- status: devices carry an explicit id; web UI keys off it instead of
  parsing titles.
- gabi_check: exact username match (no more 'gabriel' false positives).
- gaja: password readable from GAJA_PASSWORD env var (hardcoded value
  remains as fallback).
- tui: drop unused import.
2026-09-02 20:09:32 +02:00
fdfced6901 fix: reset budgets using state file mtime when server was stopped across the daily reset
The old per-device last_check timestamp was only persisted while a
device was consuming budget, so a stop/restart across days left stale
budgets. Check the state file mtime instead: if it predates today's 7 AM
and we're past 7 AM, the server was offline during the daily reset, so
give every device a fresh budget. Also drops the redundant 2-minute
reset window and the persisted last_check field.
2026-09-02 16:21:47 +02:00
4401b88726 feat: parallelize device shutdown with common _shutdown_devices function
- Curfew and budget exhaustion now use shared _shutdown_devices()
- All device turnoffs run in parallel via ThreadPoolExecutor
- Faster shutdown when multiple devices need to be turned off
2026-06-17 22:23:18 +02:00
2e47aa84f9 feat: complete device management system with float budget tracking, curfew enforcement, TUI, and parallel checks
- Float-based budget tracking with precise elapsed time calculation
- Curfew enforcement (devices turn off when blocked)
- Terminal TUI with live status refresh
- Parallel device checks using ThreadPoolExecutor
- Simplified config with time range format (e.g. '15:00-20:30')
- Optimistic UI updates for budget buttons
- Bug fixes: curfew shutdown, last_check reset on offline
2026-06-16 22:37:48 +02:00
d25104b8a1 Make checking parallel (faster). 2026-06-09 09:36:10 +02:00
0c6e94ef9f Move configuration to config.py 2026-06-09 09:20:49 +02:00
9002cbbe08 Implement curfew. 2026-06-09 09:12:57 +02:00
d3493f50d1 Implementation of the 1 hour budgeting system. 2026-06-09 08:07:45 +02:00
c5b9036644 Move the off.sh script to a pure Python implementation -- devices.py. 2026-06-08 22:59:39 +02:00