mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-07-04 15:23:03 +02:00
- Add python-kasa-based smart-plug control (_smart_plug.py) with turn_on_plug / turn_off_plug called around the alarm window. Reads ~/.config/wake_alarm/tapo.json (host/email/password). - Hard timeout (TAPO_TIMEOUT_SECONDS) so plug never blocks the alarm. - Install fan-control script + sudoers entry (install.sh step 6); _max_fans / _restore_fans now invoke it via /usr/bin/sudo -n so pwm1_enable writes succeed. - Remove ntfy.sh push notifications entirely (silent no-op was useless). - Replace every silent skip with _logger.warning() so failures are loud: missing xset / xrandr / speaker-test, unreadable hwmon files, fan script errors, missing Tapo config, kasa import failure, etc. - wake-alarm.service: Restart=on-failure with 10s backoff. - Tests: 100% line+branch coverage on python_pkg/wake_alarm.
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
"""Constants for the weekend wake alarm system."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
# Days the wake alarm is active (Python weekday(): Mon=0 ... Sun=6)
|
|
# Monday, Friday, Saturday, Sunday
|
|
ALARM_DAYS: frozenset[int] = frozenset({0, 4, 5, 6})
|
|
|
|
# How many hours after shutdown the PC should wake
|
|
WAKE_AFTER_HOURS: int = 8
|
|
|
|
# Minutes after alarm starts within which you must dismiss to earn skip
|
|
DISMISS_WINDOW_MINUTES: int = 30
|
|
|
|
# Hour at which the second (fallback) alarm fires if the first was missed
|
|
FALLBACK_ALARM_HOUR: int = 13
|
|
|
|
# Alarm escalation phase boundaries (minutes from alarm start)
|
|
PHASE_SOFT_END: int = 5
|
|
PHASE_MEDIUM_END: int = 15
|
|
# After PHASE_MEDIUM_END: continuous sine tone until dismiss window closes
|
|
|
|
# Beep intervals per phase (seconds)
|
|
SOFT_BEEP_INTERVAL: float = 10.0
|
|
MEDIUM_BEEP_INTERVAL: float = 5.0
|
|
LOUD_TOGGLE_INTERVAL: float = 2.0
|
|
|
|
# Dismiss challenge: length of the random code
|
|
DISMISS_CODE_LENGTH: int = 6
|
|
# How often the dismiss code refreshes (seconds)
|
|
DISMISS_CODE_REFRESH_SECONDS: int = 30
|
|
|
|
# State file for wake alarm (HMAC-signed)
|
|
WAKE_STATE_FILE: Path = Path(__file__).resolve().parent / "wake_state.json"
|
|
|
|
# rtcwake binary path
|
|
RTCWAKE_BIN: str = "/usr/sbin/rtcwake"
|
|
|
|
# TP-Link Tapo P110 smart-plug config file (JSON).
|
|
# Create with mode 0600 and these keys: host, email, password.
|
|
# Example contents: a JSON object mapping host -> "192.168.x.x", email ->
|
|
# "tapo@example.com" and password -> "your-password".
|
|
# Missing/invalid file => smart-plug control is skipped silently.
|
|
TAPO_CONFIG_FILE: Path = Path.home() / ".config" / "wake_alarm" / "tapo.json"
|
|
|
|
# Timeout (seconds) for a single Tapo plug operation. Keep short so a
|
|
# missing/unreachable plug never delays the alarm by more than this.
|
|
TAPO_TIMEOUT_SECONDS: float = 5.0
|