Files
off/config.py
Mitja Horvat 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

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-20: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)