Pause Plex when someone leaves the room

I know I found this automation idea somewhere on google, but can’t seem to find it again.

I’ve added a camera to my Hass.io setup and it is successfully capturing motion with no issues.

What I want to do now is setup an automation where if Plex is playing on the living room TV and a person gets up it will automatically pause the movie.

I could have sworn I saw this idea somewhere else, but can’t seem to find it now that I need it.

I’ve made a template sensor to get the state of a room. Empty, motion, tv, movie, dinner etc. This is done by collecting information from various sensors.

Using that in automation I can do things like, if state changes from empty > motion, turn the lights on. If state changes from movie > motion, turn the kitchen lights on etc (this is where you would pause.

https://github.com/christianwaite/Home-Assistant-Config/tree/master/packages/livingroom

Not complete there, but there’s an example of it. I’ve had to split the livingroom package up, so have a look at all 4. Template will be in config.