I have a door sensor which turns a light on when the door is opened to a room. There is a PIR sensor in that room.
If the door is opened but the PIR isn’t triggered shortly afterwards, I want the light to go off.
This is what I have so far. I feel like I’m close, but just not quite there.
- alias: Turn off Snug lamp when kitchen door opens and no pir
trigger:
platform: state
entity_id: binary_sensor.kitchen_snug_door
to: 'off'
for:
minutes: 5
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.snug_pir
value_template: "((as_timestamp(now()) - as_timestamp(states.binary_sensor.snug_pir.last_changed)) / 60 )| int < 6)"
action:
- service: homeassistant.turn_off
entity_id: group.snug
This would cause the action to run 5 minutes after the door closes, if at that time the PIR has been off for 5 minutes (i.e., hasn’t detected any motion since the door was closed.)
Huh? We’re talking about a binary sensor (binary_sensor.kitchen_snug_door, right?), and binary sensors are either 'on' or 'off'. And if they don’t change between those states to reflect the state of something (like the door in this case), what good are they???
You have a physical sensor on the door, right? And you have a binary sensor in HA, specifically binary_sensor.kitchen_snug_door, whose state is either 'on' or 'off', depending on the physical state of the door sensor, right?
If the answer to both of those questions are yes, then I don’t know what you’re talking about. If either answer is no, then, well, I still don’t know what you’re talking about.