I have started looking at the plex api and it’s going to be tricky to build a service manager and device types for plex. You can retrieve a list of connected clients, but the list is ephemeral. There is a way to list all clients, but it will list every browser version and device you have ever connected with.
Here are the bits I am puzzling on.
How do you create a device type to handle transient devices?
I want to see what is playing on each client and have basic control.
Will the existing capabilities work for this scenario.
Oh, it’s going down. I started a while ago but then plex lost its forums due to hackers . I have already figured out how to send basic commands to a client. I am going to hit up @pstuart because I have not messed too much with local ip stuff. I am also trying to figure out what kinds of xml parsing is available in our version of groovy.
Yeah. I was joining anyway. If you want to do this that would be great.
It’s just one way if I am understanding you. I don’t think it provides any sort of callback. I think you can only query the api. You can query for players, what’s playing, what’s in the library, etc. You can also send control commands.
Created a quick and easy Plex->SmartThings integration for a windows server where Plex runs.
Every n seconds it calls localhost:32400/status/sessions and retrieves the clients playing from Plex and sends updates to a smartapp endpoint when the play state changes where it sets some hue lights and switches depending on the play/pause/stopped state.
Since I only use Plex with a single client I’m just checking for a few needles in the xml response from Plex, but it should be quick to add support for storing states per user and send the state, user, and player to the smartapp.
Seems to be about no performance impact on the server calling it every second.
The first check after it starts takes a few seconds at times for some reason, but after that it’s faster.
Endpoint urls, plex server url, and needles are all in the app.config file. Forgot to put the ‘timer’ interval in the config, so you have to change that one in the code if you want, but it has worked fine so far when set to 1s.
Might add some extra state handling for multiple devices/users tomorrow if I feel like it
It’s pretty straightforward, and as long as you have .net framework 4.5 installed it should run fine. It should be preinstalled on windows 8 if I’m not mistaken.
If you don’t have visual studio installed to compile the code then I’ve upped another version without the source but with a few improvements at http://gosulabs.com/plex2smartthings.php, as well as a small readme here on how to get it up and running quick: https://docs.google.com/document/d/1r3R_j1qQrw70f6yoEhoZDIIw53Pcv3_YJCasacGay2g/pub
Thank you for the apps. Working great except I have multiple devices with plex client and my lights are going crazy when we use multiple devices with plex client at the same time. Is it possible to just have one device controls the lights?
@Navat604 In the config file there’s a whitelist and ignorelist.
If you set onlyAllowWhitelisted=true then only the devices on the whitelist will be monitored.
Uncomment the line <item type=“player” value=“Test Player B” /> and set the name of the player instead of ‘Test Player B’ and it should hopefully work.
Showed my wife as I was quite excited… but she didn’t really care… though I did test it whilst she was watching devious maids…
If I may ask for a feature next time you work on this project - can you set a mode when it plays / pauses/stops? As right now it overrides my lifx color settings.
thanks again. this was one of those massive features I have been looking forward to.
I’m glad it works
The application sends the plex states (play/pause/stop) to the smartthings app, so changing modes is just a quick addition to the script. I’ve added inn optional mode changes in the example script (SmartApp_Source.txt) in the download, haven’t been able to test the changes yet but most likely it works
Glad to hear it
Thanks for the suggestions, I’ll try to implement them soon! The different media types are already halfway implemented at least, since it’s already sent to the script as well as the states and player name
Great work! This is exactly what I have been waiting for! I am having a little problem though… I am very basic when it comes to making apps, etc - I followed the instructions however when I go to configure I do not see API token or API end point - what am I missing? On the right hand column where it shows that on your instructions, my options are just locations and preferences - there is no simulator option. Is my hub not up to date?
I also have a v2 hub coming any day now and I plan on starting fresh with that anyway but I would love to get this app to work!