# HearthNodes recipe 05 - bedtime taper
alias: "Presence - bedtime taper as rooms empty"
id: hn_presence_bedtime_taper
description: "Rooms emptying after 22:30 step the rest of the house down 15 points"
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: sensor.house_occupied_rooms
- platform: numeric_state
entity_id: sensor.house_occupied_rooms
below: 2
variables:
step: "{{ states('input_number.taper_step') | int(100) }}"
next_step: "{{ [step - 15, 8] | max }}"
taper_targets:
- light.living_room
- light.dining
- light.kitchen
- light.hall_downlights
condition:
- condition: time
after: "22:30:00"
before: "01:30:00"
- condition: state
entity_id: binary_sensor.cooking_active
state: "off"
- condition: state
entity_id: binary_sensor.bath_running
state: "off"
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: input_number.set_value
target:
entity_id: input_number.taper_step
data:
value: "{{ next_step }}"
- service: light.turn_on
target:
entity_id: "{{ taper_targets }}"
data:
brightness_pct: "{{ next_step }}"
color_temp_kelvin: 2200
transition: 4
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.bedroom_presence
state: "on"
sequence:
- service: media_player.volume_set
target:
entity_id: media_player.living_room_tv
data:
volume_level: 0.25
- service: lock.lock
target:
entity_id: lock.front_door
data:
code: "{{ states('input_text.service_code') }}"
# Oscillating occupied-room count suspends the taper for 30 minutes and applies
# a flat 12 percent night level instead. Bedroom sensor failure falls back to the
# bedroom door contact plus a fixed 23:30 start.
触发器 · state
sensor.house_occupied_rooms
本地时间 22:30 之后,有人房间的数量减少至少一个。
分步说明
- light.living_room · light.dining · light.kitchen每 10 分钟把紧邻空置房间的灯具下调 15 个百分点,且不低于 8 %。
turn_on · brightness_pct {{ state_attr('input_number.taper_step','level') }} · color_temp_kelvin 2200 · transition 4s - input_number.taper_step递减渐变 helper,让下一个空掉的房间从当前亮度继续下调其余灯光。
decrement · min 8 - media_player.living_room_tv一旦卧室分区报告有人,把客厅电视音量上限设为 25 %,以免吵到已入睡的人。
volume_set · 0.25 - lock.front_door当有人房间数降到 1 时锁前门,而不是等到整屋无人。
lock
每次降 15 个百分点,而不是直接减半
每一步都减半会很明显,感觉像房子在催你。4 秒内降 15 个百分点,低于大多数人看手机时的察觉阈值。测试方法:用眼角余光看一盏灯,你应当说不出它具体是什么时候变的。
设置一个绝不到零的下限
8 % 的下限既够走路不用手机手电,更重要的是避开了一些驱动在低亮度区闪烁的工作范围。查一下驱动的调光下限——有些 Zigbee 灯泡低于 5 % 会直接熄灭。
先保护睡着的人,再去调暗房子
音量上限和光线方向比整体亮度更重要。让剩余的光避开卧室门方向,并把音量上限写进同一条自动化,避免只执行了一半的保护。
硬件
| 型号 | 协议 | 连接 | 在本链路中的作用 |
|---|---|---|---|
| Aqara FP2 | wifi |
无线 | 客厅与厨房分区传感器;有人房间计数即由其分区输出汇总而来。 |
| IKEA TRADFRI bulbs on a Zigbee coordinator | zigbee |
无线 | 渐降的目标灯具;能平滑接受 4 秒过渡,这正是让调光不易察觉的关键。 |
| Bedroom zone sensor (any presence sensor) | zigbee |
无线 | 用于判断何时开始为已入睡的人隔离噪声与光线。 |
失效时怎么办
如果两个传感器互相矛盾导致有人房间数来回震荡,渐降暂停 30 分钟,改为统一的固定 12 % 夜间亮度。如果卧室传感器失效,则回退为「卧室门磁 + 固定 23:30 开始渐降」,优雅度差一些但可预测。