No Motion - turn off lights

I am looking for an automation that does the following:

IF no motion detected during 30 minutes by motion sensor X
THEN turn off lights A, B and C

p.s. The motion sensor and the light switches are ZWave.

Thanks

The reason is that my dear wife often forgets to turn off the lights in our master bathroom. I do not need the motion sensor to turn on when there is motion, as we prefer to do this manually.
I only want the lights to turn off if/when there is no motion after 30 minutes.
( Why 30 minutes ??? That is because sometimes I stay in the bath tub and may not move so that the motion sensor may think that there is no motion. )

@EndUser - I would highly recommend that you take a look at the MoLight integration in HACS.

Just use @anon11644107 ‘s without the ‘on’?

triggers:
#  - trigger: state
#    entity_id: binary_sensor.your_motion_sensor_here # change this
#    to: 'on'
  - trigger: state
    entity_id: binary_sensor.your_motion_sensor_here # change this
    to: 'off'
    for:
      minutes: 2 # adjust as necessary 
actions:
  - action: "light.turn_{{ trigger.to_state.state }}"
    target:
      entity_id: light.your_light_here # change this

This should do it ?

alias: '# MBR Bathroom OFF after no motion for 30 minutes'
description: ''
triggers:
  - trigger: motion.cleared
    target:
      entity_id: binary_sensor.office_motion_sensor_motion_detection
    options:
      behavior: each
      for:
        hours: 0
        minutes: 30
        seconds: 0
conditions: []
actions:
  - action: switch.turn_off
    metadata: {}
    target:
      device_id: ab9c0ab3bf3ba4fcc2955aa7d1b1946a
      entity_id:
        - switch.on_off_switch
        - switch.mbr_bathroom_front
    data: {}
mode: single

Erm..it looks ok to me… but I would still use this:

#  - trigger: state
#    entity_id: binary_sensor.your_motion_sensor_here # change this
#    to: 'on'
  - trigger: state
    entity_id: binary_sensor.office_motion_sensor_motion_detection
    to: 'off'
    for:
      minutes: 30 # adjust as necessary 
actions:
  - action: "switch.turn_{{ trigger.to_state.state }}"
    target:
      entity_id:
        - switch.on_off_switch
        - switch.mbr_bathroom_front

PS:Why and how to avoid device_ids in automations and scripts - #80 by tom_l

Have you thought about using a mmWave presence sensor instead of a motion sensor? This will make it more accurate.

Many thanks. I made the change.

I am not familiar with this device. Which do you suggest ?

The apollo is my favorite by far: R PRO-1 PoE mmWave Multisensor For Home Assistant | Apollo Automation

But take a look here for some options: Best Presence Sensors for Home Assistant 2026 | SmartHomeScene

Just for info sake.
A mmWave presence sensor uses the reflection of the waves to determine if a living being is in the space, instead of looking for motion. So even if a person is perfectly still it can still detect them.