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 motion, without leaving anyone in the dark.

Intermediate15 minNo HACS requiredVerified syntax
Replace your entities
01

Outcome

Build a restartable automation that correctly extends the light time whenever new motion is detected.

02

Before you start

  • A motion 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.

  1. 01

    Create an empty automation

    Go to Settings → Automations & scenes, create a new automation, and choose the empty option.

  2. 02

    Open the YAML editor

    From the top-right menu, select Edit in YAML.

  3. 03

    Configure and paste

    Enter entities, thresholds, and labels below, then replace the existing YAML.

  4. 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.

Valid configuration
Generated code
alias: "Hallway · motion 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: restart

Entity map

Where to find entity IDs and actions

  1. 01

    Open Settings → Devices & services → Entities.

  2. 02

    Find the device and copy its full ID, such as sensor.living_room_temperature.

  3. 03

    For notifications, open Settings → Developer tools → Actions and search for notify.mobile_app.

  4. 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.

01home-assistant.io · automation / trigger02home-assistant.io · automation / action03home-assistant.io · automation / modes04home-assistant.io · actions / light.turn_on
Tested with: Home Assistant 2026.8 · 2026-08-23