SIMPLE binary sensor (motion) trigger for no motion after 10 minutes

Hello,

Looking for help … I have the following script which is supposed to turn the lights off after my z-wave sensor has not detected any motion for 10 minutes. The “Turn On” part works… but the “Turn Off” part is never triggered.

This is my script:

#
# Turn Lab Lights Off
#
- action:
  - data:
      entity_id: switch.lab_flood
    service: switch.turn_off
  alias: 'Turn Lab Lights Off After ten minutes of no motion'
  condition: []
  id: '1522868080004'
  trigger:
  - entity_id: switch.lab_motion_141
    platform: state
    to: 'off'
    for:
      minutes: 10
#
# Turn Lab Lights On By Motion Detection
#
- action:
  - data:
      entity_id: switch.lab_flood
    service: switch.turn_on
  alias: 'Turn Lab Lights On By Motion Detection'
  condition: []
  id: '1522868080003'
  trigger:
  - entity_id: binary_sensor.lab_motion_141
    from: 'off'
    platform: state
    to: 'on'

This is the device history for binary_sensor.lab_motion_141:

image

Any guidance would greatly be appreciated.

Brett

Found the solution… I believe it was missing the “from:” state value.

  • action:
    • data:
      entity_id: switch.lab_flood
      service: switch.turn_off
      alias: Turn Lab Lights Off After ten minutes of no motion
      condition: []
      id: ‘1522868080004’
      trigger:
    • entity_id: binary_sensor.lab_motion_141
      for:
      minutes: 10
      from: ‘on’
      platform: state
      to: ‘off’
  • action:
    • data:
      entity_id: switch.lab_flood
      service: switch.turn_on
      alias: Turn Lab Lights On By Motion Detection
      condition: []
      id: ‘1522868080003’
      trigger:
    • entity_id: binary_sensor.lab_motion_141
      from: ‘off’
      platform: state
      to: ‘on’