Departure standby sweep with a 12-device check list
When the last person leaves, a 45-second sweep walks a fixed list of twelve devices, turns off what should be off, and refuses to touch the freezer, the router or the server shelf. Reports back one summary notification instead of twelve.
# HearthNodes recipe 03 - departure standby sweep
alias: "Presence - departure standby sweep"
id: hn_presence_departure_sweep
description: "Last person out -> 45 s parallel sweep of 12 devices, one summary"
mode: single
max_exceeded: silent
trigger:
- platform: numeric_state
entity_id: zone.home
below: 1
for: "00:05:00"
id: zone_empty
- platform: state
entity_id: binary_sensor.front_door_contact
to: "off"
for: "00:10:00"
id: door_clue
variables:
protected:
- switch.fridge_circuit
- switch.router_shelf
- switch.nas
- switch.server_rack
- switch.aquarium_pump
swept:
- media_player.living_tv
- media_player.kitchen_display
- light.decorative_*
- light.tv_backlight
- light.desk_lamp
- switch.printer_shelf
- switch.3d_printer
- switch.coffee_bar
- climate.living
- climate.study
- fan.bath_extract
- light.garage
condition:
- condition: template
value_template: "{{ states('sensor.arriving_soon') | int(0) == 0 }}"
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
- condition: state
entity_id: calendar.tradesperson_visit
state: "off"
action:
- service: script.standby_sweep
data:
devices: "{{ swept }}"
excluded: "{{ protected }}"
per_device_timeout_s: 8
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.forecast_overnight_min
above: 4
sequence:
- service: climate.set_preset_mode
target:
entity_id: climate.living
data:
preset_mode: eco
- service: notify.mobile_app_primary
data:
title: "Standby sweep"
message: >-
{{ states('sensor.sweep_summary') }} / unconfirmed:
{{ states('sensor.sweep_unconfirmed') }}
# Confirmation is by wattage, not by command acceptance: a plug reporting under
# 3 W twenty seconds later counts as off. Failures are named, never retried in a
# loop. Sweep result is also written to a local file if notify is unavailable.
Trigger · state
zone.home
Home zone occupant count drops to 0 and stays there for 5 minutes.
Step-by-step
- script.standby_sweepRun the twelve-device sweep in parallel with a per-device 8 s timeout so one dead node cannot stall the whole sweep.
run · mode parallel · max 12 devices - media_player.* · light.* (excluded list)Turn off all media players, decorative lights and the TV backlight; the exclude list keeps the fridge circuit, router, NAS and 3D-printer shelf untouched.
turn_off - climate.*Drop thermostats to eco only if the outdoor forecast low is above 4 °C; below that the sweep leaves heating alone to protect pipes.
set_preset_mode eco - notify.mobile_app_primarySend one notification listing how many devices were switched off and which ones failed to confirm.
send · title 'Standby sweep' · message {{ sweep_summary }}
Build the exclude list before the include list
Write down the devices that must never be swept — fridge, freezer, router, NAS, server shelf, aquarium pump, medical equipment — and put them in an explicit exclude block. A sweep that turns off the router is the single fastest way to lose the household's trust in the whole system.
Confirm with power, not with hope
A Zigbee command returning success means the packet was accepted, not that the appliance stopped drawing current. Read the plug's wattage 20 s later and only count the device as off when the reading is under 3 W. This is also how you catch a TV that 'turned off' into a standby state drawing 40 W.
Give the sweep a 5-minute confirmation delay
Firing immediately when the zone empties means the cleaner who popped out to the bins triggers a full shutdown. Five minutes of dwell plus the arriving-soon check removes almost all of those. Log the false departures for two weeks and tune from the log, not from intuition.
Hardware
| Model | Protocol | Link | Role in this chain |
|---|---|---|---|
| Sonoff SNZB-04P door contact | zigbee |
wireless | Front door contact that supplies the departure-direction clue. |
| Third Reality Smart Plug Gen 2 (Zigbee) | zigbee |
wireless | Power monitoring plugs on the TV, desk and printer shelf; the sweep uses their reported wattage to confirm the device really went off. |
| Zigbee coordinator with mains-powered routers (e.g. a Zigbee smart plug per room) | zigbee |
wired | A mains-powered router in every room keeps the sweep from timing out on the far end of the house. |
When it fails
Any device that does not confirm off within 8 s is retried once; if it still fails, the sweep marks it in the notification and leaves it alone rather than retrying in a loop. If the notification channel is down, the sweep result is written to a local text file so the weekly audit still sees it.