Plex activity monitor using WEBHOOKS, the easy way

I don’t think it works with hassio since you can’t install node-Js.

Ive switched completely from using the webhooks to using tautulli MQTT method. It works so much better!.. I am also building a masking system for my theater projector screen to mask the top and bottom bars when different aspect ratios are played and tautulli can post that info to mqtt when playing anything! It seems to be alot faster as well. I have noticed tho that when resuming play and pausing movies using any android client including the nvidia shield its got about a 1 to 2 second delay. Playing and stopping play is instant tho so its a little odd but whatever. Other clients like roku or pc are instant for all actions. The other cool thing is i can setup a watched notification so when i reach 95% of a movie watched… basically when credits roll it turns the lights back on in the theater room.

If webhooks doesn’t work as good or fast as tautulli, then you’re doing something wrong. Tautulli uses the webhooks and acts as a middle step.

It should be more robust and faster than tautulli.

I might have missworded that a bit. The issue i had wasnt really with the speed it was with what info i could get from it and also create a custom script to trigger lights was kind of pain. Now I can just setup a notification in tautulli and let it post all the info i need to homeassistant using mqtt. Being able to get the aspect ratio and the watch percentage automation is a big factor in me switching from the webhooks. Plus like you said tautulli uses the webhooks so its just as fast!

Are you able to do this successfully? I’m thinking the same to overcome hassio not able to support nodejs.

If so, can you post your node-red config so I can try to replicate, don’t understand the step exactly.

Its node-JS. And the code is in the firat post. Will not work with Hassio.

Yes, I understood. Indeed I tried with node-JS seperately on VM, it works, however that required be to have additional host.

I am trying to figure out if same script concept, have it implement with node-red, we will get the same results, as such hassio can support it without additional host.

Yes i am currently still using node-red to get Plex webhooks to interact with homeassistant. The steps are exactly as described in the post you replied to - which bit are you struggling with?

Also homeassistant 0.80 has a new webhooks integration so node-red workaround may not be required any more. I just need to figure out how to use the new webhooks trigger

Thanks @jimbob1001. It was my first attempt to use NodeRed. I finally manged to get it up. I face issue on part initially:

  • Did not add node-red port and http node username password in the Plex configuration.
  • With #5 on passing token of authorization and sensor API.

Now trying to figure out how to do UUID client check. Do you implement that.

Great, do provide guide if you figure out how to use the new webhook trigger on 0.80.

Oh yeah that’s just reminded me! A little cheat to make this work with the new homeassistant authorization (ie without enabling API legacy password) you can manually edit the node in node-red config folder. Look for node-red-contrib-hass.js then change line 71 to…

opts.headers['Authorization'] = node.apipassword;

Once this part is done put a long lived access token instead of a password into the node-red Hass configuration

To answer regarding uuid this should be possible, just add that to the attributes in step 4 should be something like…

"UUID":"{{payload.Player.uuid}}",

Great, the UUID work fine pair with automation.

As for the node-red-contrib-hass.js, I couldn’t find it on my configuration folder, this need enable certain module or some other path?

My current solution is to insert a function node after step #4 before sending it to #5

“{{{msg.payload}}}”
msg.headers = {};
msg.headers = {
“content-type” : “application/json”,
“authorization” : “Bearer long live token”
}
return msg;

Should be in ~/data/node_modules/node-red-contrib-hass

I’m unable to look for this in the setup. Perhaps I’m using Hassio + Node Red add on.

I’ve added websocket support to the built-in Plex component due to be released in HA 0.101. It updates the media_player and sensor device states immediately instead of the old, slow polling method. This doesn’t require webhook configuration and also doesn’t require Plex Pass.

If you’re feeling adventurous it’s in the latest beta release. Any feedback would be appreciated. :slightly_smiling_face:

I’m trying to get this started. So I put the index.js in the /home directory of my raspberry pi. and When I do through SSH to the pi in the terminal “node index.js” it does nothing until I hit CTRL+C to quit the json script.

Home assistant can see my plex player and eveyrthing and I try playing a movie but the script does nothing. I did add my ip address to my server and the password to my home assistant.

Any thoughts?