Initial Home Assistant observer

This commit is contained in:
hbrain 2026-05-16 08:02:01 +00:00
commit 325917c09b
8 changed files with 624 additions and 0 deletions

20
install_cron.sh Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
CRON_FILE="$(mktemp)"
crontab -l 2>/dev/null | grep -v "# ha-observer" | grep -v "$PROJECT_DIR/run_ha_observer.sh" > "$CRON_FILE" || true
cat >> "$CRON_FILE" <<EOF
# ha-observer: collect Home Assistant snapshots every 30 minutes
*/30 * * * * $PROJECT_DIR/run_ha_observer.sh collect >> $PROJECT_DIR/cron.log 2>&1
# ha-observer: at 05:00 send recent snapshots to AI and publish funny local webpage
0 5 * * * $PROJECT_DIR/run_ha_observer.sh analyze >> $PROJECT_DIR/cron.log 2>&1
EOF
crontab "$CRON_FILE"
rm -f "$CRON_FILE"
echo "Installed cron jobs:"
crontab -l | grep -A2 "ha-observer"