Automation: Mi Door sensor and Schlage Lock

Hello, all

Entity: Mi door sensor and schlage Lock
I would like to lock the door after Door sensor is detected to be closed for over 1 minutes.
This automation never triggered, I tried to use from on to off and also open to closed. Nothing seems to be working. This automation never triggered, I tried manually trigger it, it does lock the door.
Thanks in advance!
Code as follow

- alias: If the window is closed for 1 minutes lock the back door
  trigger:
    platform: state
    entity_id: binary_sensor.door_window_sensor_158dxxxxxab6
    #from: 'on'
    to: 'Closed'
    for:
      minutes: 1
  action:
    service: lock.lock
    entity_id: lock.back_door

in your automation, change
to: 'Closed'
to
to: 'off'
and it should work

Thanks for the reply
I tried off as well. does not make any difference, really weird.

make sure it’s off and not Off (it’s case sensitive)
It’s also a good idea to try and update your automation with dashes so each entry comes as a list.
If you want an automation to start on multiple triggers or have multiple actions, it’ll fail otherwise

- alias: If the window is closed for 1 minutes lock the back door
  trigger:
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d0000d43ab6
      to: 'off'
      for:
        minutes: 1
  action:
    - service: lock.lock
      entity_id: lock.back_door
1 Like

Thanks, Once I changed to off, it is working like a charm… :+1:

1 Like