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
This commit is contained in:
34
config.py
34
config.py
@ -1,13 +1,29 @@
|
||||
"""Application configuration."""
|
||||
|
||||
# ── Budget ────────────────────────────────────────────────────────────
|
||||
BUDGET_S = 3600 # default 60 min in seconds
|
||||
# ═══════════════════════════════════════════════════════════════════════
|
||||
# CONFIGURATION — Edit these values to change behavior
|
||||
# ═══════════════════════════════════════════════════════════════════════
|
||||
|
||||
# ── Timer ─────────────────────────────────────────────────────────────
|
||||
TICK_INTERVAL = 10 # seconds between budget check cycles
|
||||
BUDGET_S = 3600 # default 60 min per device (in seconds)
|
||||
TICK_INTERVAL = 10 # seconds between budget check cycles
|
||||
ALLOWED_WEEKDAY = "7:00-23:30" # Mon-Fri allowed hours
|
||||
ALLOWED_WEEKEND = "7:00-20:30" # Sat-Sun allowed hours
|
||||
|
||||
# ── Allowed device hours (curfew) ─────────────────────────────────────
|
||||
ALLOWED_WEEKDAY_START = 15 # Mon-Fri start hour
|
||||
ALLOWED_WEEKDAY_END = 20 # Mon-Fri end hour
|
||||
ALLOWED_WEEKEND_START = 8 # Sat-Sun start hour
|
||||
ALLOWED_END_MINUTE = 30 # End minute (all days)
|
||||
# ═══════════════════════════════════════════════════════════════════════
|
||||
|
||||
|
||||
def _parse_time_range(time_str: str) -> tuple[int, int]:
|
||||
"""Parse a time range string like '15:00-20:30' into (start_minutes, end_minutes).
|
||||
|
||||
Returns minutes since midnight for start and end times.
|
||||
"""
|
||||
start_str, end_str = time_str.split("-")
|
||||
sh, sm = map(int, start_str.split(":"))
|
||||
eh, em = map(int, end_str.split(":"))
|
||||
return sh * 60 + sm, eh * 60 + em
|
||||
|
||||
|
||||
# ── Parsed values (do not edit) ──────────────────────────────────────
|
||||
|
||||
WEEKDAY_START, WEEKDAY_END = _parse_time_range(ALLOWED_WEEKDAY)
|
||||
WEEKEND_START, WEEKEND_END = _parse_time_range(ALLOWED_WEEKEND)
|
||||
|
||||
Reference in New Issue
Block a user