Deterring people with sound

Is it possible to say if no motion is detected by a motion sensor for the past hour and the door contact sensor is on, play a pre-saved sound to a specific Google Home Display?

I want to deter people from entering a room and the display (speaker) is outside of the room.

I already have a google nest display and door contact sensor. I am purchasing a motion sensor for the room. Any suggestions? I’m probably going with Aqara for the motion sensor… is the above achievable?

Yes, this should be possible using a timer.

When movement sensor is off > start timer
When movement sensor in on > reset timer
When timer is done > cast sound to Google Home