I need an automation that turns off the bathroom lights when there is no one there. Im using 3 PIR sensors on it.
The triggers are when they have no movement, BUT, I want the automation to run when they ALL are not occupied for 5 minutes. I also need to account for the case where one or more becomes unavailable, so I cannot just put the “and if” as “not occupied”.
I tried modeling them as “AND(NOT (not occupied for 5 minutes), …)” but the 5 minutes is not working because the negation should be NOT(not occupied) for 6 minutes, which is a little bit different.
Is there a way to solve it? Here’s how it is right now:
alias: sem movimento banheiro
description: ""
triggers:
- type: not_occupied
device_id: 8a8d0f2c37e0eb0a4acfcc783431cb98
entity_id: dc2f2e958c71ab094e69f6e06cd36ee2
domain: binary_sensor
trigger: device
for:
hours: 0
minutes: 5
seconds: 0
- type: not_occupied
device_id: 7128ea10089bd2becf45f3d0e3dc4e42
entity_id: ddb61c02e913c99e3364c7496d37738e
domain: binary_sensor
trigger: device
for:
hours: 0
minutes: 5
seconds: 0
- type: not_occupied
device_id: 79688030f254a6b0e2be1bea48b88c9b
entity_id: cdc2270997413bcde57b93412cdb540b
domain: binary_sensor
trigger: device
for:
hours: 0
minutes: 5
seconds: 0
- trigger: time_pattern
minutes: /15
conditions:
- condition: and
conditions:
- condition: not
conditions:
- type: is_occupied
condition: device
device_id: 7128ea10089bd2becf45f3d0e3dc4e42
entity_id: ddb61c02e913c99e3364c7496d37738e
domain: binary_sensor
for:
hours: 0
minutes: 8
seconds: 0
- condition: not
conditions:
- type: is_occupied
condition: device
device_id: 79688030f254a6b0e2be1bea48b88c9b
entity_id: cdc2270997413bcde57b93412cdb540b
domain: binary_sensor
for:
hours: 0
minutes: 8
seconds: 0
- condition: not
conditions:
- type: is_occupied
condition: device
device_id: 8a8d0f2c37e0eb0a4acfcc783431cb98
entity_id: dc2f2e958c71ab094e69f6e06cd36ee2
domain: binary_sensor
for:
hours: 0
minutes: 8
seconds: 0
actions:
- type: turn_off
device_id: 805e72203db25cea03161d3e11584689
entity_id: 728c4861be456ab63844ad5a812e644b
domain: switch
- type: turn_off
device_id: 805e72203db25cea03161d3e11584689
entity_id: 1d41f9b210e2c070fe31ae179ea16e99
domain: switch
mode: single