# Analytics snippet placeholder — HearthNodes (gatherer.top) # Paste the measurement snippet here (server.js inlines any content that contains # a markup tag into on every page). No GA4 property is assigned to this # site yet, so leave this file as comments only and the build emits no tracking # code.
HearthNodesgatherer.top 已发布 11/28 EN 中文

离家待机清扫:12 台设备的逐项确认

最后一个人离开后,用 45 秒按固定清单逐一检查十二台设备,关闭该关的,绝不动冰箱、路由器和服务器机架。最后只推一条汇总通知,而不是十二条。

协议 · zigbee 延迟 · 45000 ms 供电 · mains 发布 · 2026-09-21 3 devices
自动化 YAML presence-departure-standby-sweep.yaml
# 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.
触发器 · state

zone.home

住宅区域人数降为 0,并持续 5 分钟。

离家待机清扫:12 台设备的逐项确认 topology

分步说明

  1. script.standby_sweep以并行方式执行十二台设备的清扫,每台 8 秒超时,避免一个离线节点卡住整轮清扫。 run · mode parallel · max 12 devices
  2. media_player.* · light.* (excluded list)关闭所有播放器、装饰灯和电视背光;排除清单保留冰箱回路、路由器、NAS 和 3D 打印机机架不受影响。 turn_off
  3. climate.*仅当室外预报最低温高于 4 °C 时才把温控器切到节能模式;低于该值则不动供暖,以保护管路。 set_preset_mode eco
  4. notify.mobile_app_primary只发送一条通知,列出关闭了几台设备以及哪些设备未能确认。 send · title 'Standby sweep' · message {{ sweep_summary }}
分步说明
先写排除清单,再写包含清单

先把绝不能清扫的设备列出来——冰箱、冷柜、路由器、NAS、服务器机架、鱼缸水泵、医疗设备——写进显式的排除块。把路由器关掉,是让全家人最快丧失对整套系统信任的方式。

用功率确认,而不是凭希望

Zigbee 命令返回成功只代表数据包被接收,不代表电器停止了耗电。20 秒后再读插座功率,只有低于 3 W 才计入「已关闭」。这也能抓出那种「关了」却进入 40 W 待机状态的电视。

给清扫加 5 分钟确认延迟

区域一空就立刻执行,意味着只是下楼扔垃圾的保洁也会触发整轮关闭。5 分钟驻留判断加「即将到家」检查能消除绝大部分误触发。记录两周内的误报离家,依据日志调参,不要凭感觉。

硬件

型号协议连接在本链路中的作用
Sonoff SNZB-04P door contact zigbee 无线 前门门磁,提供「从哪个方向离开」的判断依据。
Third Reality Smart Plug Gen 2 (Zigbee) zigbee 无线 电视、书桌和打印机架上的电量监测插座;清扫用它们上报的功率确认设备确实已关闭。
Zigbee coordinator with mains-powered routers (e.g. a Zigbee smart plug per room) zigbee 有线 每个房间一个市电供电的路由节点,避免清扫在房屋远端超时。

失效时怎么办

任何 8 秒内未确认关闭的设备重试一次;仍失败则在通知中标记并不再重试,避免死循环。如果通知通道不可用,清扫结果会写入本地文本文件,保证每周审计仍能看到。

同一触发源的配方

条款 仅供参考。这些配方会控制市电、水路与物理门禁。当地电气与给排水规范、熔断与隔离措施、以及每一处失效保护的实际测试,都需要你自己负责。本页内容不构成专业工程、法律或安全建议。