Automations / Home Assistant 2026.8
Motion and lux passage lights
Lights turn on only when the area is dark and turn off after the last movement, without leaving anyone in the dark.
Replace your entities↓Outcome
Build a restartable automation that correctly extends the light time whenever new movement is detected.
Before you start
- A movement sensor exposed as a binary_sensor.
- An illuminance sensor in lux and a controllable light.
- A lux threshold chosen after testing the actual space.
02 / Workflow
Guided installation
Follow the steps in order. The configurator below generates the block you need to paste.
- 01
Create an empty automation
Go to Settings → Automations & scenes, create a new automation, and choose the empty option.
- 02
Open the YAML editor
From the top-right menu, select Edit in YAML.
- 03
Configure and paste
Enter entities, thresholds, and labels below, then replace the existing YAML.
- 04
Save and test
Save, use Run actions for a controlled test, and inspect Traces after a real trigger.
YAML configurator
Replace your entities
Enter the real entity IDs from your installation. The code updates immediately and flags invalid values.
alias: "Hallway · movement and lux lights"
description: ""
triggers:
- trigger: state
entity_id: binary_sensor.movimento_corridoio
to: "on"
conditions:
- condition: numeric_state
entity_id: sensor.luminosita_corridoio
below: 35
actions:
- action: light.turn_on
target:
entity_id: light.corridoio
data:
brightness_pct: 65
- wait_for_trigger:
- trigger: state
entity_id: binary_sensor.movimento_corridoio
to: "off"
- delay:
seconds: 90
- action: light.turn_off
target:
entity_id: light.corridoio
mode: restartEntity map
Where to find entity IDs and actions
- 01
Open Settings → Devices & services → Entities.
- 02
Find the device and copy its full ID, such as sensor.living_room_temperature.
- 03
For notifications, open Settings → Developer tools → Actions and search for notify.mobile_app.
- 04
Paste each value into the matching field and copy the YAML only when every check is green.
Source first
Official references
The syntax and components in this project were checked against these Home Assistant pages.