[RELEASE] PlexPlus - Control Lighting with Plex Play Status

Hi thanks for the feedback :slight_smile:

For the below question, under “with these settings” set delay stop action, this will be the number of seconds that will be ignored for a stop action… 5 seconds for this is usually good…

Sorry not quite sure what you are asking :slight_smile:

I assume it is playing? What meta data are you expecting and where are you expecting this to be presented? The Device handler currently only shows play state and media type… I haven’t updated it to display anything else yet, as to do so I’ll need to update the exe also to pass the additional info.

Sorry - I shouldn’t post when I am too tired to reply or… much of anything.

I noticed the dashed line at the bottom of my window so assumed there was supposed to be metadata.

I notice ALL my virtual switches show as something playing even though, currently none have anything playing.

Other question -

Here is the scenario I am trying to invoke:
During Day - Plex plays TV show/Movie - Lamps Turn on
During Night - Plex Plays TV Show - Cans turn off/Lamps On
During Night - Plex Plays Movie - Cans dim to 15%/Lamps Off

During Pause - Day - no change
During Pause - Night TV - lamps on/Cans On
During Night - Night Movie - Cans/50%

Should I be creating routines for this in Plex and relying on those as it seems my desires may be too granular.

AWESOME work by the way - this has been really fun to play with.

Thanks @Entityxenon Jake. The 5 seconds worked perfectly for the 2 movie trailers that I have setup but the lights brightened to 50% during the cinema trailer pre-roll video before the film. I could change the seconds to be longer but some pre-roll videos I have are over a minute long and then that would effect how long I have to wait for lights to come on at a general pause.

What do you mean by a pre-roll video? There is the option to set X trailers before a film, I assume what you are talking about is different? Although I’m not sure it should make any difference, all it essentially does is ignore delay “stop” for 5 seconds and cancel if another command is recieved? If you could try adding a couple of extra seconds to the stop delay, perhaps it’s not quite long enough??

If that still doesn’t sort it, could you add the below in to the script, the first line is already there the second line needs to be added, this should post a “warn” message in live logging with the playback type details if you can check what you are getting?.. I can only assume that the playback type being sent is not correct?

def AppCommandRecieved(command, userName, playerName, playerIP, mediaType) {
     log.warn "THIS IS THE MEDIA TYPE: $mediaType COMMAND: $command"

Hi @rgreenpc Richard,

No worries, it all makes sense when you are typing it :slight_smile:

So for the virtual device… the default setting when created is “playing” with “–”, I will change this as it is slightly confusing and not really best practice!

However assuming you assign this to a room in PlexPlus to be updated it will sort itself out when you play and stop your first movie and then reflect the correct status going forwards and the – will change to the playback type…

So for your second scenario, PlexPlus does not do time based lighting… however there are options…

You could create a virtual switch or routine to trigger each play pause and stop action, and then use something like CoRE to then to control the lighting based on the time of day…

Or something slightly less official, but potentially easier… I have written a full home automation app, it’s unofficially released, but you can set “time modes” in the settings, then add a multimedia module to handle the device type from PlexPlus, then add 3 scenes, one for each play pause and stop which can have different actions based on the time of day… it’s not even as complicated as it sounds above…

I’m referring to the Plex Server Setting under Extras shown in this image:

whereby you can use short clips before a film as seen in this one that I have created:

Nice I’ve not seen that before! Love your clip too! Unfortunately I’m not getting anything strange in the logging that should mean that it wont work? Although I’m not getting any stop events between clips either? If you can drop in the above code and then see what live logging throws out?

@Entityxenon This is the result, just as the last trailer finishes and the theater pre-roll is about to start:

a42b8dad-51f7-4f8b-b7c4-665074b8b448 6:47:52 PM: trace setColor([hue:70, saturation:56, level:50])
5507c29c-78d9-4162-a69d-5d60e84e5f5a 6:47:52 PM: trace setColor([hue:70, saturation:56, level:50])
ea1e3a38-dd5e-4755-92dd-f2f5b92b8f9e 6:47:46 PM: error groovy.lang.MissingMethodException: No signature of method: script14876344251211756533467.checkAllDeviceThresholds() is applicable for argument types: () values: []
837187d6-f46d-4814-84e0-bfd0db6ae7fb 6:47:45 PM: warn THIS IS THE MEDIA TYPE: clip COMMAND: onstop

Not sure if that helps…
Second attempt, pretty much same result:
a42b8dad-51f7-4f8b-b7c4-665074b8b448 6:57:51 PM: trace setColor([hue:70, saturation:56, level:50])
5507c29c-78d9-4162-a69d-5d60e84e5f5a 6:57:51 PM: trace setColor([hue:70, saturation:56, level:50])
ea1e3a38-dd5e-4755-92dd-f2f5b92b8f9e 6:57:46 PM: error groovy.lang.MissingMethodException: No signature of method: script14876332701391756533467.checkAllDeviceThresholds() is applicable for argument types: () values: []
837187d6-f46d-4814-84e0-bfd0db6ae7fb 6:57:44 PM: warn THIS IS THE MEDIA TYPE: clip COMMAND: onstop
837187d6-f46d-4814-84e0-bfd0db6ae7fb 6:57:43 PM: warn THIS IS THE MEDIA TYPE: clip COMMAND:

I created a dozen theater pre-roll clips using www.ivipid.com
Here are my others: https://www.youtube.com/playlist?list=PLxsJn0e48ocdCswhwrWpN9za6fVYuynai

@Entityxenon SmartApp Suggestion: I use a Third-Party Program called PlexPy which is a web application for monitoring, analytics and notifications for my Plex Media Server. One of the settings I can configure in PlexPy that I think would be really beneficial in PlexPlus would be the ability to change Watched Percent so that you can Set the percentage for a media item to be considered as watched. Minimum 50, Maximum 95.

This would allow the lights to be set to turn on at 95% of the movie completion, which is usually the credits.
Just a thought, hope you see how it could be a really cool option.

So after this command there should be an onplay command, what I really need to see is both events and their time stamps… this will then tell me what timeline is being followed against which events

Cheers will definitely check that out!

1 Like

Unfortunately webhooks doesn’t provide timeline reporting, there are other APIs within Plex that do but they are a little hit and miss depending on device… ph4r has been updating the Plex HT Manager app to allow control and status reporting, but had been quite a headache to get where he currently is and it still won’t work with 100% of devices… a Plex limitation rather than code…

I need to spend some time properly looking at his code and doing some testing with him, as if this can be updated reliably then I’ll consider adding in the code to do what you are asking…

Just finished watching Arrival. I tested it and watched the Live Logging… I watched Play, Scrobble, and Stop the first trailer, Play, Scrobble, and Stop the second trailer, but for the pre-roll it just showed scrobble (no play or stop) and then it began Playing the selected movie.

webhooks does send timeline reporting… sometimes. In the PlexManager support for WebHooks I do parse it when it is sent. The rub is that it always tells you where in the media it is when an event occurs, but not always how long the media is, and it also only sends data when something changes.

In PlexManager (which you can use to trigger PlexPlus) It does support getting Timeline Status from all connected Players (via ServerSubscribe - most robust, faster than webhooks/None, but slower than Subscribe), and when media is playing, it updates every second! The part that is perhaps not working across all devices is sending commands. Client commands work the best and most reliably; however, not all players support them properly. Some users have reported that the Server and ServerProxy commands work for them, but for me these typically stop at the server and are not forwarded on to the player (I think because my server and main player are on the same IP).

I installed PlexManager last night after @Entityxenon mentioned it. I used the Dropbox links and I too use my Server as the player in my theater and using the settings Command Target Client and Timeline Status None, it worked for me, but I guess you’re saying that ServerSubscribe would be the better option?

1 Like

Cheers for the clarification :slight_smile: but just for John’s clarity… currently PlexPlus isn’t able to respond to the timeline reporting, this is possibly something I will do in the future…

I do have some further questions on the API work you have been doing… but before I batter you with questions I want to firstly test the latest version of your code and take a look through it… but I haven’t had time to much of anything SmartThings related recently :frowning: although I am looking to book a week off work soon to make some time to spend on ST (and other things)

There is a possibility I may also split PlexPlus, in to two simpler apps, one to manage the devices and the other to do scene handling across all media player device types not just Plex… but having the time is part of the issue… That way it would also make swapping in the Plex Manager component much simpler…


I’ve just updated the code to 3.5 to treat scrobble as play… however looking at your timelines, the issue may just be that webhooks doesn’t send the update quick enough or in fact it didn’t send the event at all?!.. You can see that there are 14 seconds between stop and scrobble in your log… in that case your pause would need to be longer…

Jake, I’m still trying to learn this ST IDE site, how do I update to version 3.5, to test it out. I’m seeing this when I go to Update from Repo, neither checkbox is plexplus.groovy… did I do something wrong?