Homebridge Sensors for Plex

Homebridge Sensors for Plex is a plugin I’ve created in my spare time for the popular Homebridge server, which lets you create various sensors for Apple HomeKit that can be triggered by a playback in Plex. This allows you to automate HomeKit compatible devices with Plex in fun & useful ways.

I always think of home automation as that wonderfully nerdy intersection of “useful” and “awesome to show off to your friends” and without a doubt, this plugin fits both of those categories perfectly. It makes my life a tiny bit easier everyday, and every friend who watches a movie at my house asks “how did you get your lights to do that?!”

A movie playback sensor being triggered by a Plex player in the kitchen

So what can this plugin do for you? Well, if you’re an Apple HomeKit user and a Plex user: quite a lot.

If you’ve ever wanted your lights to fade out when you start watching a movie, and come back on when you pause to go to the bathroom — this plugin could be for you. Have that one lamp that always reflects on your TV and you want it to go off when you start watching the latest episode of your favorite show? Yep, it can handle that, too.

The more smart devices you have, the more options you have: maybe you have a smart lock and you’d feel a little more comfortable if your door locked whenever you started binge watching The Walking Dead — it’s got you covered.

Customizability

The plugin was built to be super customizable, but simple as well, so if you just want one sensor that can be triggered by any Plex playback, that’s super easy. But you can also easily have multiple sensors, triggered by any combination of different player devices, users, and media types. This makes it possible to have different automations triggered when the kids start playing a movie on the Roku in the den, or when you start playing music on your Apple TV in the bedroom, for example. Here’s a sample config showing just how easy it is to configure custom sensors:

{
"platform": "homebridge-plex-sensors.Plex",
"sensors": [
{
"name": "Kids Watching TV",
"types": ["movie", "episode"],
"players": ["Den"],
"users": ["Kids"]
},
{
"name": "Bedroom Music Playing",
"types": ["track"],
"players": ["Bedroom"]
}
]
}

Beyond even that, you can filter sensor events based on any custom information provided by the Plex webhook, so you can even have a sensor that’s triggered when you play a specific TV show or movie! The geeky possibilities are endless!

{
"name": "Groundhog Day... again",
"customFilters":{ "Metadata.title": "Groundhog Day" }
}

Oh yeah, did I mention that it’s powered by Plex webhooks? Let’s talk about why that’s so awesome…

The Joy of Webhooks

What’s so awesome about using Plex webhooks for this plugin is that the Plex Media Server notifies the plugin when playback starts, which has two great benefits:

  1. The plugin isn’t pinging your server all day long, wasting resources and bandwidth.
  2. The sensor is triggered immediately when playback starts, no waiting around for your lights to dim, and no waiting around for them to come back up when you pause, either. You won’t believe how quick it happens!

Webhooks not only made the development of the plugin easier, but they also made the final product far better.

I Want it Now!

A short video of the plugin controlling some Philips Hue lights when Plex for Apple TV starts playing a movie.

So you want this magic in your life as soon as possible and you want to know where to start?

Well, if you haven’t done so already, your first step is to install Homebridge on a computer on your network that you always keep on: check out Homebridge’s installation instructions (or their detailed instructions for macOS, Windows, or Raspberry Pi)

Once you have Homebridge up and running it’s as simple as installing the plugin, configuring the webhook on your Plex account, and then editing your configuration to choose what sensors you want (taking a look at the helpful example configs to get you going).


I love these fun combinations of technology; they bring a little surprise and delight into my life every day. When I stop to think of the chain of things that are happening to make my lights dim in a split second, the magic doesn’t go away for me, it just seems even more amazing. Think about it: the Plex player tells the Plex server it’s playing, the Plex server calls a web URL for my Homebridge plugin, my Homebridge plugin tells Homebridge itself that the sensor has changed state, Homebridge tells HomeKit, then your Apple device triggers whatever scenes you’ve configured for that sensor and communicates with every device you want changed (anything from lights, to fans, to sprinklers). All of that in a split second, just to get my lamp to dim so I can enjoy my movie. The wonders of technology!

Like what you read? Give Alex Stevenson-Price a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.