[OBSOLETE] Plex Home Theatre Manager SmartApp

Is this essentially using the below in order to deliver the control? In which case the user would need to go to the address stated in the link, potentially adding this to the end depending on plex pass: ?X-Plex-Token=PLEX_TOKEN_HERE

https://support.plex.tv/hc/en-us/articles/201812803-Plex-Companion-Remote-Control-Issues

If this is the case then I don’t think ChromeCast or Samsung TVs play ball, however the ability to read status only would be very useful! I had missed that post when I read through before! Still concerns over the stability of RunIn() though…

I’m not sure if I’m doing anything wrong, but this app doesn’t seem to update its status correctly when I use my actual logitech harmony remote to pause or play. However I can pause/play with this app. Is it not supposed to stay in sync with the harmony remote?

Edit: Disregard the above. When I resync’d the app by hitting done again, it now showed the correct status of what was playing and showed paused when I paused with my remote.

Edit2: So it seems like there is about a 5 second delay when using a remote to pause plex before this app picks up on the current state. Anyway to fix this?

@iBeech This is awesome!

Some PS3 client testing for ya :wink:

Seems to report correctly on the first file you play but if you stop and play another it says stopped and doesn’t update the title. Also - controls don’t work on the PS3.

@SmartFan This is because when you change the play state in Smartthings, the event is sent straight away. When the event is triggered from outside of SmartThings, it takes a few seconds for the polling in SmartThings to detect that playback has changed. There is no way to receive the event in real time.

@Entityxeon yes, that was how I was picking them up, however i’m working on some new code which uses a different method, which can detect the state of your players. More on this soon. I also agree, runIn is very unstable. I’m working on a more reliable solution.

@Cal7 Yes, i’m hopefuly that an update i’m working on will simply allow you to get the status of your devices. If your device supports control, then that will be an added bonus.

@Larry_McFarlin glad that you are giving it ago. PS3 / Xbox probably won’t work in the control department, but it should at least show playback status (i.e. play / paused / whats playing)

1 Like

Look forward to it! and also the ability to just read state, have you considered just reading state and device from the server directly thus removing the device dependency? i.e. via /status/sessions

yes, however /status/sessions only displays device data when something is playing. There is another way to discover devices in your setup which is what i’m working on.

Oddly, runIn has been very reliable for me in the PHT smartapp- i dont think its let me down so far. its just so hit and miss with people on the whole!

Are you UK or US based, I find the US servers a lot more flakey than the UK, I guess due to low adoption in the UK, but still far from perfect. To be fair I left it running in live logging for a while the other night and didn’t miss a beat!

Looking forward to seeing how you do it though…

I am still HIGHLY interested in the status updates. Frankly, I don’t care about the control side because it’s more practical (for me, anyway) to use my Logitech Harmony. However, I would love the SmartApp to be able to sense the state of Plex so I can control lighting based on Play/Pause/Stop.

However, will there be any way for it to determine the client connected to the server and it’s state? Sometimes, I will have more than one stream going due to other members in the house. For example, someone may be upstairs streaming show “A” in a bedroom, while I’m in the basement watching show “B”. I would want to make sure that the status of show “B” is the only thing which will change the state of my lights in the basement, regardless of what the status of show “A” is…if that makes sense.

1 Like

The update works great. One concern I have now is that it adds any client that’s connected to my plex server. I’m a tech junky and have over 50 devices that have connected. This update just added a crap load of entries to my things list.
I really think you should allow selection of the detected clients that are added to the list and polled for updates.

Thanks for the feedback. I will take a look into how to do that at some point in the week.

I have now updated the SmartApp with the ability for you to select which clients you want to add. When you go through this process, all clients which are unselected will be free for deletion.

I’m getting “No devices to connect.”

Hi @jksearles

I’d love to help, but you haven’t given me a lot to go on there. Where are you getting this message? How far did you get? What is your Plex setup consist of?

Hi sorry. This only happened with the latest release so I figured it was a new problem. I installed the device type and app as instructed. I put in my credentials and clicked next, then clicked “Select Your Clients” and it said “No Devices to connect.” According to live logging the app is parsing devices.xml.

My plex setup consists of several devices all on the same local network. An Xbox 360, an Xbox one, a few Windows 10 clients, 2 Windows Phone apps, 2 Android apps.

OK, thanks for getting back to me. I’ll send you some altered code lines to help me get more logging info out!

1 Like

I hadn’t heard back from you so I just tried again after making sure I had the latest code. XBOXONE was found but no other devices were listed as choices. Checked my xml from Plex and there are definitely a bunch of devices in there.

I’m also getting the below error after inputting details and pressing done the App returns a blank page and I get the below response:

2:47:35 PM: error java.lang.StringIndexOutOfBoundsException: String index out of range: -6 @ line 97
2:47:35 PM: debug Parsing plex.tv/devices.xml
2:47:35 PM: debug Executing 'getClientList’
2:47:35 PM: debug Token is: REMOVED FOR POST
2:47:35 PM: debug Getting authentication token for Plex Server 192.168.25.100

@iBeech

Having some issue - wondering if you might be able to help.

The only client it’s finding is my mobile for some reason. Here’s a snippet of the log:

2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:13 AM: trace Current playback type:
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:12 AM: trace Determined that My SM-N910V is: stopped
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:12 AM: debug Checking My SM-N910V for updates
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:12 AM: debug getChildDevices(false), children=1
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:12 AM: debug Parsing /status/sessions
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:12 AM: trace in response(evt)
d98210a0-278e-40d6-9f59-f4f32dda3ecf 10:29:13 AM: debug Executing 'setPlaybackTitle’
d98210a0-278e-40d6-9f59-f4f32dda3ecf 10:29:13 AM: debug Executing 'setPlaybackState’
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:11 AM: debug The GET path is: /status/sessions
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:11 AM: debug Executing 'updateClientStatus’
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:11 AM: debug Polling for PHT state
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:11 AM: debug This PHT does not exist, creating a new one now
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:11 AM: debug getChildDevices(false), children=0
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:11 AM: info Updating PHT: My SM-N910V with IP: f24387977f1c93b-com-plexapp-android and machine identifier: 10.0.0.112
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:10 AM: debug Updated with settings: [plexPassword:edited, plexUserName:Edited, theHub:physicalgraph.app.HubWrapper@75767c75, selectedClients:[My SM-N910V|f24387977f1c93b-com-plexapp-android|10.0.0.112], plexServerIP:10.0.0.169]
d98210a0-278e-40d6-9f59-f4f32dda3ecf 10:29:11 AM: debug Virtual siwtch parsing 'updated’
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:10 AM: debug The GET path is: /status/sessions
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:10 AM: debug Executing 'updateClientStatus’
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:10 AM: debug Polling for PHT state
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:10 AM: debug Installed with settings: [plexPassword:edited, plexUserName:edited, theHub:physicalgraph.app.HubWrapper@5a02b9c6, selectedClients:[My SM-N910V|f24387977f1c93b-com-plexapp-android|10.0.0.112], plexServerIP:10.0.0.169]
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:01 AM: debug Parsing plex.tv/devices.xml
2ff966bc-9c05-4f1d-903d-d6f0b1be3bdc 10:29:01 AM: debug Executing ‘getClientList’

I can send the devices.xml if you need it. It does list Device name=“MediaServer”, Device name=“Plex for Sony (PlayStation 3 01.17)”, Device name=“Plex Web (Chrome)”, Device name=“My SM-N910V”, and 6 of Device name=“Plex Web (Chrome)”

Thanks!

I’m getting the same error as Entityxenon
java.lang.StringIndexOutOfBoundsException: String index out of range: -6 @ line 97

Super excited to get this working btw :slight_smile:

@Larry_McFarlin @axyr
I submitted a pull request that fixed a lot of the client issues with this. I haven’t heard back from @iBeech in a couple days…

If you would like to try it out install this app and device type and publish. This may cause issues if you update your old code. I suggest removing the old app
Device Type:
https://github.com/tonesto7/SmartThings-1/blob/master/devicetypes/ibeech/plex-home-theatre.src/plex-home-theatre.groovy

Smart App:
https://github.com/tonesto7/SmartThings-1/blob/master/smartapps/ibeech/plex-manager.src/plex-manager.groovy