Bedtime taper: the house dims itself as rooms empty
Instead of a fixed bedtime scene, the house watches which rooms still have someone in them and lowers the rest of the lighting one step every 10 minutes, so the last person standing walks to bed through a house that is already dark.
# 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.
Trigger · state
sensor.house_occupied_rooms
The count of occupied rooms drops by at least one, after 22:30 local time.
Step-by-step
- light.living_room · light.dining · light.kitchenStep occupied-room-adjacent fixtures down by 15 percentage points every 10 minutes, never below 8 %.
turn_on · brightness_pct {{ state_attr('input_number.taper_step','level') }} · color_temp_kelvin 2200 · transition 4s - input_number.taper_stepDecrement the taper helper so the next empty room lowers the remaining lights from wherever they are now.
decrement · min 8 - media_player.living_room_tvCap the living-room TV volume at 25 % once the bedroom zone reports occupied, to protect the sleeping person.
volume_set · 0.25 - lock.front_doorLock the front door when the last occupied room count reaches one, not when the house is empty.
lock
Taper by 15 points, not by half
Halving the brightness every step is visible and feels like the house is hurrying you. 15 percentage points over 4 s is below the threshold most people notice when they are reading a phone. Test it by watching a lamp out of the corner of your eye — you should not be able to say exactly when it changed.
Set a floor that never goes to zero
An 8 % floor keeps enough light to walk without a phone torch, and more importantly keeps the bulbs' own warm-up behaviour out of the range where they flicker. Check the driver's minimum dim level — some Zigbee bulbs drop out entirely below 5 %.
Protect the sleeping person before you dim the house
Volume caps and light direction matter more than overall brightness. Aim the remaining light away from the bedroom door, and set the volume cap in the same automation so you never have half the protection applied.
Hardware
| Model | Protocol | Link | Role in this chain |
|---|---|---|---|
| Aqara FP2 | wifi |
wireless | Living room and kitchen zone sensors; their zone output is what the occupied-room count is built from. |
| IKEA TRADFRI bulbs on a Zigbee coordinator | zigbee |
wireless | The taper targets; they accept 4 s transitions smoothly, which is what makes the dimming invisible. |
| Bedroom zone sensor (any presence sensor) | zigbee |
wireless | Tells the system when to start protecting the sleeping person from noise and light. |
When it fails
If the occupied-room count oscillates because two sensors disagree, the taper is suspended for 30 minutes and a single fixed 12 % night level is applied instead. If the bedroom sensor fails, the system falls back to the bedroom door contact plus a fixed 23:30 taper start, which is less graceful but predictable.