External integration - Plex

Hi everyone! :waving_hand:

I’m sharing a new external integration that I just published: Plex, to connect your Plex server to Gladys. If, like me, you have a NAS running Plex and you’ve been dreaming of connecting your playbacks to your automations, here it is! :slightly_smiling_face:

What it does

A « server » device with monitoring sensors:

  • :bar_chart: number of active streams and sessions in transcoding
  • :satellite_antenna: streaming bandwidth (kbps)
  • :television: a « now playing » text that summarizes who is watching what
  • :card_index_dividers: a counter per library: movies, series (+ episodes), music (+ tracks) — can be disabled if you don’t want them

A device per Plex player (TV app, phone, etc.):

  • :play_button: the controls: play, pause, stop, previous, next, fast forward/rewind, volume, mute
  • :musical_note: the playback state, compatible with the Music widget on the dashboard
  • :label: the current title (Series S01E02 - Episode, Artist - Title, Movie (year)) and the remaining time
  • :sparkles: my favorites: two binary sensors « in the intro » and « in the closing credits », based on the markers detected by Plex!

This last point opens up nice scenarios:

When the credits start in the living room → turn on the lights :light_bulb:
When a playback starts after 10 p.m. → dim to 20 %
A « general pause » button at mealtime :spaghetti:

The states update in a few seconds: the integration listens to the Plex server’s real-time stream (WebSocket), with a configurable fallback polling. Players are automatically discovered — even on the fly as soon as a device starts a playback.

Installation

  1. In Gladys: Integrations → Multimedia category → Plex (while the store indexer passes, you can also install via the repository URL)
  2. Enter the URL of your server (http://nas-ip:32400) and your X-Plex-Token (how to find it)
  3. « Test connection » button, then Discovery tab → add your devices, that’s all :white_check_mark:

A small but important detail: to control a phone/tablet, remember to enable « Announce as a player » in the relevant Plex app. Without this, only the Stop button works (it cuts the session on the server side).

Under the hood

This is a v1.0.0: tested at my place (NAS + SHIELD + mobiles), but I count on you to push it to its limits :grinning_face_with_smiling_eyes: Feedback, ideas, and PRs are welcome — tell me what you’re missing (launching a specific media? additional sensors?).

Happy reading… of movies! :popcorn:

1 Like