Jump to content

Plex Webhooks


DoughtCom

Recommended Posts

Posted

Wasn't really sure where to put this (mods can move it wherever), but plex released something called "webhooks" late last week.  I decided to spend an hour or so and write a webhook to interface with our ISY944.  It's nothing fancy but it allows you to do the following.

  • Capture the 3 main events from Plex: play, pause, stop.
  • Have a set of scenes and devices for each "event group"
  • Each "event group" is assigned to a specific device with a specific plex event, for instance my upstairs Apple TV controls my upstairs lights, my downstairs Apple TV controls the downstairs lights.
  • Since you have an event group assigned to each event, I usually ramp the lights to 60% on pause with a scene and on stop I ramp them to 90% over about 20 seconds.

 

Needed in order to make this function:

  • Understanding of installing node.js
  • A machine to run the node.js code all the time, I use a raspberry pi (1-3 are all fine).
  • Understanding of JSON syntax for the config.

I'm usually super busy during the day, but will try to help out however I can.  In my testing it works great and it's nice to have these callbacks wired up.

 

Here's the link to my code, there's a video on the top of the github readme page with it in action.

https://github.com/DoughtCom/isy944-Plex-Webhook

 

Cheers,

Shawn

  • 11 months later...
Posted

Hey DoughtCom,

 

I've been trying to get this working on my machine for the last few hours and I'm missing something. I'm running on Windows 7. I've got node.js installed. I wasn't sure if I should put the github code in seperate directory or not??... I've tried putting in the node.js directory as well as in its own. I ran npm install package.json and that seemed to work when it was in a separate directory. I configured my device-config.json but I'm getting an error when I try to run the index.js. I've been using command prompt as an admin. At the end I'm running

 

node.exe c:/dir/index.js 

 

I'm getting back this error:

 

Error: Cannot find module 'express'

    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Program Files\nodejs\index.js:1:77)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
 
 
  • 1 year later...
Posted

@DoughtCom

Thanks for writing this. I have enough knowledge to get it running on my pi and working well. I modified the code slightly to change state variables, rather than devices/scenes. This allows triggering of programs and more complex/granular control (i.e. only change lighting if it's dark outside).

I'm finding that when the Plex changes to play, pause, or resume there is approximately a 4-5 second delay until the ISY gets the rest command. Interestingly, for stop the change happens immediately. Is this built into your code or an inherent issue with Plex? I reviewed your code in detail and didn't see any reason why the delay should occur on your end. Any suggestions you have would be appreciated. 

Thanks very much for writing this. With control over state variables I don't see any advantage in converting to a poly.

Regards,

Ben

Posted
On 1/8/2018 at 8:46 PM, nathagt said:

I'm getting back this error:

 

Error: Cannot find module 'express'

In the folder where this script is, type "npm install" and all the dependencies, including express, will be added. Reply is better a little late than never I hope!

  • 10 months later...
Posted
3 hours ago, Michel Kohanim said:

Hi everyone, I posted to our slack channel.

With kind regards,
Michel

 

What is the link to your slack channel... I cannot seem to find that.

Posted
12 hours ago, Michel Kohanim said:

@ralbright,

Did you actually click on that link and read the contents? Curious minds wish to know :)

With kind regards,
Michel

Ah.... touche' 

Yes I did read the link. And I do have programming experience, but not a lot. (I manage Linux servers, have programmed in Javascript, HTML, basic, VB and the like before. I can usually read code and figure out what it is trying to do. But the problem is I don't always have a lot of time.)

I guess I could apply to be an ISY Developer.

Posted
36 minutes ago, Michel Kohanim said:

@ralbright,

Then you will fit right in ... all you have to do is to learn Python (it's quite easy if you already know other programming languages) and you can start writing your own node servers!

With kind regards,
Michel

@Michel Kohanim Any suggestions on where to start learning Python? Especially what I need to learn to write node servers?

Posted
17 minutes ago, DaveStLou said:

@Michel Kohanim Any suggestions on where to start learning Python? Especially what I need to learn to write node servers?

I would likely say just take another node server and start to break it down. But that is my method... your mileage may vary.

Posted
1 hour ago, ralbright said:

I would likely say just take another node server and start to break it down. But that is my method... your mileage may vary.

That's the technique I'm using. I'd like to learn best practices too.

  • 1 month later...
Posted

OMG. I just saw the news post about udi-plex-poly. Soooo exciting!! Installed it immediately and of course it just works. Two of my favorite things - ISY994 and my Plex server - connected cleanly and intuitively. I can get rid of my much more kludgy "integrations" for Plex now. Thank you!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...