fix home manager crons

This commit is contained in:
Roger Oriol
2026-07-25 20:03:16 +02:00
parent 842815d370
commit 8caf49fdf6
2 changed files with 27 additions and 25 deletions

View File

@@ -100,7 +100,9 @@ Docs: https://hermes-agent.nousresearch.com/docs/user-guide/docker
places under `discord:`) with your numeric home channel ID. (Must match the
secret's `DISCORD_HOME_CHANNEL`.)
5. **Tailor `cron-seed.yaml`** schedules/prompts to your actual HA entities
(your sensor names, your `script.goodnight`, etc.).
(your sensor names, your calendars, your todo lists). The default schedule
has 4 jobs (energy anomaly, comfort check, morning briefing, evening
briefing) — adjust thresholds and wording to your setup.
6. **Commit & push** the whole change (including the regenerated
`argocd/apps/home-manager.yaml`). ArgoCD will create the namespace resources,
deploy the pod, and bring up the ingress at `home-manager.rogi.casa`.
@@ -108,11 +110,13 @@ Docs: https://hermes-agent.nousresearch.com/docs/user-guide/docker
automatically on every sync. The hook **reconciles** the cron schedule to
match Git: it deletes + recreates each named job, so prompt/schedule edits
in `cron-seed.yaml` take effect on the next sync (this overwrites any live
`hermes cron edit` changes — edit the prompts in Git instead). To re-run
it by hand: `kubectl apply -f home-manager/cron-seed.yaml`.
`hermes cron edit` changes — edit the prompts in Git instead). The schedule
has exactly 4 jobs: `energy-anomaly` (every 4h), `comfort-check` (every 4h),
`morning-briefing` (08:00 daily), `evening-briefing` (00:00 daily). To
re-run it by hand: `kubectl apply -f home-manager/cron-seed.yaml`.
8. **Smoke test:** trigger a check manually —
`kubectl exec -n home-manager deploy/hermes -- hermes cron run door-window-check`
and confirm the message lands in Discord (or `[SILENT]` if all clear).
`kubectl exec -n home-manager deploy/hermes -- hermes cron run morning-briefing`
and confirm the message lands in Discord.
---

View File

@@ -10,7 +10,12 @@
# cron prompts containing curl+auth-header patterns. The exact HA REST API
# endpoints and examples are documented in the agent's SOUL.md instead.
#
# Tailor the schedules/prompts below to your actual Home Assistant entities.
# Schedule (4 jobs):
# 1. energy-anomaly — every 4h (silent unless power draw is too high)
# 2. comfort-check — every 4h (silent unless a room is out of range)
# 3. morning-briefing — 0 8 * * * (always delivered)
# 4. evening-briefing — 0 0 * * * (always delivered)
# None of these act autonomously on climate/energy — they report and ask Roger.
---
apiVersion: batch/v1
kind: Job
@@ -74,28 +79,21 @@ spec:
kubectl -n home-manager exec "$POD" -- hermes cron create "$schedule" "$prompt" --name "$name" --deliver "$deliver"
}
# ---- Watchdog checks (silent unless something is wrong) ----
create "door-window-check" "every 15m" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. List all door and window sensor entities (binary_sensor.* for doors, windows, contact sensors). If any are open and it is between 23:00 and 06:00, notify Roger with which sensor is open. Note: this HA instance has NO presence sensors configured, so do NOT infer 'nobody is home' from missing/absent presence entities — only treat the house as empty if a real presence entity (zone.home / device_tracker / presence binary_sensor) exists AND reports away/off; otherwise occupancy is unknown and you must assume someone might be home. If all closed, reply with exactly [SILENT]."
# ---- 1. Energy anomaly (every 4h, silent unless too high) ----
create "energy-anomaly" "every 4h" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. Read the current total house power draw sensor (sensor.* power / current_power — your main power clamp). Determine whether it is currently day (06:00 to 23:00) or night (23:00 to 06:00) from the current time. If the power draw exceeds 4000 W during the day, or exceeds 1000 W during the night, report to Roger on Discord: the current reading in watts, the time, whether it is day or night, and which threshold was exceeded. Ask Roger what he wants to do about it. Do NOT turn anything off or change any entity yourself — only report and ask. If power is within the normal range for the time of day, reply with exactly [SILENT]."
create "leak-moisture-check" "every 10m" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. Look for moisture, water leak, or flood sensor entities (binary_sensor.* moisture/water/leak, sensor.* moisture). If any report wet/active, alert Roger immediately with the sensor name and location. If all dry, reply with exactly [SILENT]."
# ---- 2. Temperature & humidity check (every 4h, silent unless out of range) ----
create "comfort-check" "every 4h" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. Read indoor temperature and humidity sensors in each room (sensor.*temperature, sensor.*humidity). Comfortable range: temperature between 18C and 26C, humidity between 30 and 65 percent. For any room that is outside that range, report to Roger on Discord: the room name (entity_id), the reading, and whether it is too high or too low. Ask Roger what he wants to do about it. Do NOT change climate/HVAC, fans, or any entity yourself — only report and ask. If every room is within the comfortable range, reply with exactly [SILENT]."
create "energy-anomaly" "every 30m" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. Read the current power draw sensor (sensor.* power, sensor.* current_power). If the total power draw is unusually high for the time of day (over 4000 W during the day, or over 800 W at night), alert Roger with the reading. Otherwise reply with exactly [SILENT]."
# ---- 3. Morning briefing (daily at 08:00, always delivered) ----
create "morning-briefing" "0 8 * * *" "discord" \
"Produce a morning home briefing for Roger using the Home Assistant REST API as documented in your SOUL.md. Include, in short bullet form: (1) today's calendar events from calendar.* entities for today (time + title); (2) open tasks from todo.* task lists; (3) overnight energy use — total energy consumed overnight from energy / utility_meter sensors, plus the current power draw; (4) outdoor and indoor temperature and humidity, and the current weather from weather.*; (5) occupancy status from zone.home — report its state if it exists; if zone.home is missing or unavailable, state 'occupancy: unknown — zone.home not configured' rather than claiming no one is home; (6) any sensors currently in an alert or unavailable state. Keep the message under 1800 chars. Always deliver (no [SILENT])."
create "comfort-check" "every 1h" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. Read indoor temperature and humidity sensors. If a room is outside a comfortable range (below 18C or above 26C, or humidity above 65 percent), you may toggle a fan entity in that room (safe). Do NOT change climate/HVAC settings yourself — if it is uncomfortable, propose a climate change to Roger on Discord and wait. If everything is comfortable, reply with exactly [SILENT]."
create "left-on-check" "every 1h" "discord" \
"Check the Home Assistant REST API as documented in your SOUL.md. IMPORTANT: this HA instance has NO presence sensors configured. Do NOT infer 'nobody is home' from missing/absent zone.home or presence entities. Only treat the house as empty if a real presence entity (zone.home / device_tracker / presence binary_sensor) exists AND reports away/off. If no such entity exists, occupancy is UNKNOWN — assume someone might be home and do NOT turn things off. Only when presence genuinely reports away/off: find any lights, media players, fans, or non-critical switches that are on, turn off the safe non-essential ones (lights, media, fans), and report what you turned off. Do NOT touch anything security-critical. If someone is home (or unknown), or nothing is left on, reply with exactly [SILENT]."
# ---- Routines (always delivered) ----
create "goodnight-routine" "0 23 * * *" "discord" \
"Run the goodnight routine via the Home Assistant REST API as documented in your SOUL.md. Turn off all non-essential lights and pause media players (safe actions). Then propose — but do NOT execute — locking the doors (lock.*), closing the garage (cover.* garage), and arming the alarm (alarm_control_panel.*). Ask Roger on Discord for confirmation before calling any of those security-critical services. Deliver a short summary of what you turned off and what you are waiting for confirmation on."
create "morning-briefing" "0 7 * * *" "discord" \
"Produce a morning home briefing for Roger using the Home Assistant REST API as documented in your SOUL.md. Include: (1) occupancy status from zone.home / presence sensors IF such entities exist — if they do not exist, state 'presence: no presence sensors configured (occupancy unknown)' rather than claiming no one is home; (2) any lights or media still on, (3) any doors or windows open, (4) indoor temperatures, (5) today's calendar events if a calendar entity exists, (6) overnight energy use if an energy sensor exists, (7) any sensors in an alert/unavailable state. Keep it under 1800 chars. Always deliver (no [SILENT])."
# ---- 4. Evening briefing (daily at midnight, always delivered) ----
create "evening-briefing" "0 0 * * *" "discord" \
"Produce an evening home status report for Roger using the Home Assistant REST API as documented in your SOUL.md. Report on: (1) lights currently turned on (light.* with state 'on'); (2) sockets and switches currently turned on (switch.* with state 'on'); (3) current energy use / power draw; (4) indoor temperature and humidity per room. List the specific entity_ids and their values. Then ask Roger which of the on devices/lights he wants turned off. Do NOT turn anything off yourself — only report and ask. Keep the message under 1800 chars. Always deliver (no [SILENT])."
echo "Done. Listing all cron jobs:"
kubectl -n home-manager exec "$POD" -- hermes cron list