[OBSOLETE] Plex Home Theatre Manager SmartApp

Strange… I can’t seem to replicate the issue?

Hi sorry it took so long for me to back to you, busy week. Here are the logs below, personal info removed of course.

Ok so I took a look at the Plex Media center address.

I got an xml response when nothing was playing.

<MediaContainer size="0"></MediaContainer>

I did the same thing after playing a video and got the following response:

<MediaContainer size="1"> <Video addedAt="1251242078" art="" chapterSource="" contentRating="G" duration="8919840" guid="c" key="" librarySectionID="1" originallyAvailableAt="1968-04-05" rating="7.6" ratingKey="267" sessionKey="33" studio="" summary="movie" tagline="" thumb="" title="" type="movie" updatedAt="1458002392" year="1968"> <Media aspectRatio="1.85" audioChannels="2" audioCodec="mp3" bitrate="666" container="avi" duration="8919840" height="352" id="267" videoCodec="mpeg4" videoFrameRate="24p" videoResolution="sd" width="640"> <Part container="avi" duration="8919840" file="<path-to-filename>" id="267" key="/library/parts/267/file.avi" size="742352896"> <Stream bitDepth="8" bitrate="534" chromaSubsampling="4:2:0" codec="mpeg4" codecID="XVID" colorSpace="yuv" duration="8919827" frameRate="23.976" gmc="0" height="352" id="327" index="0" level="5" profile="asp" qpel="0" scanType="progressive" streamType="1" width="640"/> <Stream audioChannelLayout="stereo" bitrate="119" bitrateMode="vbr" channels="2" codec="mp3" codecID="55" duration="8919840" id="328" index="1" samplingRate="48000" selected="1" streamIdentifier="1" streamType="2"/> </Part> </Media> <Genre count="153" id="42" tag="Science Fiction"/> <Genre count="18" id="751" tag="Mystery"/> <Genre count="176" id="141" tag="Adventure"/> <Writer ../> <Role ../> <User id="1" thumb="<avatar>" title="<username>"/> <Player machineIdentifier="A0EC78E1-64C6-4DE0-89DD-AD2E4D96A9C6" platform="iOS" product="Plex for iOS" state="buffering" title="iphone"/> <TranscodeSession key="A32F7124-5DC0-4E30-B052-8C3C2B5DBDF3" throttled="0" progress="0" speed="0" duration="8919000" context="streaming" videoDecision="transcode" audioDecision="copy" protocol="hls" container="mpegts" videoCodec="h264" audioCodec="mp3" audioChannels="2"/> </Video> </MediaContainer>

Device logs
18a2a8e0-67ec-4cb3-9b77-1f988af9a537 10:26:48 PM: debug Executing 'on’
18a2a8e0-67ec-4cb3-9b77-1f988af9a537 10:26:46 PM: debug Executing 'setPlaybackTitle’
18a2a8e0-67ec-4cb3-9b77-1f988af9a537 10:26:46 PM: debug Executing ‘off’

App Logs
Clear
565e424e-5d0d-4a13-8c7e-9b5800b718ff 10:26:48 PM: debug Command: null
565e424e-5d0d-4a13-8c7e-9b5800b718ff 10:26:48 PM: debug Plex Home Theatre event received: pht.10.0.015.A0EC78E1-64C6-4DE0-89DD-AD2E4D96A9C6.10.0.0.2.play
565e424e-5d0d-4a13-8c7e-9b5800b718ff 10:26:46 PM: debug Command: null
565e424e-5d0d-4a13-8c7e-9b5800b718ff 10:26:46 PM: debug Plex Home Theatre event received: pht.10.0.015.A0EC78E1-64C6-4DE0-89DD-AD2E4D96A9C6.10.0.0.2.stop

I added the plex app in theSmartThings app and here are the logs for the app:
0880b11b-d514-465b-b095-d497765d308f 10:30:29 PM: debug The GET path is: /status/sessions
0880b11b-d514-465b-b095-d497765d308f 10:30:29 PM: debug Executing 'updateClientStatus’
0880b11b-d514-465b-b095-d497765d308f 10:30:29 PM: debug Polling for PHT state
0880b11b-d514-465b-b095-d497765d308f 10:30:28 PM: debug This PHT does not exist, creating a new one now
0880b11b-d514-465b-b095-d497765d308f 10:30:28 PM: debug getChildDevices(false), children=0
0880b11b-d514-465b-b095-d497765d308f 10:30:28 PM: info Updating PHT: Device Name with IP: A0EC78E1-64C6-4DE0-89DD-AD2E4D96A9C6 and machine identifier:
0880b11b-d514-465b-b095-d497765d308f 10:30:28 PM: debug Updated with settings: [selectedClients:[Device Name|A0EC78E1-64C6-4DE0-89DD-AD2E4D96A9C6|], plexPassword:, theHub:physicalgraph.app.HubWrapper@15bbe3bf, plexServerIP:, plexUserName:]
0880b11b-d514-465b-b095-d497765d308f 10:30:27 PM: debug The GET path is: /status/sessions
0880b11b-d514-465b-b095-d497765d308f 10:30:27 PM: debug Executing 'updateClientStatus’
0880b11b-d514-465b-b095-d497765d308f 10:30:27 PM: debug Polling for PHT state
0880b11b-d514-465b-b095-d497765d308f 10:30:27 PM: debug Installed with settings: [selectedClients:[Device Name|A0EC78E1-64C6-4DE0-89DD-AD2E4D96A9C6|], plexPassword:, theHub:physicalgraph.app.HubWrapper@3539842c, plexServerIP:, plexUserName:]
0880b11b-d514-465b-b095-d497765d308f 10:30:25 PM: debug Parsing plex.tv/devices.xml
0880b11b-d514-465b-b095-d497765d308f 10:30:24 PM: debug Executing 'getClientList’
0880b11b-d514-465b-b095-d497765d308f 10:30:20 PM: debug Parsing plex.tv/devices.xml
0880b11b-d514-465b-b095-d497765d308f 10:30:20 PM: debug Executing 'getClientList’
0880b11b-d514-465b-b095-d497765d308f 10:30:20 PM: debug Token is: pa7xusvLRApnP3axS6Cq
0880b11b-d514-465b-b095-d497765d308f 10:30:19 PM: debug Getting authentication token for Plex Server

Device logs looked the same

All Logs-
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:27 PM: debug The GET path is: /status/sessions
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:27 PM: debug Executing 'updateClientStatus’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:27 PM: debug Polling for PHT state
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:17 PM: debug The GET path is: /status/sessions
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:17 PM: debug Executing 'updateClientStatus’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:17 PM: debug Polling for PHT state
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:16 PM: debug The GET path is: /system/players/10.0.0.31/playback/play
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:16 PM: debug Executing 'playpause’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:16 PM: debug Command: play
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:16 PM: debug Plex Home Theatre event received: pht.10.0.0.15.Plex2L645M040461.10.0.0.31.play
6f4d4c89-4279-43c1-ae03-df90df41d33d 11:06:16 PM: debug Executing 'on’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:10 PM: debug The GET path is: /system/players/10.0.0.31/playback/play
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:10 PM: debug Executing 'playpause’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:10 PM: debug Command: pause
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:10 PM: debug Plex Home Theatre event received: pht.10.0.0.15.Plex2L645M040461.10.0.0.31.pause
6f4d4c89-4279-43c1-ae03-df90df41d33d 11:06:10 PM: debug Executing 'pause’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:07 PM: debug The GET path is: /status/sessions
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:07 PM: debug Executing 'updateClientStatus’
e734eee5-2759-479a-b92c-86b92528ba5a 11:06:07 PM: debug Polling for PHT state

Devices tried:
iPhone
Roku Stick

Hi @all3nt

Sorry have been on holiday, I’ve looked below, can you confirm that the “Device Name” below has been altered by yourself? and can you also confirm that you have manually removed the entiries below I have flagged, especially the one just before the password, as there should be an IP address here?

It appears that polling may not be working?

Can you also go in to IDE > My Locations > List Smart Apps > Plex Manager

And can you provide the values next to “Poll” and “appInstalled”

Hi @Entityxenon yes, I masked those values from the logs.

My SmarThings hub happens to be on a child router and not on the same as my Plex devices. I wonder if I need to port forward for the polling. I’ll give it a try on the same router and see.

Do happen to know the ports for polling?

I would suggest moving to the same router and seeing if it makes any difference before playing with port forwarding… I would assume that the ports would be http or https 80 / 443 I think from memory, but might not be that simple if on different subnets etc…

However can you get me the two values I mentioned in my previous post as well? Poll probably being the key one, should be set to true, if it’s not I’ll need to work back through Toms code to see if I can work out why it’s there and if something is broken, it’s difficult to troubleshoot when you can’t replicate the issue :slight_smile:

So I moved everything back to the same router but that made no difference for playing off my iPhone (Chromecasting). But I tested my Roku and it worked control wise. I can play and pause the movie. If I pause the movie on the Roku directly is the SmartThings app supposed to reflect the change in status? Also what rule app should I use to configure having my lights turn off when I play a video. I tested with rule machine and the rule didn’t seem to be firing when playing/pausing. Looks like it may be an issue with the iPhone app not accepting incoming http requests.

Both poll and app installed are true.

So…

Can you please confirm your exact issue you are seeing? If you change the status on the Roku this should update in ST within 10 seconds… I assume however that you are not seeing this because the polling does not appear to be working? - If you can confirm that this is the issue?

With regards to control, you are correct only devices supporting control can be controlled… the latest version of the code will put “[status]” on the end where you can only see status and not control… If you don’t have this already then I suggest being on up to date code is your first step to get this working…

Please completely uninstall the smart app and the device types in IDE itself, not just in the app, you will need to go in to each device in IDE and delete the code and the create brand new device types and smart apps… do not attempt to update the code without removing completely first you will end up with stranded devices…

If/when your status reporting is working then I would suggest using the below smart app, mostly because I wrote most of it…

BOk I have removed the apps and Plex devices and reinstalled everything on use and app. Currently the Plex manager and device type are not updating in real time and any updates I make are not playing or pausing Plex. This is kinda interesting considering it work last week. Anyways any suggestions. I can post whatever logs I need to. I am testing in the Roku Stick.

I took a look at the code and I noticed that it doesn’t look like I was getting responses back after the polling. I am going to play around with stuff to see if I can figure out why that is. I have checked the status/session url and I am getting s good response with correct xml (which reflects the state of my Roku).

The key question… In live logging is the app updating every 10 seconds? Is it doing anything? I’m away for the next couple of days, I will try to see if they have changed the RunIn logic or something, but a quick check on my phone and I don’t see anything in the KB…

Worst case I could Remote Desktop in otherwise I expect this is going to be a long slog…

Can you also confirm the URL you use to access IDE, wonder if the issue relates to the server farm you are on?

Am I doing something wrong? I can’t seem to select my server as a Client even with Plex Media Player running on the pc?

I have a projector hooked up to my server and usually play directly from it as a 3rd monitor. Is it not possible to list the server as a client?

Yeah shouldn’t be an issue will appear with the name of your media PC, if you still haven’t got it working can you please PM me the data found under the below URL, you’ll need to login to Plex TV first…

And if you can confirm if you are using the windows app from the app store or the downloaded media centre?

https://plex.tv/devices.xml

Thanks for offering the help! Seems that my desktop is now showing up as a device though… not sure why it didn’t show up right away but it is now!

Thanks.

1 Like

Hi All,

I’ve installed the device handler and smart app, configured my server and clients. I’m getting accurate reporting of whats playing and it updates every 10 seconds to reflect whats happening, but unfortunately I don’t seem to be able to control the play/pause from smartthings.

I’m using the latest PMS and PHT on mac os.

Log shows:

6:57:27 PM: trace Current playback type:episode
6:57:27 PM: trace Determined that Jarvis is: playing
6:57:27 PM: debug Checking Jarvis for updates
6:57:27 PM: debug getChildDevices(false), children=1
6:57:27 PM: debug Parsing /status/sessions
6:57:27 PM: trace in response(evt)
6:57:27 PM: debug The GET path is: /status/sessions
6:57:27 PM: debug Executing 'updateClientStatus’
6:57:27 PM: debug Polling for PHT state
6:57:23 PM: trace in response(evt)
6:57:23 PM: debug The GET path is: /system/players/172.16.0.100/playback/play
6:57:23 PM: debug Executing 'playpause’
6:57:23 PM: debug Command: pause
6:57:23 PM: debug Plex Home Theatre event received: pht.172.16.0.100.83eecb31-5e8d-458a-9f07-8404cdfdf9b1.172.16.0.100.pause

If anyone can suggest why the play pause commands aren’t affecting PHT, I’d appreciate the help.

Thanks in advance

Adam

While my device was showing, I’ve realized that I don’t have control of the device/device wont show up now that I removed it. I think that I found the issue though. The Windows App and server are not being registered Clients for providers they are only registered as either “provides=“controller,sync-target”” or “provides=“server”” where as all the devices that show up in my list of devices on the app are “provides=“client””.

<MediaContainer publicAddress="####ip####">
<Device name="" publicAddress="####ip####" product="Device" productVersion="1.0" platform=""    
platformVersion="" device="" model="" vendor="" provides="" clientIdentifier="Plex" version="1.0" id="" 
token="" createdAt="1474470027" lastSeenAt="1474913502" screenResolution=""
 screenDensity=""></Device>
<Device name="Plex Web (Chrome)" publicAddress="####ip####" product="Plex Web" productVersion="2.8.1" 
platform="Chrome" platformVersion="53.0" device="Windows" model="" vendor="" provides="player" 
clientIdentifier="" version="2.8.1" id="73414152" token="" 
createdAt="1474913447" lastSeenAt="1474913448" screenResolution="1920x950,1920x1080" screenDensity="">    
</Device>
<Device name="PC" publicAddress="####ip####" product="Plex Media Server" 
productVersion="1.1.4.2757-24ffd60" platform="Windows" platformVersion="10.0 (Build 10586)" device="PC" 
model="x64" vendor="Microsoft" provides="server" 
clientIdentifier="" version="1.1.4.2757-24ffd60" id="" 
token="" createdAt="1451612257" lastSeenAt="1474913448" screenResolution="" screenDensity="">
<Connection uri="http://####ip####:23859"/>
<Connection uri="http://192.168.0.101:32400"/>
</Device>
<Device name="Plex Web (Chrome)" publicAddress="####ip####" product="Plex Web" productVersion="2.9.0"    
platform="Chrome" platformVersion="53.0" device="Windows" model="hosted" vendor="" provides="player" 
clientIdentifier="" version="2.9.0" id="" 
token="" createdAt="1474648524" lastSeenAt="1474912751" 
screenResolution="1882x902,1920x1080" screenDensity="">
</Device>

<Device name="DESKTOP-WinApp" publicAddress="74.67.128.212" product="Plex for Windows" 
productVersion="3.0.69.0" platform="Windows" platformVersion="10.0.10586.589" device="x64" model="" vendor="" 
provides="controller,sync-target" clientIdentifier="1a8ea99e-1b73-4914-a3ec-ee3fc123dfcd" version="3.0.69.0" 
id="73402780" token="zxp8wbAD4cCBTxPmzp8y" createdAt="1474909932" lastSeenAt="1474909933" 
screenResolution="" screenDensity="">

<SyncList itemsCompleteCount="0" totalSize="0" version="1"/>
     
<Connection uri="http://192.168.0.101:32468"/>

</Device>

<Device name="" publicAddress="####ip####" product="Plex for Samsung" productVersion="1.012" 
platform="Samsung" platformVersion="4.0" device="TV UN46F5500" model="" vendor="" provides="client" 
clientIdentifier="mtchc5zte7qng" version="1.012" id="33617254" token="" 
createdAt="1440366846" lastSeenAt="1460845111" screenResolution="" screenDensity=""></Device>

</MediaContainer>

Not all players can be controlled, only those that accept incoming http requests… not idea if the app on MacOS does or doesn’t, but looks like it doesn’t…

Looks like the windows App only works as a player if you pay extra or have a plex pass subscription?

Perhaps that’s why it’s not reporting correctly? Try going in to the Plex App > settings > act as remote player - this seems to work to identify as a player…

@adamrhoades - may be a setting in settings that can help you… but again you need to find your device in https://plex.tv/devices.xml, when I looked at mine it’s returning two IP addresses as I have virtualbox installed, so my first IP is not my real network IP… no idea how to fix this though…

I don’t have the app running at the moment so can’t test in detail and I don’t have the time to look in to it for another few days…

I was able to edit the app code to have it pull in ‘status’ from other device types. I can now see my server and Windows10 app and Server.

It’s working as intended for now but maybe i’ll try the ‘act as remote player’ thing you mentioned if I have time.

The only other thing I had to do was change the IP address I was using in Plex, I was originally using my external IP but my static server IP is what I really needed to use.

1 Like

Great work on the app, one thing though.
I just installed this app, wanna use it with my apple tv 4th gen.
I get status such as play / stop updated.
But Is it possible to get pause status also?

Id love to have a different scenario with my lights when its paused.

Ps: I cant seem to find the plex device in rule machine or core, is there anything in particular I need todo to have the device displayed in either of rule / core?

If you install plex plus then this will allow you to control lighting on play, pause or stop and several other things…

For core and rule machine I think the device type should be media player if they have added it in either… but not sure what that will give you in terms of control. Like I say plex plus should give you the control you need…

Did you get any luck with this? If not it’s found as a Music Player, states being play, paused and stopped, RM shows the states, Core I think you need to provide them as the Value manually… Otherwise the Plex plus app is the easy route and handles a lot of things such as fast forward being reported as a pause…