Plex Light

Automatically control your home theater lighting with Plex!

This project is maintained by randyoyarzabal

GitHub release GitHub commits (since latest release)

Automated Plex Lighting Control

A webhook application for Plex Media Center to automatically control home theater lighting (i.e. Leviton Decora) triggered by media (movies, episodes, trailer/pre-roll) events, such as play, pause, stop and even media endings.

Features

Quick Start

Caution: if you intend this app to control lights based on trailer/pre-roll events, you need to make sure that pre-rolls are defined in Plex Settings (Extras). That is, if trailers are defined, and you intend to have dim lighting (for example) for trailers and lights-off for the movie, then you are required to have pre-rolls enabled in Plex. But why, you might ask? It is because Plex decided to send a “media.play” event ONLY when playback is invoked right before the trailers and pre-roll. It is therefore impossible to detect when a movie is about to start, unless you have a pre-roll, then this app will detect the end of that, and therefore turn off the lights before the movie starts.

Long story short, if you have trailer/pre-roll enabled, CONTROL_MODE should be set to Advanced, otherwise leave as Basic if you don’t.

Installation

Please note that while the “master” branch is a working version tested with Python 3.7 on CentOS and MacOS, documentation and code clean-up is in-progress.

Stand-alone Installation

Docker Installation

Known Issues/Solutions

There are no known issues in Basic mode and where no trailers/pre-roll are enabled in Plex. However, in Advanced mode, there are some issues due to Plex’s limitation on playback events when trailers/pre-roll are involved:

Issue #1: Lights turn on (instead of off) when movie starts.
Solution: Make sure pre-roll videos are enabled if trailers are enabled.

Issue #2: There’s a long delay in some/all the actions. Solution: Be sure to set CONTROL_MODE='Basic' when trailers/pre-roll are disabled or the stop/play delays will be in effect.

Issue #3: Lights turn on and off in between trailers.
Solution: Be sure you have CONTROL_MODE='Advanced' and pre-roll enabled in Plex. This could also be a timing issue on how fast trailers load making the app think you stopped/skipped the trailer. If it bothers you, tweak the PLEX_STOP_ACTION_DELAY setting to about 2-5.

Issue #4: Lights turn off then dim right after I play a movie and the trailers start.
Solution: This is a timing issue because Plex sends a ‘media.play’ for a movie, followed by a ‘media.play’ for a trailer. It all depends on how fast Plex can transition from movie play to trailer. If it bothers you, tweak the PLEX_PLAY_ACTION_DELAY setting to about 5-8.

Credits

This is based on the idea and code posted by dwclarknu on the Plex Forums.
The library used for Leviton Decora Smart WiFi Switches & Dimmers is python-decora_wifi.