Go Back
Plex Playing Tv Screen

If you’re an avid movie watcher and also love your home automation, you’ve probably wondered if you can dim your lights automatically when watching a movie. If you haven’t, you’re thinking about it now.

I use Plex a media server and organisation tool for streaming your media to just about anywhere.

If you have lights connected to your Apple Home, we can get them to dim when you hit play on your Plex device. We’re going to do this by using Homebridge and a Homebridge plugin called Homebridge Plex Sensors. You do need a Plex Pass subscription to use Webhooks.

Essentially what this does it set up a sensor within your Apple Home that detects occupancy when your chosen device is playing something in Plex.

There are some limitations, your Plex Media Server does need to be on the same network or you’ll need to expose your server IP. If you have your server running on VPS you may need to do this.

Let’s get started.

SSH into your Homebridge device, if you haven’t got one read my article here.

sudo npm install -g homebridge-plex-sensors

We’re going to need the name of the Plex client that you want to affect your lighting. The easiest way to find this is to play something on the Plex client and review what your Now Playing section of the Plex Web app says.

Plex Client Name

Then you’ll need to edit your config file:

"platforms": [{
	"platform": "homebridge-plex-sensors.Plex",
	"logSeenPlayersAndUsers": true,
	"sensors": [{
		"name": "Plex Playing",
		"players": ["SHIELD Android TV"]
	}]
}]

You can replace the name of the sensor and of course add in the correct name of your Plex client under players. Mine is an NVIDIA Shield so that’s what I’ve added to the players’ attribute.

Save your config file.

Webhooks

We now need to set up your Webhooks for Plex. This effectively sends data from your Plex Media Server to your Homebridge hub to say that something is happening. Make sure you have a Plex Pass subscription.

To set up a Webhooks log into Plex via https://app.plex.tv and then under your profile up the top right, select Account. Then on the left-hand side click Webhooks.

We’re going to need your Homebridge IP address, if you know it – great! If you don’t and you’re running a Pi simply run:

sudo ifconfig

Hopefully, your Pi is connected via Ethernet and under eth0 you should see your inet IP address.

Back in Plex Webhooks we’re going to want to add a new Webhook:

Plex Webhooks

You’re going to want to fill in the X’s with your IP address, ensure you add the port number :22987.

Now let’s restart our Homebridge hub

sudo service homebridge restart

For good measure restart your Plex Media Server too.

Setting up your Automations in Apple Home

We now need to set up the automations in the Home app. I have a daily automation that turns on my main lights at sunset. This is called Good Evening.

If the lights aren’t on, then we don’t need the Movie automation to do anything. So we’re going to create a new Scene called Movie (or anything of your choice). This is what will happen when Plex plays something, so make sure it turns off any lights that would be on normally.

Plex Playing Sensor

You should now see in your Home app a sensor called ‘Plex Playing’ or whatever you chose to call it. If you play something on your Plex client you’ll see that it shows as occupancy detected.

Now let’s tie that to an automation

Plex Movie Scene Automation

Test it out!

You’re now going to want to return your lights back to their original state if you stop/pause the movie. You can do this by adding an automation for No Occupancy Detected.

No Occupancy Plex

Congrats, you’ve now go your own cinema style lighting which dim when you’re playing a movie. This has endless possibilities and is not just limited to simply playing something via Plex. You can set different filters for TV/Movies/Music or Genres. You can also set up multiple players to trigger different rooms.

More on the automation side, although this guide was written for lights, the same method can be used to trigger other smart devices. I.e making sure the door is locked, closing the blind to reduce glare on your TV screen.

As always a quick video to show it off:

Would love to hear what other’s do with this too!

Share this

About the author

Will Beeching

I'm Will, a entrepreneurial designer/developer based in Britain. I create products that people love to interact with. I focus on Home Theater/Audio, Media Servers and Home Automation.