Use “any sensor on, every sensor off”

For Home Assistant motion lights with multiple sensors, let either sensor turn the light on, but require all selected sensors to remain clear before turning it off. Do not give each sensor its own independent turn-off timer. Otherwise, a sensor near the doorway can turn off the lamp while the sofa sensor still detects someone.

Start by checking each sensor’s reported state. Then give this room one lighting automation, add a visible pause control, and test the handoff between sensors. The example below uses a motion sensor and a presence sensor, but two motion sensors work with the same logic if they expose the required states.

This is a rule about what sensors report. It cannot prove a room is empty. If both sensors miss a quiet reader, both can report clear and the lights will go out. Keep ordinary manual control available and try a nonessential lamp before using this in a room people depend on.

Research method: researched from current Home Assistant documentation on September 22, 2026. The configuration and timing example illustrate the documented behavior; they are not a Tara hardware or installation test. The cover is an AI-generated illustration.

1. Check the two inputs and the lamp

  1. Find the actual entities. An entity is Home Assistant’s named sensor or control. Open Settings > Tools > States (called Developer Tools > States in older layouts). Find each sensor’s binary_sensor entity, which reports a two-state detection signal.
  2. Watch each sensor separately. Walk through its coverage, then leave it clear. The raw state should change between on and off, even if the dashboard calls these “Detected” and “Clear.” Copy the entity IDs; do not paste the friendly room names into YAML.
  3. Choose one lamp that already works from the dashboard. This example needs a light. entity. If your plug exposes only switch., change both light actions to switch.turn_on and switch.turn_off, and use the switch’s ID.
  4. Pause competing lighting rules for this lamp. Check Home Assistant and any vendor routines. Keep other room lighting available during the test.

A State trigger can watch several entities, but it fires when any individual entry matches. Listing two sensors under a turn-off trigger does not automatically mean “both clear.” Also, a sensor may take time to report clear after movement stops; the example’s five minutes starts from the reports, not from your physical exit.

2. Decide whether a group’s behavior is enough

A Binary sensor group helper is a convenient way to combine inputs. With All entities disabled, any member reporting on makes the group on. With that option enabled, all members must be on together; that is usually the wrong rule for turning on a room’s lights.

The catch is missing data: with the default setting, one member reporting off and another reporting unavailable can leave the group off. Use the following direct checks if you want a missing sensor to prevent automatic shutoff.

On a narrow screen, swipe the table sideways. Keyboard users can focus the table and use the arrow keys.

Sensor A / sensor BThis example’s decisionHousehold consequence
On / offRequest light on; no shutoff wait.One sensor is enough to keep the light.
Off / onRequest light on; no shutoff wait.Clearing the doorway does not overrule the sofa.
Off / offWait five continuous minutes, then recheck.Both must stay clear for the whole wait.
Off / unavailable or unknownBlock or cancel automatic shutoff.The lamp may stay on until the sensor recovers or someone turns it off.
On / unavailableAllow the working sensor to request light on.A missing sensor does not block a positive detection.

This conservative choice favors leaving a convenience light on over leaving someone in darkness. It does not diagnose a sensor that is stuck at a plausible off value.

3. Add a visible automatic-lighting switch

Go to Settings > Devices & services > Helpers > Create helper > Toggle. Name it Living room auto lights and put it on the room’s dashboard. Check its entity ID; the example uses input_boolean.living_room_auto_lights. Keep it off while setting up.

The Toggle helper is a virtual switch: on allows the routine; off pauses it. To choose the lamp state yourself, turn this helper off first, then use the ordinary lamp control. It does not automatically detect a manual wall-switch press. For other ways to request a pause, see the manual-override guide.

4. Add the room’s automation

In Settings > Automations & scenes, create a new empty automation and open its menu’s Edit in YAML view. Replace the editor contents with this example. YAML is the text form of the automation. Replace every occurrence of the two sensor IDs, the helper ID and the lamp ID with yours; keep the indentation and quoted states.

This is one automation for the editor, not a complete configuration.yaml file. It uses general State and Template triggers that remain documented alongside the newer named triggers. Menu labels can differ by installed release.

On a phone, swipe the code sideways to read long lines. With a keyboard, focus the code box and use the arrow keys.

alias: Living room - lights from two sensors
id: living_room_two_sensor_lighting
mode: restart
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.living_room_motion
      - binary_sensor.living_room_presence
    to: "on"
    id: occupied
  - trigger: state
    entity_id: input_boolean.living_room_auto_lights
    to: "on"
    id: resumed
  - trigger: template
    value_template: >-
      {{ is_state('input_boolean.living_room_auto_lights', 'on')
         and is_state('binary_sensor.living_room_motion', 'off')
         and is_state('binary_sensor.living_room_presence', 'off') }}
    for: "00:05:00"
    id: clear
conditions:
  - condition: state
    entity_id: input_boolean.living_room_auto_lights
    state: "on"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: [occupied, resumed]
          - condition: state
            entity_id:
              - binary_sensor.living_room_motion
              - binary_sensor.living_room_presence
            match: any
            state: "on"
        sequence:
          - action: light.turn_on
            target:
              entity_id: light.living_room_lamp
      - conditions:
          - condition: trigger
            id: clear
          - condition: state
            entity_id:
              - binary_sensor.living_room_motion
              - binary_sensor.living_room_presence
            state: "off"
        sequence:
          - action: light.turn_off
            target:
              entity_id: light.living_room_lamp

The Template trigger is a small true/false expression. It becomes true only when automatic lighting is enabled and both sensors report off. The for setting requires that whole expression to stay true for five minutes. Detection, missing data or pausing makes it false and cancels the pending wait.

The choose action selects the matching branch. Just before shutoff, the state condition checks both sensors again. Its default is to require every listed entity to match; the turn-on branch deliberately uses match: any.

Restart mode lets a newer eligible trigger replace an unfinished action run. The five-minute wait belongs to the trigger, rather than a long delay inside the actions. A command already sent to the lamp cannot be recalled by changing the mode.

Turning the helper back on requests light immediately if either sensor is already on. If both are clear, it starts a fresh five-minute wait. It does not restore a previous brightness or scene.

Before adding a third sensor: add its ID to the turn-on trigger and both branch conditions, and add another and is_state('binary_sensor.your_third_sensor', 'off') line to the template. Omitting it from the template would allow shutoff while that sensor still detects someone.

A worked example: the doorway clears first

Imagine a doorway motion sensor and a sofa presence sensor controlling a reading lamp. These are hypothetical reported times, not measured response times. Automatic lighting stays enabled throughout.

Reported timeWhat changesWhat the routine does
8:00 p.m.Doorway becomes on.Requests lamp on.
8:01 p.m.Doorway clears; sofa remains on.No shutoff countdown starts.
8:10 p.m.Sofa clears; now both are off.Starts a wait ending at 8:15.
8:13 p.m.Doorway detects movement again.Cancels the 8:15 shutoff.
8:14 p.m.Doorway clears; both are off again.Starts a new wait ending at 8:19.
8:19 p.m.Both have stayed off.Rechecks them and requests lamp off.

If the sofa sensor instead becomes unavailable at 8:17, the 8:19 shutoff is canceled. When it later reports off and the doorway is also off, a new full five-minute wait begins.

5. Test one lamp before using the whole room

  1. Start in daylight or with other lighting on. Save the automation, enable it, then turn the automatic-lighting helper on.
  2. Trigger each sensor separately. A fresh on report from either should request lamp on. Watch the raw states so you know which one responded.
  3. Let one clear while the other stays on. Leave that situation for longer than five minutes. This automation should not turn the lamp off.
  4. Let both report clear. The lamp should turn off after five uninterrupted minutes. Repeat, but trigger either sensor partway through: the earlier deadline should no longer switch it off.
  5. Check the pause. Turn the helper off, choose the lamp’s state manually, and create real sensor changes. The routine should leave the lamp alone. Re-enable it to check the resume behavior described above.
  6. Read the automation’s Traces. These records show the trigger and branch taken. If it behaves differently, compare the actual entity states and check for another lighting rule before changing hardware.

Use real sensor transitions for this check. Home Assistant’s Run actions test skips triggers and top-level conditions; it also lacks the trigger ID used by these branches. It does not prove this routine works end to end.

If the lights still behave unexpectedly

  • They go off while somebody is sitting still: check whether either sensor actually stayed on. A correct automation cannot compensate for two false-clear reports. Pause automatic lighting while checking placement and the sensor’s own settings.
  • They never go off: check the helper, both raw states and the trace. One stuck-on or unavailable sensor intentionally prevents shutoff. A connection problem is different from an overly sensitive sensor; the unavailable-device notification guide can help flag the former.
  • They stay off after you save: the example responds to transitions. Turn the helper off and back on; an already-on sensor should then request light. If the action fails, try dashboard control and verify the target ID.
  • You only want lights after dark: add the darkness condition inside the turn-on branch. A common condition above both branches could also block the later turn-off action. A darkness condition alone will not start a run when dusk arrives; that needs a separate trigger if no sensor changes state. Establish the basic sensor behavior before adding that restriction.

After a restart or automation reload, check the lamp. Home Assistant documents that pending for waits reset. This example stores no deadline and promises no catch-up shutoff; do not assume an interrupted wait resumes where it left off. If recovery matters, use a deliberate stored-deadline and restart-check design.

This routine follows the sensors even if someone turned the lamp on manually. Use the helper when you want a manual hold. Keep it for convenience lighting with an accessible fallback, rather than the sole light on stairs or an exit route.

Frequently asked questions

Can I use two ordinary motion sensors?

Yes, if both expose on/off binary sensor entities. This combines their coverage; it does not make either sensor detect someone who is sitting still. Test the actual places where people read or work before relying on automatic shutoff.

Should I enable All entities on a binary sensor group?

Leave it off if the group should become active when any member detects someone. Enabling it requires every member to be on. For the stricter missing-data behavior in this guide, use the explicit all-off check in the example.

What happens if one sensor becomes unavailable?

That sensor no longer satisfies the all-off expression, so this routine cancels a pending shutoff and cannot start a new one until every selected sensor reports off. Another sensor can still turn the lamp on. A faulty sensor that keeps reporting off is a different problem.

Will the five-minute wait survive a restart?

No. A pending for duration resets when Home Assistant restarts or automations reload. This example does not store the deadline or guarantee a catch-up shutoff. Check the lamp after maintenance and use a stored-deadline design if recovery is essential.

When planning several rooms, choose the sensor coverage and the ordinary wall controls together. Tara’s smart lighting kit describes that room-by-room planning approach.