- 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
30 lines
1.6 KiB
Python
30 lines
1.6 KiB
Python
"""Application configuration."""
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════
|
|
# CONFIGURATION — Edit these values to change behavior
|
|
# ═══════════════════════════════════════════════════════════════════════
|
|
|
|
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
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════
|
|
|
|
|
|
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)
|