Hi I have a motion sensor in office which turns on lights when I walk in.
I have a motion sensor in staircase.
I have the following set up so when I walk into the office the lights go on
when I go towards staircase the office light goes off.
Problem is evertime I walk out of the office the lights close which is ok but sometimes I only leave for a minute. so wanted to add a delay.
I added delay in the turn off office automation which worked. But problem is even though I walk back into the office within the 2 minutes the light closes 2 minutes later.
would like to modify the automation so that when I walk back into my office and the motion sensor in office sees me it cancels the 2 minute off cycle.
this is what I have
- id: '1608423397772'
alias: office on with motion
description: ''
trigger:
- platform: state
entity_id: sensor.zooz_sensor_office_burglar_2
to: '8'
condition: []
action:
- type: turn_on
device_id: f9da103eb77c412cbb080627e0ec9328
entity_id: switch.office_light
domain: switch
mode: single
- id: '1610481877555'
alias: turn off office if motion in staircase
description: ''
trigger:
- platform: state
entity_id: sensor.zooz_sensor_basement_staircase_burglar
to: '8'
condition: []
action:
- delay: '00:02:00'
- type: turn_off
device_id: f9da103eb77c412cbb080627e0ec9328
entity_id: switch.office_light
domain: switch
mode: single
Try this modified version of your second automation:
- id: '1610481877555'
alias: turn off office if motion in staircase
description: ''
trigger:
- platform: state
entity_id: sensor.zooz_sensor_basement_staircase_burglar
to: '8'
condition: []
action:
- wait_for_trigger:
- platform: state
entity_id: sensor.zooz_sensor_office_burglar_2
to: '8'
timeout: '00:02:00'
- choose:
- conditions: "{{ wait.trigger == none }}"
sequence:
- service: switch.turn_off
entity_id: switch.office_light
mode: single
It is triggered the same way as your original automation, when the staircase motion sensor detects your presence. After that it waits for the office motion sensor to trigger. It waits a maximum of 2 minutes for the office motion sensor to trigger.
If it does not trigger within 2 minutes (meaning you never returned to the office) then wait.trigger is none and the office light is turned off.
If it does triggers within 2 minutes (meaning you returned to the office) then wait.trigger is notnone and the office light is not turned off.
I’m pleased to hear it works and meets your requirements.
Please consider marking my post (above) with the Solution tag. It will automatically place a check-mark next to the topic’s title. This signals to other users that this topic has an accepted solution. It will also place a link below your first post that leads directly to the Solution post.
All of this helps other users find answers to similar questions.