[OBSOLETE] Plex Home Theatre Manager SmartApp

Hey guys,

im very new to smart things and have multiple apps setup. But for some reason this wont add to myapps. I followed the instructions, but im probably doing something stupid. Any help would be great.

Hi Andrew, what error are you getting?

Also if the issue is happening when pasting the code from GitHub then I would suggest changing to raw view and then selecting all, sometimes copying in the standard view selects other stuff

I just implemented this yesterday [from the OP Github DTH and SA] and can confirm that I am getting status from multiple clients, and that it is not accepting control commands with any of them. I have verified that I can open up the Plex Remote from iOS or WebUI and control those same clients, and that they show player in the provides from the devices.xml. I really want to get rid of the polling, so I will look at Plex2Smartthings for that, but from what I understand only this system allows sending control back to it which I would like to get working (If the door is opened, Pause playback for example). Below is an example of a typical client in my list where I see status changes, but it does not respond to commands.

<Device name="Apple TV" publicAddress="xxx.xxx.xxx.xxx" product="Plex for Apple TV" productVersion="1.5" platform="tvOS" platformVersion="10.1" device="Apple TV" model="5,3" vendor="" provides="client,player,pubsub-player" clientIdentifier="ID Hash Here" version="1.5" id="79758600" token="ID Hash Here" createdAt="1478218863" lastSeenAt="1481847818" screenResolution="1920x1080" screenDensity="1">
<Connection uri=""/>

Hi I think this has been broken for a while… I suspect Plex changes the API

However… I’ve been playing for the last hour, and I think the code currently connects to the server to control the device… but the documentation I have been looking at appears to refer to direct interaction with the device…

Can you try the code below… I’ve bodged in the code so only a stop command will work… so you will need to manually play, then use ST to send the stop command… if that works then I believe I can re-code the lot so control works again…


Let me know how you get on… also note the attached code is heavily modified from the version on git hub… but does include a switch so you can turn off polling should you wish to poll via Plex2Smartthings/PlexPlus


I’ve just made further amendments to the code linked above… should hopefully all work , but let me know how you get on!

Edit: you will need to uninstall and re-install…

I can’t test this yet, but it looks like a minor typo on the previous (wrong line commented out). I look forward to testing this late tonight or early tomorrow. I was reading into it some as well, and I think there may be a way to pass it through the server still with including the X-Plex-Client-Identifier header for the target Player and a commandID. Hopefully you will merge the client identification information into your SA so that I do not need to manually enter it all. I also need to test that at the same time.

No there were quite a few things “wrong”, it seems some devices don’t support comms from the server for some reason… but give it a go and let me know if it works, no idea if Apple TV allows http control or not… if you end up with a * next to the device in the list it won’t work, but not to say all without it will work…

When you mean my app I assume you mean PlexPlus? If so the Plex token isn’t used there it’s used in the exe so you will need to obtain it…

Edit: I’ve re-read a few times and don’t think that’s what you mean? If you could explain?

So your latest code doesn’t work for me and I’ve been playing around with my Apple TV Client and a web browser and I have been able to pass commands that are working to control the playback states passing messages to the server.


I see that all the pieces are available already, it should just be a matter of putting the deviceID as an additional header in your new executeClientRequest function, but I am having a hard time figuring out how the object members work in this system. Also, my previous message was about your function named previous where you had the executeRequest active instead of the executeClientRequest.

1 Like

I was having some weird issues so I started over from the OP Code, and I got the commands working now!!

See 2 posts down for github link of latest instance.

1 Like

Ahh I see what you mean now! Good work on getting it working! I’ll take a proper look later in the week, I’m thinking of making a self contained DTH so commands are sent direct from the device, but not sure if a DTH can can do GET requests directly, this would provide control using PlexPlus also and no need for a separate app just for the control method…

I think there is an issue with your solution though (although nothing technically wrong with your code) as I noticed while playing yesterday, the Roku stick seems to present a different ID when being added to when reporting play state! No idea why! Not sure if it’s a roku issue or plex but the Plex API doesn’t seem very consistent in its implementation!

I added [Jakes’] features (sans client direct port communications) and put it here:

Ph4r’s Fork of PlexManager SmartApp


Good work saves me trying to work it all out :slight_smile:

Will give it a try later…


Can you un-comment the below line in your code, this is needed to identify state in some instances:

//def address = getPHTAddress(pht.deviceNetworkId);

Other than that looks good, to late to test properly, I can see in some instances that it doesn’t work to control some devices, but it’s highly possible that these do not support control… I’ll test some of the same devices using direct control and see if that works…

Also have you created a new DTH? I see you have added in the other control commands?

I have them on an in-progress DTH that I put in a new branch on my GitHub. I might have a typo somewhere, as they do not seem to work consistently, and the response is a bit slower than using the native plex app control for example. I’ve been doing my testing mostly on the aTV4, but the unit I really want to use this with is a PC in another room and that one is behaving very inconsistently. I may need to go back to trying your client direct commands, but they did not work at all with the aTV4 which is why I implemented the server commands. What is the reference that you used for sending client commands, as I don’t see it that way in the official API Docs I was looking at?

1 Like

So your code seems to work with Plex Media Center (No longer supported by Plex) I think… but doesn’t work with the Windows 10 App that replaced it…

But I don’t think works with Roku, which mine did, but I don’t think there is a single answer, some things work with one method and some with the other method… I think generally the API is a bit of a mess, with no consistency… including Plex owned apps not reporting full capability!!

I’ve just spotted I uploaded the wrong version of my code as still has some values I was using to test… Play/pause/stop are triggering the wrong actions… but also the playpause toggle in the original version or mine doesn’t appear to toggle, so need to add some code fort this too, based on current device state I would assume…

I was referencing the below documentation…

Looks like a fun “free time” activity for later this week or next. I’ll add this a setting to the DTH, and dot append it after the command to be parsed by the SA, as each device may need different settings. Since the official Plex API suggests that Server Comms is the directive, I suggest that if no value is set, Server Commands should be assumed. I wish I could send the commands from the DTH directly instead of bouncing them to the SA to handle,

input name: "CommandTarget", type: "enum", title: "Command Target", options: ["Server", "Client"], description: "Select Command Target", required: true

I think the passing will need to be like this:

sendEvent(name: "switch", value: device.deviceNetworkId + "." + command + "." + $CommandTarget);

Sounds good mate, let me know if you make a start on this, otherwise I’ll give it a go over Christmas…

What’s stopping you doing it in the DTH though? Are sending get requests restricted?

Love the app so far! Thanks for making this. Couple of questions I have:

  1. I’ve noticed a delay in status for playback. Seems to be about 10 seconds after I pause the movie that it changes status. Is this by design or is there to make this more instant?

  2. Regarding CoRE integration. I see that in the log of Plex HT Manager it mentions “playback type” Do you know of a way I can integrate that into CoRE so that it only dims light if “playback type” is movie?

Thanks again!

EDIT: I see question 1 was answered a couple of times.

The event you would need to pull is playbackType, but I don’t know if that is something CoRE can pick up on, probably worth asking in the CoRE queries thread…

The alternative is to use PlexPlus… you can add the plex HT device in here and it already has the logic to be able to determine media type and adjust lights accordingly… you don’t have to use the exe in this case you can just add the device you created in this app in to Plex Plus… however if you do use the exe then the latency can be much lower between state changes as the polling takes place external to smart things…


I am curious why the app is picking up all of my devices (phones, tablets) but not the Plex server on my pc.

If i choose Show all devices regardless of Capability it shows my PC. Im am reading through the thread but just curious on the logic.

Also, I am getting an unknown error when trying to save Plex Manager. It happens after i save it (if confirms then throws up an error).