Help - bathroom privacy using aqara door sensor and audio

I currently have two automation scripts;

Script 1

  • When bathroom door is closed, play rain/ambient sounds over speakers for bathroom privacy.

Script 2:

  • When bathroom door is opened, stop sounds.

Problem is that sometimes the bathroom door might want to be immediately closed after use (when nobody is in it) because someone blew it up with super stank. In this case, we don’t want the sound to trigger when door is closed after they exit.

I’m trying to make it so that when the door is closed the sound will only play if the door sensor state had been open for longer than 10 seconds (someone opening the bathroom door and closing it behind them wouldn’t trigger this).

This seems like the perfect use case for a motion sensor…

Trying to avoid this.

Create a boolean sensor that is set when the door is left open for 10 seconds then use this as a condition when the door is shut to play the sound. If the door is shut for a duration than reset the boolean sensor so it can be set again when the door is open for 10 seconds.

I really think a motion detector is they way forward, as there is no reliable way to work out whether or not to play the sounds based on the state of the door alone.

If the door was shut when someone approaches the bathroom, and they simply open it, go in, then close it in a couple of seconds, you’d get no music with your 10 second approach.

You might also perhaps use a vibration sensor on the side of the toilet to determine when its flushed. That way you’d know the state of the door AND the state of occupancy at the same time, and could work something out using that.

Suit yourself, but objectivity will be your friend in your home automation journey. I fought several things over the years for one silly reason or another, and ended up at the same place anyway. With time, you’ll come to learn this as well.