Installation | Configuration | Cast Devices | Commands
Google Assistant Triggers | HA Conversation Setup
Plex Assistant is a Home Assistant component to allow Google Assistant, Home Assistant's conversation integration, and more to cast Plex media to Google devices and Plex clients. You could use this component with anything that can make a service call to HA as well (see the automations in the Google Assistant trigger guides for IFTTT and DialogFlow as a starting point).
Example: "Hey Google, tell Plex to play The Walking Dead on the Downstairs TV."
You can use the component's service (plex_assistant.command
) to call the commands however you'd like. Visit the services tab in HA's Developer Tools to test it out.
Example HA service call:
service: plex_assistant.command
data:
command: Play Breaking Bad
Music and audio aren't built in yet, only shows and movies at the moment.
Install by using one of the methods below:
-
Install with HACS: Search integrations for "Plex Assistant", select and hit install. Add the configuration (see below) to your configuration.yaml file.
-
Install Manually: Install this component by copying all of these files to
/custom_components/plex_assistant/
. Add the configuration (see below) to your configuration.yaml file.
Add config to your configuration.yaml file.
Key | Default | Necessity | Description |
---|---|---|---|
url | Required | The full url to your Plex instance including port. | |
token | Required | Your Plex token. How to find your Plex token. | |
default_cast | Optional | The name of the cast device to use if none is specified. | |
language | 'en' | Optional | Language code (Supported Languages). |
tts_errors | true | Optional | Will speak errors on the selected cast device. For example: when the specified media wasn't found. |
aliases | Optional | Set alias names for your devices. Example below, set what you want to call it then it's actual name or machine ID. |
Sample Config
plex_assistant:
url: 'http://192.168.1.3:32400'
token: 'tH1s1Sy0uRT0k3n'
default_cast: 'Downstairs TV'
language: 'en'
tts_errors: true
aliases:
Downstairs TV: TV0565124
Upstairs TV: Samsung_66585
This component does not use HA's media_player entities, it automatically detects compatible devices (Google Cast devices and Plex Clients). It will use the name from the devices themselves. Use the companion sensor to get a list of compatible devices with their names/IDs.
Plex Assistant includes a sensor to display the names of currently connected devices as well as the machine ID of Plex clients. This is to help with config and troubleshooting.
Add the sensor by including the code below in your configuration.yaml file.
sensor:
- platform: plex_assistant
To update the sensor send the command "update sensor" to Plex Assistant either through your voice assistant (e.g. "Hey Google, tell Plex to update sensor."
) or as a HA service call. The sensor is also updated any time Plex Assistant is sent a command. To view the sensor results, navigate to "Developer Tools" in HA's sidebar and click "States", then find sensor.plex_assistant_devices
in the list below.
Plex clients must be open in order to be detected or recieve commands from this component, Plex can sometimes take around a minute to detect that a client is active/inactive.
You must restart after installation and configuration, you may want to setup Google Assistant triggers or HA's conversation intergration first as they will also require a restart. Instructions for each below.
You can either use IFTTT or DialogFlow to trigger Plex Assistant with Google Assistant. IFTTT is the easiest way to set this up, but only if IFTTT supports your language. DialogFlow is a bit more involved and has some quirks, but has support for more languages.
IFTTT Setup Guide
- Go to "Configuration" in your HA sidebar and select "Integrations"
- Hit the add button and search for "IFTTT" and click configure.
- Follow the on screen instructions.
- Copy or save the URL that is displayed at the end, we'll need it later and it won't be shown again.
- Click "Finish"
Visit ifttt.com and sign up or sign in.
- Click "Explore" in the top right, then hit the plus sign to make your own applet from scratch
- Press the plus sign next to "If". Search for and select "Google Assistant"
- Select "Say phrase with text ingredient"
Now you can select how you want to trigger this service, you can select up to 3 ways to invoke it. I use things like tell plex to $
or have plex $
. The dollar sign will be the phrase sent to this component. See currently supported commands below). You can also set a response from the Google Assistant if you'd like. Select your language (as long as it's supported, see list above), then hit "Create Trigger" to continue.
- Press the plus sign next to "Then"
- Search for and select "Webhooks", then select "Make a web request"
- In the URL field enter the webhook URL HA provided you earlier
- Select method "Post" and content type "application/json"
- Then copy and paste the code below into the body field
{ "action": "call_service", "service": "plex_assistant.command", "command": "{{TextField}}" }
Finally, add the following automation to your Home Assistant configuration.yaml:
automation:
- alias: Plex Assistant Automation
trigger:
- event_data:
action: call_service
event_type: ifttt_webhook_received
platform: event
condition:
condition: template
value_template: "{{ trigger.event.data.service == 'plex_assistant.command' }}"
action:
- data_template:
command: "{{ trigger.event.data.command }}"
service_template: '{{ trigger.event.data.service }}'
If you prefer Node Red to HA's automations, @1h8fulkat has shared a Node Red Flow to do this.
Either refresh your automations or restart after adding the automation.
DialogFlow Setup Guide
- Go to "Configuration" in your HA sidebar and select "Integrations"
- Hit the add button and search for "Dialogflow".
- Copy or save the URL that is displayed, we'll need it later and it won't be shown again.
- Click "Finish"
Visit https://dialogflow.cloud.google.com/ and sign up or sign in. Keep going until you get to the "Welcome to Dialogflow!" page with "Create Agent" in the sidebar.
- Click on Create Agent and Type "Plex_Assistant" as the agent name and select "Create"
- Now select "Fulfillment" in the sidebar and enable "Webhook"
- Enter the "URL" Home Assistant provided us earlier, scroll down and click "Save"
- Now select "Intents" in the sidebar and hit the "Create Intent" button.
- Select "ADD PARAMETERS AND ACTION" and enter "Plex" as the action name.
- Check the checkbox under "Required"
- Under "Parameter Name" put "command", under "Entity" put "@sys.any", and under "Value" put "$command"
- Now click "ADD TRAINING PHRASES"
- Create a phrase and type in "command"
- Then double click on the word "command" you just entered and select "@sys.any:command"
- Scroll to the bottom and expand "Fulfillment" then click "ENABLE FULFILLMENT"
- Turn on "Enable webhook call for this intent"
- Expand "Responses" turn on “Set this intent as end of conversation”
- At the top of the page enter "Plex" for the intent name and hit "Save"
- On the left side of the page hit "Integrations", then "Integration Settings"
- Click the space under "Explicit invocation", select "Plex"
- Type "Plex" in "Implicit invocation"
- You may need to hit the test button and accept terms of service before next step
- Click "Manage assistant app", then "Decide how your action is invoked"
- Under "Display Name" type "Plex" then hit save in the top right (it may give an error, but thats okay).
Add the following to your configuration.yaml
file
intent_script:
Plex:
speech:
text: Command sent to Plex.
action:
- service_template: plex_assistant.command
data_template:
command: "{{command}}"
You can now trigger Plex Assistant by saying "Hey Google, tell plex to..." or "Hey Google, ask plex to..."
Restart after adding the above.
Language | Code | IFTTT | DialogFlow |
---|---|---|---|
Dutch | "nl" |
❌ | ✔️ |
English | "en" |
✔️ | ✔️ |
French | "fr" |
✔️ | ✔️ |
German | "de" |
✔️ | ✔️ |
Italian | "it" |
✔️ | ✔️ |
Swedish | "sv" |
❌ | ✔️ |
To use Plex Assistant with Home Assistant's conversation integration simply add the code below to your configuration.yaml file. Using the conversation integration will work with any of the languages from the table above.
conversation:
intents:
PlexAssistant:
# These trigger commands can be changed to suit your needs.
- "Tell Plex to {command}"
- "{command} with Plex"
intent_script:
PlexAssistant:
speech:
text: Command sent to Plex.
action:
service: plex_assistant.command
data_template:
command: "{{command}}"
A show or movie's title and the Chromecast device used in your phrase are processed using a fuzzy search. Meaning it will select the closest match using your Plex media titles and available cast device names. "play walk in deed on the dawn tee"
would become "Play The Walking Dead on the Downstairs TV."
. This even works for partial matches. play Pets 2
will match The Secret Life of Pets 2
.
"play the latest episode of Breaking Bad on the Living Room TV"
"play unwatched breaking bad"
"play Breaking Bad"
"play Pets 2 on the Kitchen Chromecast"
"play ondeck"
"play ondeck movies"
"play season 1 episode 3 of The Simpsons"
"play first season second episode of Taskmaster on the Theater System"
play
pause
stop
jump forward
jump back
Be sure to add the name of the device to control commands if it is not the default device. "stop downstairs tv"
.
If no cast device is specified in your command, the default_cast
device set in your config is used. A cast device will only be found if at the end of the command and when preceded with the word "on"
or words "on the"
. Example: "play friends ON downstairs tv"
I've tried to take into account many different ways that commands could be phrased. If you find a phrase that isn't working and you feel should be implemented, please make an issue.