Some hardware links on this page are affiliate links. As an Amazon Associate I earn from qualifying purchases. We may earn a commission if you buy through them, at no extra cost to you. See the affiliate disclosure.
A motion light that only sets a brightness cannot also set the lamp in the corner, the color, and the switch by the door. A scene can. This blueprint turns a scene on when any selected motion or presence sensor is detecting, and only inside a window you set. After a later hour it can use a second, dimmer scene instead. When every sensor has been clear for a delay, it runs a clear-out scene, or it turns off a list of targets if you left that scene empty.
Entity ids are blueprint inputs. Do not publish which room the scenes belong to.
A light that cares about lux, and not about a clock, is occupancy lighting with a lux gate. A dim path that only exists at night, with no second scene, is adaptive night path. One button that walks a list of scenes is button scene cycling. This one is the clock plus the scenes.
What problem it solves
You want the room bright in the evening, dim after a set hour, and back to a known off state when the room is empty, without a second automation fighting the first.
How it works
The sensor device class must be motion, occupancy, or presence, and the state must be on while the room is in use. Occupied means any selected sensor is on.
- The window is the day boundary — motion before the start and after the end does nothing. Pack defaults are 17:00 to 07:00, so the daytime is the ignored stretch. If the end is earlier than the start, the window runs overnight.
- Evening scene — inside the window, and before the late start,
scene.turn_onruns the normal on-scene. If someone is already detected when the window opens, the same scene runs then. It does not wait for a new motion edge. - Late-night scene — from the late start (pack default 23:00) until the window ends, the late on-scene is used when you set one. An empty late scene keeps the evening scene. If someone is still detected when the late hour arrives, the late scene is applied then.
- Clear-out — the blueprint waits until every sensor is
off, then waits the no-motion delay (pack default 120 seconds). Motion during that delay starts the wait over. The tier was chosen when the run started, so the clear-out scene matches the on-scene even if the clock crosses the late hour while you are still in the room. The clear-out still runs if the window has already closed, so a last detection near the end does not leave the room on. - No clear-out scene — if that input is empty,
homeassistant.turn_offruns on the fallback targets. If those are empty too, nothing turns the room off. Set one or the other.
mode: restart. A new detection applies the on-scene again and resets the delay. There is no lux test and no manual-override memory. A hand change sticks until the next clear-to-detect edge.
Hardware notes
- Sensors. One or more binary sensors. A PIR is enough for a hallway you walk through. A mmWave module is the one to add when a PIR times out on someone sitting. The ESP32 that would host either module is only needed when the sensor is not already in Home Assistant.
- Scenes. HA
sceneentities. The evening on-scene, the late on-scene, and the two clear-out scenes are separate entities you build first. The blueprint does not invent brightness. - Bulbs. Whatever those scenes already set. A dimmable bulb matters only if the late scene is supposed to be dimmer than the evening one.
- One room per automation. A second room gets a second blueprint instance and its own scenes. Do not point two instances at the same scene if they should look different.
Snippet
Inputs replace real entity ids. This is the branch structure, not every condition:
trigger:
- trigger: state
entity_id: !input motion_sensors
to: "on"
id: motion
- trigger: time
at: !input window_start
id: window_start
- trigger: time
at: !input late_start
id: late_start
condition:
- condition: time
after: !input window_start
before: !input window_end
- condition: template
value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count > 0 }}"
action:
- choose:
- conditions:
- condition: template
value_template: "{{ late_period and late_scene != '' }}"
sequence:
- action: scene.turn_on
target:
entity_id: !input late_scene_on
default:
- action: scene.turn_on
target:
entity_id: !input scene_on
- repeat:
sequence:
- wait_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}"
- delay:
seconds: !input no_motion_wait
until:
- condition: template
value_template: "{{ expand(sensors) | selectattr('state', 'eq', 'on') | list | count == 0 }}"
- choose:
- conditions:
- condition: template
value_template: "{{ late_period and late_off != '' }}"
sequence:
- action: scene.turn_on
target:
entity_id: !input late_off_scene
- conditions:
- condition: template
value_template: "{{ off_scene != '' }}"
sequence:
- action: scene.turn_on
target:
entity_id: !input off_scene
default:
- action: homeassistant.turn_off
target: !input off_target
late_period is decided once, from the late start and the window end, when the run begins. Pack defaults are a 17:00–07:00 window, a 23:00 late start, and a 120 second clear delay.
Setup outline
- Create the evening on-scene and a clear-out scene. Optional: a late on-scene and a late clear-out scene.
- Import the blueprint. Select the sensors, the window, the evening scene, and either a clear-out scene or fallback targets.
- Leave the late scenes empty for a first test. Trip a sensor inside the window. The evening scene should run. Stay still until the delay ends. The clear-out scene should run.
- Set the late start a minute from now, stand in range, and confirm the late scene replaces the evening scene without a new motion edge.
- Trip the sensor outside the window. Nothing should change.
Troubleshooting
- The scene never runs. The clock is outside the window, or the sensor state is not
on. Read both in Developer Tools. An inverted sensor looks clear while you are standing there. - The late scene never runs. The late on-scene input is empty, or the late start is not between the window start and the window end. An empty late scene is a deliberate fallback to the evening scene.
- The room stays on. Neither clear-out scene nor fallback targets are set. The delay also restarts on every new
on. A sensor that sticks on will never clear. - It turned the evening scene back on after you dimmed the room by hand. There is no override memory. The next detection reapplies the scene. Change the scene, or use a keep-on helper in a different automation.
- You wanted a lux gate instead of a clock. That is occupancy lighting with a lux gate. This blueprint will not read a lux sensor.
- Two rooms share one sensor. They will both fire. One blueprint instance per room, with the sensors that actually cover that room.
Credits
Based on Scene and be seen (motion_scene_lighting.yaml). That blueprint applies scenes from motion and presence sensors, with a window that can cross midnight and an optional late-night scene tier. This write-up is an original overview of that path: the evening scene, the late scene, the clear-out, and the fallback turn-off. It does not add a lux condition or a manual override. The blueprint does not have those either.