How to Setup “Plex Assistant” in Home Assistant To Cast Plex Media Using Your Voice

by Danny
8 comments

READING TIME: 7 MINUTES

In this guide, I’m going to show you how to setup Plex Assistant, which is a project that integrates with Google Assistant. This allows you to say things “Hey Google, tell Plex to play Game of Thrones on Living Room Chromecast”.

There are two installation methods available for Plex Assistant. One of the methods is using HACS, which is an easy way to upload custom configurations, and the other is manually.

Since I don’t have HACS setup yet, I’m going to go with the manual method which is really easy to do.


Step 1: Create Custom Components Directory

First, install the File Editor addon if you haven’t already. You can find this under Supervisor > Add On Store. Once installed, you choose pin it to your sidebar for quick access.

Click File Editor from your sidebar and then select the folder.

Check is a custom_components folder exists. If not, then click New Folder.

Create a new folder called custom_components.

Then, click the newly created folder. Create a subfolder called plex_assistant. Keep this webpage open for the time being, we will need to access it again in Step 3.


Step 2: Download and Extract Plex Assistant Files

Now that the directory is created, the next step is to download the required Plex Assistant files to your computer.

Open a new browser tab and navigate to the Plex Assistant Github page to download the files.

Once there, click the green CODE button > Download Zip.

Right click the zipped folder, extract all, and then browse to the plex_assistant folder.


Step 3: Upload Plex Assistant Files to Home Assistant

In Home Click the UP arrow to upload files. Browse the location you extracted the files and upload them one at a time.


Step 4: Add Configuration to Configuration.yaml

Add the following code to your yaml config file.

plex_assistant:
  url: 'http://192.168.68.137:32400'
  token: '5yeV9E6FBpV14U8am3GM'
  default_cast: 'Living Room TV'
  language: 'en'
  tts_errors: true

URL and token are required fields, the rest are optional.

The URL is the IP address of your Plex media server.

To find your Plex token, open the Plex UI. Find a Movie> Get Info > View XML. In the URL, scroll to the far right and copy the Plex-Token= XYZ field


Step 5: Add Plex Assistant Sensor to Configuration.yaml

Plex Assistant includes a sensor to display the names of currently connected devices as well as the machine ID of Plex clients.

In File Browser, go to /config/configuration.yaml. Add this sensor and save.

sensor:
- platform: plex_assistant

It should now look like this:


Step 6: Restart Home Assistant

After saving the configuration file, restart Home Assistant by going to Supervisor > System > Reboot Host.


Step 7: Add IFTTT to Home Assistant

  1. In your Home Assistant sidebar, click Configurations > Integrations > Add Integration.
  2. Search for IFTTT and follow the instructions.
  3. Copy the URL; you’ll need it the next step. Note that the URL won’t be shown again, so be sure to copy it.
  4. Then, click finish.

Step 8: Configure IFTTT Applet

  1. Go to Ifttt.com and sign in. Then create a new applet.
  2. Click Add next to the black “If This” button and select Google Assistant.
  3. Click the “Say phrase with text ingredient” option.
  4. Click Connect, and then select the Google account used for your Google Home devices.

After giving IFTTT permission to your Google Home, you can choose up to 3 trigger phrases to invoke the Plex Assistant requests.

I recommend something like this:

  • tell plex $
  • have plex $
  • open plex and $

If you want Google to respond to you, you could enter a phrase in the last box as well. Click Create Trigger once complete.

On the Then That screen, click Add.

Search for Webhooks, then click Make a Web Request. Then click Connect.

  • URL field: enter the URL you saved earlier.
  • Method: Post
  • Content Type: application/json
  • Body: Copy and paste this: { "action": "call_service", "service": "plex_assistant.command", "command": "{{TextField}}" }

Then click Create action and then finish on the next screen.

Step 9: Create Home Assistant Automation

  • Go to “Configuration” in your sidebar
  • Click “Blueprints”, then “Import Blueprint”
  • Paste this into the URL field https://gist.github.com/maykar/11f46cdfab0562e683557403b2aa88b4
  • Click “Preview Blueprint”, then “Import Blueprint”
  • Find “Plex Assistant IFTTT Automation” in the list and click “Create Automation”
  • Type anything on the last line (HA currently requires any interaction to save)
  • Hit “Save”

Step 10: Using the Plex Sensor to find out Casting Device Names

The next step is to find out what your Plex devices are called (note that these are probably not the same as your Home Assistant entities) so you can quickly and easily cast to them from Google Assistant.

You can find these names out by going to Configuration > Entities. Then click Plex Assistant Devices > Settings.

Here’s how Plex sees all of my devices.

To any of these devices, I can simply say “Hey Google, tell plex to play Game of Thrones on Living Room Chromecast.”

Other phrases I’ve tested are:

  • Hey Google, tell plex to play Ondeck Game of Thrones
  • Hey Google, tell Plex to stop.
  • Hey Google, tell Plex to play Gold Rush season 11 episode 5 on Pixel 5.

Step 11: (Optional) Setting a Default Cast Device

At this stage, everything should now be working. I’m really impressed with how well everything works and how responsive the commands are.

One of the things you might want to do now is set a default device in your configuration.yaml file.

For example, if you primarily watch Plex in the living room, you should add that as your default device so you don’t have to always have to append “on Living Room Chromecast”

To do this, you would edit your plex_assistant configuration to look like this:

plex_assistant:
  url: 'http://192.168.68.137:32400'
  token: 'tH1s1Sy0uRT0k3n44'
  default_cast: 'Living Room TV'
  language: 'en'
  tts_errors: true
  aliases:
    Living Room TV: TV0565124
    Bedroom TV: Samsung_66585

Updating Plex sensor when adding new devices

If you add new Plex devices, you can tell Plex Assistant to updating your devices by using the command:

“Hey Google, tell Plex to update sensor.”


Wrapping Up

Hopefully this guide gets you started with casting Plex TV shows and movies to your Chromecasts and other casting devices simply. If using HACS – you can simply search for the “Plex Assistant” integration and skip steps 1-4.


My Favorite Home Assistant Devices

Below are some of the Home Assistant-compatible devices I personally use in my home. I highly recommend each of them.

The full list of all Home Assistant compatible & recommended devices I use can be found on my Equipment List page.

8 comments

You may also like

8 comments

John June 12, 2021 - 10:16 am

Nice Tutorial!

Just one question. Will plex assistant and your tutorial work to play music aswell?

Reply
Danny June 14, 2021 - 1:19 pm

I haven’t tried it with music so I’m not 100% sure, but I assume if you have music files visible in Plex, then you should be able to.

Reply
JOHN UNINA August 29, 2021 - 8:03 am

Thank you so much for documenting this. I’m now up and running.

Reply
Danny September 1, 2021 - 4:19 am

Hey John,

You are very welcome! I’m glad to see my Plex Assistant guide still works as of August 2021.

Reply
Taylor September 9, 2021 - 8:43 am

Does this require a plex pass to function? Can a device other than rasp pi be used (windows app)? Did you install the home assistant operating system or home assistant supervisor?

Would love to get this to function for music.

Reply
Danny September 9, 2021 - 1:31 pm

I don’t think this requires a Plex Pass, although I have a lifetime pass and don’t have a way to confirm that.

I have Home Assistant w/ Supervisor installed on a VMWare Workstation VM on my Windows 10 PC.

Reply
xray September 20, 2021 - 10:18 pm

If you don’t specify a cast device, will it cast on the local device? For example, I have a bunch of Google Minis around the house. If I give a voice command to use Plex to play music, will it just start playing on whatever device heard the command? Or do I need to say use Plex to play music on a specific device name?

Reply
Danny September 20, 2021 - 10:37 pm

I believe you need to specify a default cast device in your configuration.yaml (step 4 of my guide). You are welcome to leave the default_cast: out of your config file as a quick test to see what happens, but mine is already setup with a default one so I’m not able to test that out.

Reply

Leave a Comment