Plex Webhooks

Your code works great btw, and the attribute is getting set properly. Thanks for that. But I am still not educated enough on how to pass the value to another rule. I named mine PlexTitle to keep it clear like this.

def playbackTitle(PlexTitle) {
sendEvent(name: "trackDescription", value: PlexTitle);
log.debug "Title set to $PlexTitle"

Logs are showing the correct title but when I use another rule to send notifications, I get either null or $PlexTitle or {PlexTitle}. I'm not sure how else to pass it.

trackDescription is the variable and attribute.. you're calling the wrong thing :slight_smile:

Changing the other variable does nothing..

lol. I'm an idiot.

I do get a null value when I use trackDescription in another rule though.

Not really sure exactly what you are doing and I'm in a hotel currently so can't check on my setup, but I'm guessing you are trying to pull as a global variable, rather than an attribute on a device? You need to specifically pull the attribute from the device you want to monitor, I'm guessing then you need to pass that to a variable to use how you want, but I'm not sure as I've never done what you are trying to do..

So to be clear GlobalVariables in rule machine are not global across hubitat, just across rule machine rules I believe, global within an application not cross application.. if you need to call something from else where you can call the attribute, or set the attribute as a trigger and use that to update a rule machine variable.. Hope that points you in the right direction, but tell them you have an attribute trackDescription and how you want to use it and one of the rule machine experts on here will tell you exactly what you need to do..

1 Like

Yeah, that's exactly what I am trying to do. Pass that attribute value to another rule to use it in a push alert to my phone so I know when my kids start a movie and show the title of the movie.

But your portion of the code works great. You are awesome, and thank you again for your help and time.

@jebbett I forgot to include this screenshot to show you that the attribute of the music device gets updated correctly.

1 Like

@jebbett hey there thanks a lot for this code, but I'm struggling a bit to get things going. I imported all the code and can set up the app fine, along with MediaScene (what a great idea!).

I have an LG TV with Plex app but this doesn't show up in the client list, even if I keep it playing something while I scan. I enabled some debug logging in the code and can see that once I have set it up for a client (my phone), I get some logs when I interact with the TV. The client is correctly identified:

Player JSON: [local:true, publicAddress:xxx.xxx.xxx.xxx, title:LG 65UJ630V-ZA, uuid:6t8vxmclwiolmcxrr1hb0akh] 

However this one never comes up in the list. I checked my PMS and the TV doesn't show up as an authorized device, guessing this is blocking from doing so. I read through the whole thread and there are some indications that it's not mapping things to the right client ID but I am not sure how to fix it. Any help here would be greatly appreciated. Stay safe everyone!

EDIT: Figured I could swap the GUIDs out in the Device properties and sure enough, that did the trick!!

So for my own sanity, was it a different ID showing up when playing Vs adding?

Secondary question: when you were playing were you using the primary profile in Plex? Plex is weird with profiles and only updates in some places if it's not the primary profile using it.. i.e. if you use a secondary on a new TV it'll not show in the Plex devices page! (But should show in currently playing) hence why I have to lookup in two places to find devices!

Hey! To clarify my problem: I was not able to find my TV in the devices list when setting up the Communicator app, but I noticed that after using my phone as a test client (which did appear in the list), the Communicator app was still logging actions from the TV when I would play / pause. So I went through the code and enabled all the DEBUG lines I could find, then did some testing. I picked up my TVs GUID from the logs and used it on my phone's Communicator device which was created. I changed the greyed out value, the Device Network ID and that got it working.

To answer your second question, I was using my main account and main profile (I don't have any other users set up at all) so not sure why the TV would not show up in Authorized Devices, but as you say, I did see the client listed correctly in the Dashboard (now playing section) so I figured they sure are talking to each other properly.

What I think is wrong with the app code: the device is there, it's playing content but not listen in the XML version of the scan at all from what I can see. But I don't see how to fix this particular problem, as Plex's APIs are a mystery and don't have time study up. But what I did works and I recommend to all who have the same issue during device discovery. Maybe the app should have an option for debug logging to make it more user friendly, but as it is, it's not rocket science to uncomment a few lines and watch the logs come in as you play with it.

1 Like

Thanks for the response, the Plex APIs are are a mystery even after reading up on them, Plex doesn't show some stuff it should and different devices share different information, there is no consistency with it. Although grabbing devices isn't really a formal API, so probably part of the problem.. if the device is there to trigger actions though it should work.. but would need to recheck the code..

I agree adding a debugging option would be helpful, although I've not formally released this, hence some rough edges, will get round to it one day..

1 Like

@jebbett - Did you ever update the app and driver codes to include pulling the currently playing title? I would love to use that on a hubitat dashboard.

Are Roku boxes supported? I keep getting this in the logs:
Error creating device: com.hubitat.app.exception.UnknownDeviceTypeException: Device type 'Plex Communicator Device' in namespace 'jebbett' not found

Most definitely. I have a Roku 2, 3, and Ultra being monitored. Different Rokus in different rooms, triggering different lights.

Yes they are, just looks like you have not installed the driver, you need to add the app and driver code to hubitat

Sorry I did not, I'll look at adding it today

You:

Me: I stayed up late trying to fix this, how could I miss the dri... I guess I stayed up too late.

Thanks, this is awesome work. Is there a way to have the lights fade in and out?

No worries, it depends on your bulbs I guess, hue bulbs at least have a setting you could set in rule machine to define the duration of the fade

Hi, I've done it for you!! (See the next post!)

1 Like

Hello people,

I will no longer be anwering anything on this thread, and I will lock it if I can!

But don't worry! This is because I have pulled my finger out added the code to GitHub and you can now find the new and improved version here:

NEW VERSION HERE:

Thank you and see you on the other side!

PUBLIC NOTICE - DO NOT POST IN THIS THREAD

Follow the link in my previous post which also says not to post here.. I will actively be ignoring posts in this thread.

This will serve as a basic intelligence test, if you reply on this thread I will not provide support on either thread as it is clear that you are unable to follow basic instructions which has probably lead to you posting your question in the first place...

Hit like if you passed the test :smiley:

4 Likes