I think here should Ben smth like this:
If door was opened and there is no motion - turn on the motion. If there is motion - turn on motion.
For turning off:
If the door was opened, then there was no motion for “n” minutes (n minutes motion sensor is still “on” after firing. On aqara, for example - 120 seconds) - turn off the light.
If there is motion (motion sensor is “o n” more then “n” minutes), start from the beginning (wait the door to be opened if it’s closed, or wait 2 minutes if the door is open)
So
Door from close to open, and
No motion after 2 minutes -> turn off
Find motion after 2 minutes - wait for another opening.
Did you have that fixed?
I’m in same situation with my bathroom sensor, he doesnt see mee in the shower, i dont have a door sensor there though…
I tried moving the sensor without luck
Here’s mine so far
I got 3 lights in the bathroom
lavabo (putting it on always)
douche (just when taking shower)
bad (just when taking bath)
- id: turn_on_bathroom_lights_when_its_dark
alias: "Lichten: Badkamer ouders aan bij beweging wanneer het donker is"
trigger:
- platform: state
entity_id: binary_sensor.presence_badkamer_ouders
from: "off"
to: "on"
- platform: numeric_state
entity_id: sensor.lightlevel_badkamer_ouders
below: 30
condition:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.lightlevel_badkamer_ouders
below: 30
- condition: state
entity_id: binary_sensor.presence_badkamer_ouders
state: "on"
- condition: state
entity_id: light.lavabo
state: "off"
action:
- service: light.turn_on
entity_id: light.lavabo
- id: turn_off_bathroom_lights_when_no_movement
alias: "Lichten: Badkamer ouders uit als er geen beweging is"
trigger:
- platform: state
entity_id: binary_sensor.presence_badkamer_ouders
to: "off"
for: "00:02:00"
condition:
- condition: or
conditions:
- condition: state
entity_id: light.lavabo
state: "on"
- condition: state
entity_id: light.bad
state: "on"
- condition: state
entity_id: light.douche
state: "on"
action:
- service: light.turn_off
entity_id:
- light.lavabo
- light.bad
- light.douche