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

by Danny
0 comment

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.

0 comment

You may also like

Leave a Comment