Skip to content
ScogunPublic

About

Home Assistant integration for Plex to extend official integration

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

PlexEx

PlexEx extends an existing Plex Media Server connection with automation actions and a Plex Pass status sensor:

  • plexex.search — search the library for movies, shows, seasons, or episodes by title or title fragment.
  • plexex.mark — mark a library item as watched or unwatched using its Plex ratingKey.
  • plexex.skip_marker — seek a Plex player past the intro, credits, or commercial break it is playing.
  • A diagnostic binary sensor that reports whether the Plex account has an active Plex Pass subscription.
  • A Playback event event entity that reports when playback of a movie or an episode enters or leaves a Plex marker: intro, credits, final credits, or commercial. There is one entity for the whole server and one for each Plex player. Each event type is also fired as a Home Assistant event, for example plexex_final_credits_started.
  • Automation triggers for the same events, such as plexex.final_credits_started, each with its own target players and a before/after offset.
  • Events and triggers for a player starting or stopping a movie or an episode, with media details such as audio channels, aspect ratio and edition.

PlexEx reuses the URL and token stored by the official Home Assistant Plex integration. It does not ask for Plex credentials again.

Requirements

  • Home Assistant 2026.11 or newer.
  • The official Plex Media Server integration configured with the server.

Installation

Install as a custom repository

Use these steps while PlexEx is not yet available in the default Marketplace catalog.

  1. Open Settings → Marketplace.
  2. Select Add from link in the upper-right corner.
  3. In GitHub link, enter:
    https://github.com/Scogun/plexex
    
  4. Select Add. If Home Assistant asks for the content type, choose Integration and confirm.
  5. Open the added PlexEx repository and select Install.
  6. Complete the integration setup by selecting the existing official Plex server.

Adding a custom repository requires connecting a GitHub account to the Marketplace. Home Assistant uses this connection to read the public GitHub repository.

Configure PlexEx

After installation, add PlexEx from Settings → Devices & services → Add integration → PlexEx and select the existing official Plex server.

Add one PlexEx config entry for each Plex server you want to use.

Actions

plexex.search

Searches the Plex library for media of one type by full or partial title.

action: plexex.search
data:
  type: episode
  title: Pilot
response_variable: result
Field Required Description
type Yes movie, show, season, or episode
title Yes Full or partial title of the item itself. For a season or an episode this is its own title, not the title of the show
server No PlexEx connection, see Multiple Plex servers

The action returns structured response data and can be used with response_variable:

media:
  - type: episode
    ratingKey: 23456
    title: Pilot
    year: 2008
    viewCount: 1
    lastViewedAt: "2025-12-25T20:15:00"
    showTitle: Breaking Bad
    seasonNumber: 1
    episodeNumber: 1
Field Type Description
type String movie, show, season, or episode
ratingKey Integer Plex library item identifier
title String Title of the item
year Integer or null Release year
viewCount Integer Number of times watched
lastViewedAt String or null Last viewed timestamp
showTitle String Title of the show; seasons and episodes only
seasonNumber Integer Season number; seasons and episodes only
episodeNumber Integer Episode number; episodes only

plexex.mark

Marks a Plex library item as watched or unwatched.

action: plexex.mark
data:
  rating_key: 12345
  status: unwatched

Use the integer ratingKey returned by plexex.search. The supported statuses are watched and unwatched.

Example: Search and mark all matching movies as unwatched

alias: Mark matching Plex movies as unwatched
fields:
  title:
    name: Movie title
    required: true
    selector:
      text:

sequence:
  - action: plexex.search
    data:
      type: movie
      title: "{{ title }}"
    response_variable: result

  - repeat:
      for_each: "{{ result.media }}"
      sequence:
        - action: plexex.mark
          data:
            rating_key: "{{ repeat.item.ratingKey }}"
            status: unwatched

plexex.skip_marker

Seeks a Plex player to the end of the marker it is playing right now: an intro, credits, or a commercial break.

action: plexex.skip_marker
data:
  entity_id: media_player.plex_plex_for_apple_tv_living_room
Field Required Description
entity_id Yes Media player created by the official Plex integration
markers No Kinds of markers to skip: intro, credits, final_credits, commercial. Any marker is skipped when empty

The action fails if the player is not inside a marker (or not inside one of the selected kinds), so it is safe to call from a button. The seek itself is done by the official Plex integration through media_player.media_seek, so the player has to support remote seeking. In testing, support varied by player:

Plex app Platform Remote seek Test status
Plex on Web ❌ Tested
Plex for Google TV Android TV ❌ Tested
Fire TV❔Not tested
NVIDIA SHIELD❔Not tested
Plex Desktop Windows ❌ Tested
MacOS❔Not tested
Plex HTPC Windows ✅ Tested
MacOS❔Not tested
Other platforms ❔ Not tested

Skipping the final credits seeks to their end, which is usually the end of the item.

This action has no server field: PlexEx finds the server from the media player.

Example: Skip intros automatically

This automation skips every intro on every player. The trigger is the PlexEx bus event, which carries the player's entity ID:

alias: Skip Plex intros
triggers:
  - trigger: event
    event_type: plexex_intro_started
actions:
  - action: plexex.skip_marker
    data:
      entity_id: "{{ trigger.event.data.player_id }}"
      markers:
        - intro

Multiple Plex servers

If multiple PlexEx entries are configured, select the connection in the action's Server field. In YAML, server is the PlexEx config entry ID selected by the action selector:

action: plexex.search
data:
  type: movie
  title: Interstellar
  server: YOUR_PLEXEX_CONFIG_ENTRY_ID
response_variable: result

The same optional server field is available for plexex.search and plexex.mark. Leave it empty if only one PlexEx connection is configured.

Plex Pass sensor

Each PlexEx config entry creates a diagnostic binary sensor named Plex Pass. It is on when the Plex server reports an active Plex Pass; this is read from the server itself. Its attributes include the Plex username, subscription plan, and subscription features. These come from plex.tv using the server's token and are empty when the token cannot be used there, for example on a local server without a token. Everything is refreshed hourly.

Playback marker triggers

PlexEx listens for state updates from media players created by the official Plex integration. When a movie or an episode starts playing, it fetches and caches the item's markers. Between position updates, it estimates playback locally from media_position and media_position_updated_at and checks the estimate once per second; it does not poll Plex sessions. When the estimated position moves into or out of a marker, it fires a Home Assistant event and updates the PlexEx Playback event entity.

Markers are created by Plex itself when it analyzes the library (intro and credits detection are Plex Pass features). PlexEx does not guess: an item without markers produces no events.

Event types

Event type Fires when playback
intro_started enters an intro
intro_ended plays past the end of an intro
credits_started enters credits that are not the final ones, for example before a post-credits scene
credits_ended plays past the end of those credits
final_credits_started enters the final credits (the marker Plex flags with final="1")
final_credits_ended plays past the end of the final credits
commercial_started enters a commercial break of a recording
commercial_ended plays past the end of a commercial break

The automation editor and the entity's history show these as readable names, for example Intro started; YAML uses the event types above.

A credits marker is reported either as credits_* or as final_credits_*, never both. To react to any credits, list both event types in the trigger. Final credits usually run to the end of the item, so final_credits_ended is rare: stopping playback is not reported as an end.

React to one player

PlexEx adds a Playback event entity to the device of every media player created by the official Plex integration, for example event.plex_plex_for_apple_tv_living_room_playback_event. It only receives events from that player. In the automation editor, choose the Event received trigger, target the player's device (or its Playback event entity), and select final_credits_started:

triggers:
  - trigger: event.received
    target:
      device_id: YOUR_PLEX_PLAYER_DEVICE_ID
    options:
      event_type:
        - final_credits_started

Entities follow the official Plex integration: a new player gets its entity when Plex creates its media player, and the entity is removed together with the media player. Plex Web and other transient players share a single Plex Client Service device, so their entities are added to the PlexEx server device instead and carry the player's name.

React to any player

The Playback event entity on the PlexEx server device receives events from every player of that server. Target the PlexEx device to use it:

triggers:
  - trigger: event.received
    target:
      device_id: YOUR_PLEXEX_DEVICE_ID
    options:
      event_type:
        - final_credits_started

Every event type is also fired on the Home Assistant event bus with the plexex_ prefix, for example plexex_intro_started.

Event data

Field Description
server PlexEx config entry ID (bus event only)
rating_key Plex library item identifier
media_type movie or episode
title Movie or episode title
show_title, season, episode Show name, season number, and episode number; null for movies
marker_type Plex marker type: intro, credits, or commercial
final true for the final credits marker
marker_start, marker_end Marker boundaries in milliseconds
view_offset Estimated playback position in milliseconds when the event fired
user Plex username
player_name Player name
player_id Entity ID of the Plex media player

To filter a bus event by player, match on player_id:

triggers:
  - trigger: event
    event_type: plexex_final_credits_started
    event_data:
      player_id: media_player.plex_plex_for_apple_tv_living_room

Triggers with an offset

PlexEx also provides its own automation triggers, one per event type, named like the event: plexex.intro_started, plexex.final_credits_started, and so on. Unlike the Playback event entities, each trigger has its own offset, so it can fire before or after the marker boundary, for example to bring the lights up 20 seconds before the final credits begin.

In the automation editor, add a trigger, search for Plex, pick the event, select the Plex players to follow, and set Offset to Before or After with a duration. In YAML a negative offset is before the boundary and a positive one after it:

triggers:
  - trigger: plexex.final_credits_started
    target:
      entity_id: media_player.plex_plex_for_apple_tv_living_room
    options:
      offset: "-00:00:20"
  • Target: media players of the official Plex integration, chosen directly or through a device, area, or label. In YAML the target can be left out to follow every Plex player.
  • Offset: applies to this trigger only and is limited to five minutes before or after the marker. Other triggers, the Playback event entities, and the plexex_* bus events are not shifted.
  • Trigger data: the fields of the event data are available on trigger, for example {{ trigger.title }}, together with trigger.entity_id (the media player), trigger.event (the event type), and trigger.offset. marker_start and marker_end always carry the boundaries Plex reports; view_offset shows where playback was when the trigger fired.

Two limits follow from how markers are tracked:

  • A trigger cannot fire before the item begins, so a Before offset on a marker at the very beginning fires at the start of playback.
  • A trigger whose offset moves the start of a marker to or past its end, or the end to or before its start, never fires for that marker. For example, plexex.intro_started with an offset of one minute after never fires for a 30-second intro.

plexex.skip_marker only works while the player is inside the marker, so it cannot be called from a *_started trigger with a Before offset.

How seeking and resuming are handled

  • Seeking forward into a marker counts as entering it. Seeking over a whole marker, or backward into one, fires nothing.
  • A playback that begins inside a marker fires its *_started event. This covers intros that start at the very beginning of an episode, and also an item resumed in the middle of its credits.
  • If playback is already inside a marker when PlexEx starts, PlexEx establishes a baseline and does not fire *_started for it.
  • Moving the position while paused only moves the baseline; resuming inside a marker after that fires nothing.

Playback started and stopped

PlexEx also reports when a Plex player starts or stops playing a movie or an episode, together with technical details of the item. Use it to switch a receiver's sound mode, set projector masking for the aspect ratio, or bring the lights back when playback ends.

Event type Fires when a player
playback_started starts playing a movie or an episode
playback_stopped stops playing it, or moves on to another item

Both are available the same three ways as the marker events: on the Playback event entities, as plexex_playback_started and plexex_playback_stopped bus events, and as automation triggers:

triggers:
  - trigger: plexex.playback_started
    target:
      entity_id: media_player.plex_plex_for_apple_tv_living_room
conditions:
  - condition: template
    value_template: "{{ trigger.audio_channels in ['5.1', '7.1'] }}"

The triggers take the same target as the marker triggers. In place of an offset they have an optional for: how long the player has to keep playing, or to stay stopped, before the trigger fires.

triggers:
  - trigger: plexex.playback_stopped
    target:
      entity_id: media_player.plex_plex_for_apple_tv_living_room
    options:
      for: "00:00:10"
  • playback_started with for: fires only if the player has not stopped that item within the given time. A pause in between does not cancel it; a stop does.
  • playback_stopped with for: fires only if nothing starts on that player within the given time. This keeps the lights down between two episodes, and through a player that drops out for a moment.
  • Without for both fire at once. The Playback event entities and the bus events are never delayed.
  • trigger.for holds the duration. The other trigger data, including view_offset, describes the moment the playback started or stopped, not the moment the trigger fired.

Media details

The event data has the fields of the marker event data, without the marker fields, plus:

Field Description
duration Length of the item in milliseconds
edition Edition of a movie, for example Director's Cut; null if none
file Path of the media file on the Plex server
aspect_ratio Aspect ratio, for example 2.35
audio_channels Audio channel layout: one of 1.0, 2.0, 2.1, 3.0, 3.1, 4.0, 4.1, 5.0, 5.1, 6.0, 6.1, 7.0, 7.1. It follows the layout Plex reports; without one, six or more channels are taken to include a subwoofer channel. null for anything else

The details come from the Plex library. They describe the first version of the item and the audio stream Plex selects for it. They do not know which version or audio track a particular player chose, or what a transcode delivers to it. A field is null when Plex does not report it.

When the events fire

  • Start: when a player begins a movie or an episode. The event waits until PlexEx has read the item from Plex, so it can arrive a moment after playback begins, or later if Plex cannot be reached at that time. view_offset shows where playback was.
  • Stop: when the player leaves the playing and paused states, including when it becomes idle or unavailable, and when it moves on to another item. Pausing and resuming are not stops.
  • Already playing at startup: a playback that is running when PlexEx starts reports only its stop.
  • Other media: music, clips and anything else that is not a movie or an episode reports nothing.
  • Reconnects: if a player drops out for a moment, for example while the official Plex integration reconnects, a stop and a new start are reported. A trigger with for rides these out.

Removing PlexEx

PlexEx is removed like any other integration. Nothing has to be undone on the Plex server or in the official Plex integration.

  1. Open Settings → Devices & services and select PlexEx.
  2. Next to the entry of the Plex server, open the three-dot menu and select Delete. To remove PlexEx completely, repeat this for every server.
  3. To uninstall the integration itself, open Settings → Marketplace, open PlexEx and remove it there, then restart Home Assistant.

Deleting an entry removes the entities PlexEx created for that server: the Plex Pass sensor, the Playback event entities, and the PlexEx device. The official Plex integration, its devices and its media players stay as they are. PlexEx keeps nothing on the Plex server; items already marked as watched or unwatched stay that way.

Automations and scripts that use plexex.* actions or triggers, plexex_* events, or the Playback event entities stop working once PlexEx is removed, and have to be changed or deleted by hand.

Technical notes

  • PlexAPI network calls run in Home Assistant's executor, not in the event loop.
  • Markers are cached per item until the cache is full. An item Plex had no markers for is read again the next time it is played, so markers Plex detects later are picked up without a restart. If Plex cannot be read, PlexEx tries again after a minute.
  • plexex.search covers movies, shows, seasons, and episodes. Marker and playback events cover movies and TV episodes.
  • PlexEx creates one diagnostic binary sensor for each configured Plex server.
  • PlexAPI is supplied by the official Plex integration dependency; PlexEx does not install a second version.

Development and releases

Pull requests are checked by the validation workflow. When changes are merged into main, the release workflow runs the same checks. If all checks pass, it reads version from custom_components/plexex/manifest.json, creates a Git tag with that exact version, and publishes a GitHub Release.

To publish a new version, update the version field in manifest.json before merging the change into main. The release workflow fails if that tag already exists.

About

Home Assistant integration for Plex to extend official integration

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages