Powering off TV when door is close

New to all of the home automation but so far loving it.

I configured a Ring contact sensor to trigger the lights on (TP Link light switch) and the TV on (Nvidia Shield). When the door is closed after entering, nothing occurs. When you hit play on a movie, the lights go off. When the door is opened and the movie is on, the movie pauses and the lights come on. When the door is then closed, the movie plays and the lights go off. When the movie ends, the lights come on again.

For the life of me, I can’t figure out a way to turn off everything when I am leaving. If I program a door close to power off everything, it turns off everything right after I enter the room.

Anyone have any ideas what triggers i could use to turn off everything so that it doesn’t interfere with the automations I already have?

I tied it to my remote. When i press power off, my remote switches from “Play Shield” to “Power off” I set the trigger to when “Power off” is triggered, wait 20 seconds, then power off the light switch.

If anyone has a better idea, please let me know but it is working for now.

I use MMwave radar thingy to do a similar thing. The ld2410 tied to a D1Mini. There are commercial sensors that do the same thing.

My automation turns the tv off if the room is unoccupied for 2 minutes and comes back on as soon as someone enters the room. It turns lights off as well. It could easily be set to detect if some is in the room or not and therefore used to control whatever you want. I use similar in my office to hibernate the pc when I leave the room. been running them for sometime and they seem very reliable if a bit tricky to set up.