PlexPlus (with Plex2SmartThings)
Using either a Windows EXE, direct from Plex webhooks (Plex Pass only) or a Plex custom device type to translate status changes in Plex Media Server and passing these status changes to the Plex Plus SmartThings App to control lighting and switches. Different statuses include Play, Pause, Stop & Trailer
Note: This is a modified version of @ChristianH’s Excellent Plex2SmartThings exe.
Code and Program Location:
- Recieve Plex events from either the Plex2SmartThings exe, the Plex Server (Plex Pass only) or the Plex HT device type.
- Player identification (IP Address, Player Name, User Name, Device Type)
- State identification: (Play, Pause, Stop)
- Content identification (Movie, TV Episode, Music or Trailer)
- SmartThings Mode restrictions
- Scenes include control over (on/off/color/mode/switches)
- Switches can return to original state on stop
- Lights can be set to only change if already on
- Delay scene changes for pause and stop actions
- Create and change a virtual device type so that events can be triggered to other apps
- Plex2SmartThings - Windows Application - This is the most reliable method at the moment due to ST reliability issues and also should be able to handle any client and can select based on many variables. A computer will need to run a program to poll Plex, so will need to be switched on when you are using Plex for this to work (This does not need to be on the same computer as the Plex server)
- Plex Webhook (Requires Plex Pass) - Plex can now directly talk to SmartThings, to get the webhook URL install the SmartApp using the instructions below, open Live Logging in IDE, enable debugging then press done on the app, the webhook URL will be posted in the Live Logging. Instructions on how to setup Plex can be found here, please also ensure that your plex server is up to date: https://support.plex.tv/hc/en-us/articles/115002267687-Webhooks
- Plex HT Manager - Non Windows / NAS etc. - This is an app and custom device type, which uses ST to poll Plex every 10 seconds, as such is subject to ST reliability issues, but offers greater server support and easier to setup - [RELEASE] Plex Home Theatre Manager SmartApp
- Plex Plus Device Type (Optional) - Now you can install this device type under “My Device Handlers” and then create new devices in the Smart App then associate the device under the “Trigger These Actions” section. This allows you to interface with other applications such as Core and Rule Machine.
How To Install:
1. Create the SmartApp
PLEASE NOTE GITHUB INTEGRATION IS NOW LIVE:
A. Go to your IDE location, the below link should re-direct you to the correct IDE location.
B. Select “From Code”
C. Paste App source code with the code from the file PlexPlus.groovy.
D. Save and publish the app for yourself.
E. Enable OAuth in IDE by going in to IDE > My Smart Apps > Plex Plus > App Settings > Enable OAuth.
F. Get the Token and API Endpoint values via one of the below methods:
- Open the PlexPlus smart app and click API Information for your region, you can then send it to your computer via email from the app.
- Enable debugging, open live logging in IDE and then open the app again and press done and values will be returned in Live Logging.
- If the above does not work (usually as ST have introduced a new region) then you can just get the App ID and Token from the “Last Event / App ID / Token” screen, but you will manually need to write this down.
- Configure the app online and note down the API Token and API Endpoint values.
2. Configure Your Chosen Polling Method (Choices detailed in “Additional Requirements section”)
If you have chosen Plex2SmartThings EXE continue below, otherwise follow the guide provided via the link in the “Additional Requirements” section then resume at step 4
A. Download Plex2SmartThings.exe and config.config. (I have also put a ZIP file containing all of these in the same folder)
B. Open the config.config file.
C. In config/smartThingsEndpoints fill in your API token and add the APP ID to the endpoint urls from the previous section.
<!ENTITY accessToken "123-123-123"> <!ENTITY appId "abc-abc-abc"> <!ENTITY ide "https://graph-eu01-euwest1.api.smartthings.com"> <!ENTITY plexStatusUrl "http://localhost:32400/status/sessions">
D. Be sure to also check that your IDE URL matches the URL in config.config, if you have the URL from the app then this should be correct, if you were unable to get this from the app then you willl need to copy from IDE, it’ll be somethign like “graph-na02-useast1.api.smartthings.com”
E. If Plex and this application is not running on the same server then enter the URL to the session status page of your Plex server in the plexStatusUrl attribute.
F. If you have Plex Pass users with PINs (and also possibly non Plex Pass users now) be sure to append your plex_token to the end of the url in the step above. (e.g. http://localhost:32400/status/sessions?X-Plex-Token=‘MYPLEXTOKEN’). To find your plex token follow this guide.
G. The polling interval and debugging can also be configured, however the standard value should suffice.
3. Run Plex2SmartThings
You can now run Plex2SmartThings.exe and the SmartApp should be notified whenever any media plays on plex.
To run this on mono you will need to download mono for Mac, or for Linux install “mono-complete”, the standard runtime doesn’t contain everything you need.
On Linux you can run “mono Plex2SmartThings.exe” or “mono Plex2SmartThings.exe &” to run in the background (“jobs” will show running instances and “kill $1” will kill process 1)
4. Configure the Smart App
Configuration should be self explanatory however come back here with any questions.
If using Plex2SmartThings EXE you will need to populate “Player name, User or IP” If you require device details from then the App has a section called “Last Event” which will tell you the details of the last event recieved.
5. Errors / Debugging
Plex2SmartThings.exe - SendGetRequest: the remote server returned and error: (403) Forbidden
There is an issue with the URL in config.config re-check section 2.D
The remote server returned an error: (401) Unauthorized.
You need to get the Plex token mentioned in section 2.F.
No error in the EXE and no “Last Event” present in the App
This is because SmartThings is not reciving an event, this is usually because the App ID or Token are incorrect, if you re-install the app these values will change and need to be setup again.
“Last Event” in the app, but hasn’t triggered the lights to change.
This is likely to that the “Room” is not configured correctly, re-check the name or IP you have setup
Live Logging - java.lang.NullPointerException: Cannot get property ‘authorities’ on null object @ line xx
You have not enabled OAuth in the parent app, go to Section 1.B.iii
I’ve played a video via Plex but no “Last Event” is showing
If the event is not appearing here then the config.config is not setup correctly and you will need to revisit step 2. (If using Plex2SmartThings) If using the Plex Webhook then either you have pasted in the URL incorrectly or your server is not up to date.