[OBSOLETE] Plex Home Theatre Manager SmartApp

Hey all,

This is a SmartApp which allows you to view the state of, and if your client supports HTTP control, control playback / volume of your devices. Some Plex clients do not allow control over HTTP (such as Xbox One / PS). You need to go into the Plex clients settings and enable the ‘HTTP control’ feature.

I personally use a Raspberry Pi with RasPlex; This distro is fast / compact and works with HTTP control. I highly recommend it.

Simply knowing the state of your Plex devices in SmarThings lets other SmartApps react to that information… Good examples are: ‘Someone is at the door, pause playback’, or ‘Plex is playing, dim the living room lights’. (e.g. see Rule Machine)

Updates

08/02/2016

  • Added. Support for Xbox One, Viewing status only, actions do not work as the Xbox One app does not support HTTP control.

07/02/2016

  • Added: New option in SmartApp for selecting specific clients. We will only install devices for those which you select. Items which were previously installed which you unselect will be unsubscribed (so you can manually delete) but we will not delete the device (it may be registered with other SmartApps). If you have used Plex Manager before this update, the client selection page may not have your clients selected, just select them and continue. Thanks @toliver182

06/02/2016

  • Added: New multi attribute tile which is much more attractive (thanks @tonesto7)
  • Change: Changed the method used for discovering players. It is more reliable, and your player does not have to be active.
  • Fix: Stop button now stops playback, rather than toggling play/pause
  • Fix: Updated authentication with Plex to support complex passwords. Thanks to @btk

Fixed issue where when movies are playing there is no feedback in the device

Known Issues

  • Channel playback does not register in the Plex device type
  • Uninstalling can throw an error stating that the app has subscriptions to devices (see my post below for uninstalling
  • Volume state is not initially set

Instructions

Firstly, make sure that you have the Plex Server setup (www.plex.tv) and at least one client (I have only tested with RasPlex, but this has been confirmed to work with other devices which support HTTP control)

Install the device type and SmartApp. Instructions are found at the top of the code:

Device type: SmartThings/PlexHomeTheatre.groovy at master · iBeech/SmartThings · GitHub
SmartApp: SmartThings/PlexManager.groovy at master · iBeech/SmartThings · GitHub

Install the Plex Manager SmartApp in SmartThings

  1. Goto your mobile device and open SmartThings
  2. Got the Marketplace tab at the bottom
  3. Tap SmartApps’
  4. Scroll to the bottom and tap My Apps’
  5. Tap ‘Plex Manager’
  6. Fill in the details that have been requested and click ‘Next’
  7. Pick the clients you want to add to SmartThings and hit ‘Done’
  8. Tap ‘Done’ and go back to ‘Things’, whrere you will see your Plex devices there
  9. If you ever have another device you want to add, just open up the SmartApp, and pick the device from the list and hit ‘Done’

If you are having any problems, please uninstall the SmartApp, goto the IDE (where you installed the devicetype and SmartApp code) and click the ‘Logs’ button. Reinstall the SmartApp via your mobile phone and post the logs here for me. Please ensure you check the logs for your username and password before posting!

22 Likes

@iBeech this looks amazing!!! I’ve been a user of the Plex Integration app to control my hue lights so your app is a major step forward. I look forward to trying it later.

One question, have you been able to test with Chromecasts? My one issue with Plex Integration has always been that I use my phone to control playback on either my living room or bedroom Chromecasts. As Plex reports it is as my phone each time (rather than a particular Chromecast) it’s nearly impossible to control different sets of lights based upon my current position.

Keep up the top work

This is awesome! Thanks very much! I wonder if I can integrate this now with Amazon Echo and use commands to pause and resume playing by voice?

1 Like

it is registered as a switch- so if you can currently send ‘turn this device off’ or ‘turn this device on’ you will be able to get echo to work with it.

As for Chromecasts, i’m not sure as i don’t own one- if you could test and find out that would be great. I’d be happy to do what I can to help.

I can also confirm, after testing, that this SmartApp picks up events which are triggered from Plex itself. So if you use the Plex app to pause playback, it will still trigger the event in SmartThings.

I am getting these as errors.
When I save the configuration I get a red error message that seems to go away before I can read it then it seems to save it.

However I’m not getting anything come back:

87c1fd8a-9830-4cc8-a392-da646f073932 7:58:09 PM: debug getChildDevices(false), children=0
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:09 PM: debug Parsing /status/sessions
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:09 PM: debug Parsing /clients
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:07 PM: debug Hit Exception groovyx.net.http.HttpResponseException: Unauthorized on [uri:https://plex.tv/users/sign_in.json?user[login]=########################&user[password]=######################, headers:[X-Plex-Client-Identifier:Plex, X-Plex-Product:Device, X-Plex-Version:1.0], requestContentType:application/json]
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:06 PM: debug Getting authentication token for Plex Server 192.168.0.10
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:06 PM: debug The GET path is: /status/sessions
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:06 PM: debug Executing ‘updateClientStatus’
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:06 PM: debug Polling for PHT state
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:02 PM: debug getChildDevices(false), children=0
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:02 PM: debug Parsing /status/sessions
87c1fd8a-9830-4cc8-a392-da646f073932 7:58:02 PM: debug Parsing /clients

I’ve only got that error before when my Plex.tv username / password was incorrect

Got some more…

87c1fd8a-9830-4cc8-a392-da646f073932 8:01:39 PM: debug The GET path is: /status/sessions
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:39 PM: debug Executing ‘updateClientStatus’
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:39 PM: debug Polling for PHT state
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:40 PM: error org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. @ line 87
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:39 PM: error org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. @ line 87
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:39 PM: error org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. @ line 87
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:36 PM: error org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. @ line 87
87c1fd8a-9830-4cc8-a392-da646f073932 8:01:35 PM: error org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog. @ line 87

If your username / password are incorrect, you are probably seeing alot of exceptions haha. Could you goto www.plex.tv and double check the username and password you entered into smartthings works?

I’ve just updated the Plex Manager code so that you won’t get spammed with errors / exceptions when you don’t have an authentication token.

Ok I think I signed in ok now - How long does it take to pull over the device’s?

Once you’ve clicked ‘Done’ it scans and adds- its pretty quick. Your device has to be on and connected to plex for it to work. If it wasnt, just open the Smartapp settings and hit done again to re-add. I have just updated the Plex Manager so that it regularly checks for new clients

This is great! For clarification, you have to be using an installation of PHT as the client, correct? Not official mobile apps (or Android TV devices)?

Unfortunately, I have not tested anything other than PHT. I can try with mobile devices. I can’t see why they wouldnt work.

Great, thanks! This would be awesome for when I’m using my Nexus Player or Xbox One client.

I can test Xbox One and iPhone. I’ll look to do this tomorrow :smile:

1 Like

I’m using a roku with the official plex client. This doesnt seem to pick it up. Thoughts?

I’ll private message you with some steps to help me debug, if that’s OK?

Sure, feel free [20chars]

How do i remove the app?

if i try to remove the app it tells me its still in use by a device.

If i try to remove the device it says its still in use by an app

Yeah, apologies- its a SmartThings thing, where all subscriptions have be removed. But for some reason, even though I call unsubscribe in the uninstalled method, it seems to check if there are any subscriptions before it executes uninstalled. Thus the unsubscribe method is never called (sigh).

A quick fix is to:

  1. Open the SmartApp code
  2. Locate the line which starts ‘def updated() {’
  3. Replace everything within the curly braces with ‘unsubscribe()’
  4. Hit ‘Save’ then ‘Publish’ -> ‘For me only’
  5. Open the SmartApp on your device, and hit ‘Done’
  6. Now try to delete it

I’d love your feedback on the app, so that I can make it better.

I’m loving it so far, just want to remove and set it up again.

I tried what you suggested, however it didnt work.

here is my log

1ad9e9b7-dda3-4e95-b72c-1a2cbda3416c  19:58:22 GMT: error physicalgraph.exception.ConflictException: Device still in use. Remove from any SmartApps or Dashboards, then try again @ line 59
1ad9e9b7-dda3-4e95-b72c-1a2cbda3416c  19:58:22 GMT: warn DEPRECATION: You no longer need to call 'unsubscribe' within the 'uninstalled' method.
1ad9e9b7-dda3-4e95-b72c-1a2cbda3416c  19:58:22 GMT: debug getChildDevices(false), children=1
1ad9e9b7-dda3-4e95-b72c-1a2cbda3416c  19:58:22 GMT: warn DEPRECATION: You no longer need to call 'unsubscribe' within the 'uninstalled' method