I have an automation to control a PIR who turns on light in my basement. The only way i manage to turn the light off, is to put in a delay. Can somenone explain to me how i reset the delay when new motion is detected.
Here’s one possible way to do it using a single automation:
- alias: 'Kjellarlys - '
trigger:
- platform: state
entity_id: binary_sensor.kjellar_pir
to: 'on'
- platform: state
entity_id: binary_sensor.kjellar_pir
to: 'off'
for: '00:05:00'
action:
service: "switch.turn_{{ trigger.to_state.state }}"
entity_id: switch.bfa5cb2c8f5aa6eb74dqmq
It will turn on the switch when kjellar_pir turns on and it will turn off the switch only when kjellar_pir turns off, and remains off, for 5 minutes (300 seconds).
And further, you could template the ‘for’ time to have it adjustable from the front end (input number) set it to seconds, that way you could go from say 10 secs to 600 (10 mins) or more if needed