Seamless Entertainment: Integrating Plex with Home Assistant
- #IoT

Your smart home is more than just lights and thermostats; it's about creating a unified, responsive living environment. For many, a significant part of that environment is media consumption. Whether it's streaming movies, TV shows, or music, services like Plex have become central to home entertainment.
But what if your media server could interact with the rest of your smart home? Imagine your lights automatically dimming when a movie starts, or your thermostat adjusting for optimal comfort during a binge-watching session. This is where integrating Plex with Home Assistant shines, offering a powerful bridge between your entertainment and your smart home ecosystem.
Why Integrate Plex with Home Assistant?
Integrating Plex with Home Assistant provides several compelling benefits:
- Unified Control: Manage media playback (play, pause, stop, seek) directly from your Home Assistant dashboard, alongside all your other devices.
- Contextual Automation: Trigger automations based on the playback state of any Plex client in your home. Is a movie playing? Turn on the projector scene. Is playback paused? Turn up the lights temporarily.
- Information at a Glance: Display currently playing media information (title, poster art, progress) on your dashboard or send it via notifications.
- Multi-User Awareness: Home Assistant can track which user is playing media on which client, allowing for personalized automations.
Prerequisites
Before you begin, ensure you have:
- A working Home Assistant installation (running on a supported platform like Home Assistant OS, Supervised, Container, or Core).
- A running Plex Media Server. This can be on a dedicated NAS, a PC, a server, or a supported streaming device.
- Network connectivity between your Home Assistant instance and your Plex Media Server.
Setting Up the Plex Integration in Home Assistant
The official Plex integration makes connecting the two systems relatively straightforward.
1. Obtaining a Plex Token (if needed)
While the integration can often discover your server, obtaining a Plex token is a reliable way to ensure connectivity, especially for remote servers or complex network setups. To get a token:
- Log in to your Plex account in a web browser.
- Open a new tab and navigate to
https://app.plex.tv/desktop#!/settings/account
. - Look for the "Authorized Devices" section (you might need to click 'Show Advanced' in account settings first). Find the device associated with your current browser session.
- The URL in your browser's address bar will contain your token. Look for something like
X-Plex-Token=YOUR_TOKEN_HERE
. Copy the string afterX-Plex-Token=
. Keep this token secure, as it grants access to your Plex account.
Alternatively, you can often find the token by accessing your Plex server's local web interface and checking the developer console network requests when navigating authenticated pages.
2. Adding the Integration in Home Assistant
- In Home Assistant, navigate to Settings -> Devices & Services.
- Click the + Add Integration button.
- Search for "Plex".
- Home Assistant might discover your local Plex server automatically. If it does, select it. If not, or if your server is remote, you'll need to enter the details manually.
- Follow the prompts:
- Enter the IP address or hostname of your Plex server.
- Enter the port (usually 32400).
- Enter your Plex token (if you obtained one).
- You might be asked to select which Home Assistant user corresponds to which Plex user for tracking playback.
- Submit the configuration. Home Assistant should now connect to your Plex server and discover your clients and libraries.
Device Integration Tips
Once set up, Home Assistant will expose various entities related to your Plex server and connected clients:
- Media Player Entities: Each active Plex client (like 'Plex (Living Room TV)') will appear as a media player entity (
media_player.plex_living_room_tv
). You can use the standard media player services (media_player.play_media
,media_player.media_play_pause
, etc.) to control playback on these devices. - Sensors: Sensors might be created to show server status, library scan status, etc.
- Attributes: The media player entities will have attributes providing detailed information about the currently playing media, such as
title
,artist
,album
,media_content_type
,state
(playing, paused, idle),media_position
,volume_level
, and more. These attributes are crucial for creating sophisticated automations.
Tip: Pay attention to the entity names Home Assistant assigns to your Plex clients. These are based on the client's name as seen by the Plex server. You can rename them in Home Assistant if needed for clarity.
Automation Examples
The real power of integrating Plex with Home Assistant lies in automation. Here are a few ideas:
1. Dimming Lights When Playback Starts
Automate your lighting for a cinematic experience.
alias: Dim Lights on Plex Play
description: Dim lights in the living room when a movie starts playing on the Plex client.
trigger:
- platform: state
entity_id: media_player.plex_living_room_tv # Replace with your client entity ID
to: 'playing'
condition:
- condition: template
value_template: "{{ trigger.to_state.attributes.media_content_type == 'movie' }}"
action:
- service: light.turn_on
target:
entity_id: light.living_room_lights # Replace with your light entity ID
data:
brightness_pct: 20
transition: 5
mode: single
2. Pausing Playback on Doorbell Press
Never miss a visitor while watching something again.
alias: Pause Plex on Doorbell
description: Pause Plex playback on the living room TV when the doorbell is pressed.
trigger:
- platform: state
entity_id: binary_sensor.front_door_doorbell # Replace with your doorbell entity ID
to: 'on'
condition:
- condition: state
entity_id: media_player.plex_living_room_tv # Replace with your client entity ID
state: 'playing'
action:
- service: media_player.media_pause
target:
entity_id: media_player.plex_living_room_tv
mode: single
3. Turning Lights Back On When Playback Stops/Pauses
Restore normal lighting when the show is over or paused.
alias: Restore Lights on Plex Stop/Pause
description: Turn living room lights back on when Plex playback stops or is paused.
trigger:
- platform: state
entity_id: media_player.plex_living_room_tv # Replace with your client entity ID
to: 'paused'
- platform: state
entity_id: media_player.plex_living_room_tv # Replace with your client entity ID
to: 'idle'
condition: []
action:
- service: light.turn_on
target:
entity_id: light.living_room_lights # Replace with your light entity ID
data:
brightness_pct: 100
transition: 2
mode: single
Best Practices for a Reliable Integration
- Static IP for Plex Server: Assign a static IP address to the machine running your Plex Media Server on your local network. This prevents issues caused by the server's IP changing.
- Firewall Rules: Ensure your firewall is not blocking communication between your Home Assistant instance and your Plex server on port 32400.
- Monitor Logs: If you encounter issues, check the Home Assistant logs for errors related to the Plex integration. Common problems include network connectivity issues or invalid tokens.
- Plex Account Login: Ensure the Home Assistant instance is logged into a Plex account via the integration settings. This is necessary for features like user tracking and remote server access.
- Token Refresh: While less common now, older versions or certain configurations might require re-obtaining and updating the Plex token periodically if connectivity drops.
Conclusion
Integrating Plex with Home Assistant significantly enhances your smart home's capabilities, moving beyond simple device control to creating truly immersive and responsive environments based on your media consumption. By following the setup steps, understanding the exposed entities, and implementing thoughtful automations, you can create a seamlessly integrated entertainment experience that responds intelligently to your lifestyle.

NGC 224
Author bio: