Smart Home Assistant

Home Assistant Night Light Automation for Hallways (UK)

SepehrBy Sepehr· 22 October 2026· Updated 22 October 2026· 8 min read
✓ Independent — no paid placements✓ UK-tested in real homes✓ Cited sources
Illustrated dark hallway with a warm glowing floor light and a small red motion sensor on the wall.

Key takeaways

  • A Home Assistant night light automation needs two triggers: motion on, and motion off for a set time using the for option.
  • A time window of 22:00 to 06:30 works past midnight because Home Assistant treats an earlier Before time as the next day.
  • Start at brightness_pct 10 and color_temp_kelvin 2700, then adjust by eye in the real hallway at night.
  • A toggle helper stops the automation switching off a light that someone deliberately turned on manually.
  • PIR sensors only detect movement, so use a presence sensor in rooms where people sit still, such as bathrooms.
On this page[tap to expand]

A Home Assistant night light automation turns a hallway or landing light on at a low, warm level when a motion sensor trips after dark, then switches it off a minute after movement stops. You need one motion sensor, one dimmable bulb, a toggle helper and about half an hour.

The common mistake is a single automation that turns the light on, waits, then turns it off. If someone keeps moving, that timer still expires and the light drops out on them. This guide uses two triggers instead, so the sensor decides when the room is clear. If you are new to the editor, our Home Assistant automations guide covers the basics first.

What do you need before you start?

  • A motion sensor that reports to Home Assistant. Any Zigbee, Matter or Wi-Fi sensor that appears as a motion or occupancy binary_sensor works. Our best Zigbee motion sensors roundup compares options.
  • A dimmable smart bulb or light strip that supports brightness and warm colour temperature. Plain on/off smart plugs cannot do a dim glow.
  • A toggle helper. Home Assistant describes an input_boolean as an entity that stores an on or off state you can set yourself. You create one under Settings, Devices & services, Helpers, then choose Toggle.
  • Entity IDs written down. The example uses binary_sensor.hallway_motion, light.hallway and input_boolean.hallway_night_light. Swap in your own.

If you would rather start from a pre-built recipe, see our blueprints guide; building it by hand is still worth doing once because the pattern below reuses for stairs, bathrooms and bedrooms.

Away for a few days? See how to make an empty house look occupied with a Home Assistant presence simulation that varies lamp times each night.

Step 1: Tune the motion sensor for night use

Start at the sensor, because its own settings decide how twitchy the light feels. Most Zigbee sensors apply a hold time after movement before they report clear, and Home Assistant only sees what the sensor reports.

Two examples from Zigbee2MQTT's device pages. The SONOFF SNZB-03P exposes a motion_timeout setting, described as the occupied-to-unoccupied delay, adjustable between 5 and 60. The Aqara Motion Sensor P1 exposes a detection interval (from 2 to 65535 seconds), a motion sensitivity of low, medium or high, and an illuminance reading in lux. Changing the P1's settings requires pressing its pairing button immediately beforehand, otherwise the change fails.

For a night light, keep the sensor's own hold time short and let Home Assistant add the extra minute in Step 3. That way you tune the delay in one place, in the automation, rather than re-pairing a battery sensor every time you want to change it.

Home Assistant's binary sensor documentation lists both a motion class and an occupancy class, each showing Detected for on and Clear for off. Either works here, because the automation only cares about on and off.

Step 2: Create the toggle helper

Go to Settings, Devices & services, Helpers, choose Create helper, pick Toggle, name it "Hallway night light" and save. Its entity ID becomes input_boolean.hallway_night_light.

This helper records one fact: the automation, not a person, switched the light on. When the sensor clears, the automation only turns the light off if this flag is on. Without it, someone who deliberately turned the hallway light on at full brightness to look for a lost earring would have it switched off a minute after they stopped moving past the sensor.

Step 3: Build the automation

Open Settings, Automations & scenes, create a new automation, switch to YAML mode from the three-dot menu and paste the block below. It uses the current triggers, conditions and actions keys with trigger: and action: inside them.

alias: Hallway night light
description: Dim warm light on motion at night, off a minute after the hallway clears
mode: single
triggers:
  - trigger: state
    entity_id: binary_sensor.hallway_motion
    to: "on"
    id: motion_on
  - trigger: state
    entity_id: binary_sensor.hallway_motion
    to: "off"
    for: "00:01:00"
    id: motion_clear
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: motion_on
          - condition: time
            after: "22:00:00"
            before: "06:30:00"
          - condition: state
            entity_id: light.hallway
            state: "off"
        sequence:
          - action: input_boolean.turn_on
            target:
              entity_id: input_boolean.hallway_night_light
          - action: light.turn_on
            target:
              entity_id: light.hallway
            data:
              brightness_pct: 10
              color_temp_kelvin: 2700
              transition: 2
      - conditions:
          - condition: trigger
            id: motion_clear
          - condition: state
            entity_id: input_boolean.hallway_night_light
            state: "on"
        sequence:
          - action: light.turn_off
            target:
              entity_id: light.hallway
            data:
              transition: 5
          - action: input_boolean.turn_off
            target:
              entity_id: input_boolean.hallway_night_light

The two triggers. The first fires the moment the sensor reports on. The second uses Home Assistant's for option, which the docs describe as the time the new state must remain unchanged before the trigger fires, so it only fires once the sensor has stayed off for a full minute. If movement resumes in that window, the timer is cancelled. Home Assistant's documentation also notes that a for timer resets if Home Assistant restarts or automations are reloaded.

The conditions. The choose block runs different actions depending on which trigger ID fired. The motion branch requires the time window and that the light is currently off, so the automation never overrides a light someone has already set.

The actions. They use brightness_pct and color_temp_kelvin from the light.turn_on action, with transition as the fade time in seconds. Home Assistant's documentation says to use either brightness or brightness_pct for brightness, not both.

Does the time condition work past midnight?

Yes. Home Assistant's time condition documentation says that if Before is earlier than After, the time window goes past midnight. That is why after: "22:00:00" with before: "06:30:00" works as a single overnight window with no second condition.

One quirk from the same page: day-of-week checks use the current calendar day, so hours after midnight count as the next day. If you add a weekday filter, a 01:00 trip on Saturday morning counts as Saturday, not Friday night.

If your household's night is not a fixed clock window, swap the time condition for a sun-based one. Home Assistant documents a sun trigger with an offset, written in hh:mm:ss format, where a negative value fires before sunset and a positive one after. That suits UK winters, when it is dark by late afternoon, but a fixed window is more predictable for bedrooms and landings where daylight is not the issue.

Step 4: Pick brightness and colour for the glow

Ten per cent at 2700 K is a starting point, not a rule. Smart bulbs differ in how low they can dim and how warm they can go, so adjust the two numbers until the light is enough to see the floor without waking anyone. Lower Kelvin values are warmer and more yellow, higher values are cooler and bluer, according to the light.turn_on documentation. A lower value than 2700 gives a more amber glow if your bulb supports it.

Test at the real time of night, in the real hallway. A level that looks dim in a lit room can look bright at 3am. For a related approach to making lighting respond to time of day, our smart lighting automation tips include more ideas, and our scenes guide shows how to store a preset such as a "night glow" and reuse it from several automations.

SettingWhere it livesWhat it controlsStarting value
Sensor hold timeThe sensor (for example SNZB-03P motion_timeout)How long the sensor waits before reporting clearKeep it short
for on the clear triggerThe automationHow long the area must be clear before the light goes off1 minute
brightness_pctThe turn-on actionHow bright the glow is10%
color_temp_kelvinThe turn-on actionHow warm the glow is2700 K
transitionTurn-on and turn-off actionsFade time in seconds2 s on, 5 s off
Time windowThe time conditionWhen the automation is allowed to run22:00 to 06:30

Step 5: Test it and read the trace

Save the automation, make sure the hallway light is off, then walk past the sensor during the time window. The light should fade up to the glow, and a minute after you leave it should fade out. To check the clear branch without waiting for the real hours, temporarily widen the time window in the condition, run through the sequence, then set it back.

If something does not fire, open the automation's trace first. Home Assistant's troubleshooting guide says most problems show up in the trace of the automation, and suggests selecting the step that ended the run and checking its details for the result or error.

Should the light stay on while someone is still in the room?

Yes, and the two-trigger design handles it. The light stays on as long as the sensor keeps reporting motion, and only goes off once the sensor has reported clear for the full minute. Because the second trigger waits for a sustained clear state, a person who pauses on the stairs does not get plunged into darkness.

That said, a passive infrared sensor only sees movement. Someone sitting still in the hallway can look the same as an empty hallway. For rooms where people stay put, such as a bathroom or office, a presence sensor is a better fit, and our mmWave presence sensor roundup covers the options. The same pattern also works for extractor fans, as in our bathroom extractor fan automation.

Why isn't my night light automation working?

The light never comes on. Check the time condition and the light-is-off condition in the trace. If the hallway light was already on, the motion branch will deliberately skip. Also confirm the sensor entity ID matches the one in your YAML.

The light comes on but never goes off. The for timer only starts once the sensor reports off. If the sensor keeps flickering to on because it is too sensitive, or because a pet is walking past, the minute never completes. Lower the sensor's sensitivity or accept a longer hold.

The light goes off after a manual switch-on. The helper flag should prevent this. If it still happens, check that the helper turns on in the motion branch and that you did not switch the light on during the exact same moment as a motion trigger.

It stops working after a restart. Home Assistant's trigger documentation states that for timers reset on a restart or an automation reload. A restart mid-window can therefore leave the light on until the next motion event. Set the helper to restore its previous state, which is its default, and consider a second automation to switch the light off if the helper is on and the sensor is clear.

Using a delay instead of the clear trigger. Some guides use a delay action. If you go that route, set the automation to restart mode. Home Assistant's automation modes documentation says restart stops the current run, including a delay or wait that is running, and starts a new run, whereas the default single mode ignores new triggers while a run is in progress.

What can you build on top of this?

Once the pattern works, copy the automation for the landing, the stairs and the bathroom, giving each its own helper. Add an illuminance condition if your sensor reports lux, so the light stays off on bright mornings. Or use a lower brightness for rooms with children asleep. Because the structure is the same each time, you only change the entity IDs, the time window and the glow settings.

Buy the picks in this guide

Recommended for Smart Lighting

See all devices →
Shop these picks on our Amazon storefront →

Frequently asked questions

How do I make a motion-activated night light in Home Assistant?
To make a motion-activated night light in Home Assistant, create an automation with two state triggers on your motion sensor: one when it reports on, and one when it has reported off for a set time using the for option. The on branch should check a night-time window and then call light.turn_on with a low brightness_pct and a warm color_temp_kelvin. The off branch should call light.turn_off. A toggle helper records that the automation, not a person, switched the light on, so a manually lit hallway is never switched off. The caveat is that a standard PIR sensor only detects movement, so someone standing still may be treated as an empty room.
What brightness should a Home Assistant night light use?
There is no single correct brightness for a Home Assistant night light, so treat 10 per cent at 2700 K as a starting point and adjust by eye at the time of night it will be used. Use brightness_pct for a simple percentage, and do not set both brightness and brightness_pct in one action. Lower color_temp_kelvin values are warmer and more yellow, higher values are cooler and bluer. Different smart bulbs dim to different minimums and offer different warm limits, so a value that looks gentle on one bulb may look harsh on another. Test in the real hallway in the dark, because a glow that looks faint in a lit room often looks much brighter at 3am.
Does a Home Assistant time condition work across midnight?
Yes, a Home Assistant time condition works across midnight. Home Assistant documents that if the Before time is earlier than the After time, the window runs past midnight, so after 22:00:00 and before 06:30:00 is a single overnight window. The one quirk is weekdays: day-of-week checks use the current calendar day, so hours after midnight belong to the next day. If you add a weekday filter, a trip at 01:00 on Saturday morning counts as Saturday rather than Friday night. If your night is better defined by darkness than by the clock, you can use a sun trigger with an offset in hh:mm:ss format instead.

Sources

Sources verified 2026-10-22

  1. Home Assistant — State trigger
  2. Home Assistant — Time condition
  3. Home Assistant — light.turn_on action
  4. Home Assistant — Automation triggers (sun trigger and offset)
  5. Home Assistant — Automation modes
  6. Home Assistant — Troubleshooting automations
  7. Home Assistant — Input boolean
  8. Home Assistant — Binary sensor device classes
  9. Zigbee2MQTT — SONOFF SNZB-03P device page
  10. Zigbee2MQTT — Aqara Motion Sensor P1 (RTCGQ14LM) device page
›How we researched this

Claims in this article are checked against primary sources — manufacturer specifications, official documentation, Which? research, Ofgem guidance, or gov.uk — rather than forum threads or video reviews. Where the author has direct hands-on experience with a product (most Home Assistant, Zigbee, and home-networking gear is running in his own homelab), that is stated explicitly in the text.

For categories outside that personal setup — such as boilers, heat pumps, and other areas that are traditionally a heating engineer's domain — verdicts are built from cross-referenced manufacturer data, published lab results, and vetted expert and owner reviews rather than a claim of personal hands-on testing. See the editorial policy for the full methodology.

Sepehr

Written by

Sepehr

10+ years hands-on with Home Assistant & networking · Research-backed elsewhere · No brand deals

Smart home specialist with 10+ years running a self-hosted Home Assistant setup — Zigbee2MQTT, Frigate NVR, and local-first automations. Independent coverage for UK homes, no brand deals.

LinkedIn →

Citing this page? Please use a dofollow link back to the original article — it helps us keep the data on this page accurate and up to date.

Related reading