Plex binding for OH3 | Will it be ported?

What worked for me after trying and changing a lot of config, is to stop Openhab and delete your cache.
After a while everything should come on online.

Good Luck

No luck clearing cache either :confused: . The only thing I can think of is maybe itā€™s somehow because Iā€™m running Plex on docker docker. I can run a curl from the OH container to the plex one and get a response so itā€™s not a communication issue at least. I also tried getting the auth token via curl following these directions but still no luck Generating a Plex Auth Token using curl - kcore.org. I even set up a test box with a clean install of OH and only the 0.9 plex binding jar and same issue. I thought about trying to download the source and see if I can debug it that way, but unfortunately the source package linked to the 0.9 tag in github here: https://github.com/bigbasec/openhab-addons/archive/refs/tags/0.9.zip doesnā€™t seem to actually have the plex binding code in it and the latest commit from the ā€œplexā€ branch in that repo is from February :frowning:

So I managed to get the 0.8 code working enough on 3.1 to do some debugging. It turns out that indeed the issue was that my plex was running docker. For some reason it had its network set to ā€œbridgeā€ mode so it was reporting its IP address as 172.17.0.3 instead of the host IP address of 192.168.0.45 that I was using. After I switched the plex container to ā€œhostā€ mode networking, the binding came up green and online! I donā€™t know why it was only this binding that had an issue with the networking that way but Iā€™ll take the win.

Edit: It looks like I spoke too soon, after I tried to add my first player thing I get this in the log every 5 seconds and the bridge thing wonā€™t come back online again :frowning:

2021-09-09 13:50:33.153 [DEBUG] [ex.internal.handler.PlexApiConnector] - Session Data refreshing
2021-09-09 13:50:33.167 [WARN ] [x.internal.handler.PlexServerHandler] - An exception occurred while polling the PLEX Server: 'null'

Edit 2:
It seems that this binding doesnā€™t support music playing on the plex client. When I play any music I get the above issue but if I switch to some kind of video (tv/movie) everything comes online and works as expected. Perhaps some day music will also work

This is what I also discovered. I never actually tried movies or tv shows and thought the binding was broken, turns out movies work good and also the binding finds plex players automatically.
Any reason why music might make so much trouble?

If you look at the XML for the sessions at http(s)://plexserverIP:32400/status/sessions?X-Plex-Token=YourToken , it has two different kinds of elements: Track for music (if music is currently playing) and Video for any kind of video (if video is currently playing). The binding seems to only look for Video elements and chokes if it finds a Track instead since itā€™s a different type of object (even though it has basically all the same properties - length, play time, etc). Unfortunately Iā€™m pretty lost when it comes to java and especially with binding code or else Iā€™d fix it myself but itā€™s probably a fairly easy fix for someone that knows what they are doing.

Hi all
Does anyone still try to fix this or is it hopeless?

I am asking the sameā€¦ Was running org.openhab.binding.plex-3.1.0-SNAPSHOT.jar and it worked great until I upgraded to 3.2ā€¦ and Iā€™m getting log4j errors when I try to rollbackā€¦

If I leave this enabled in 3.2, all of my bindings are frozen and I get javax.ws.rs.ClientErrorException: HTTP 415 Unsupported Media Type errors in the log.

If I move the plex binding out of the addons folder, everything works again. So Iā€™m asking for an 3.2 update to the plex binding.

Just upgraded to OH 3.2 and plex things all broke. Not runing RaspPi - this is on debian.
Added the latest : org.openhab.binding.plex-3.1.0-SNAPSHOT.jar to the
/usr/share/openhab/addons folder, restarted OH3.2 and im geting a language lib missing error:

[ERROR] [Events.Framework] - FrameworkEvent ERROR
org.osgi.framework.BundleException: Could not resolve module: org.openhab.bindin
g.plex [261]
  Unresolved requirement: Import-Package: org.apache.commons.lang; version="[2.6
.0,3.0.0)"
        at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclips
e.osgi-3.16.300.jar:?]

checking how to resolve

The binding needs some changes, as apache.commons is no longer supported.

1 Like

Iā€™ve forked the plex binding created by Brian Homeyer and compiled it to work with openhab version 3.2.0 and higher.

3 Likes

Added support for playing audio tracks

2 Likes

Pull Request made to OpenHab addons. Lets see what the feedback is and get this addon integrated.

2 Likes

Thatā€™s bloody amazing, Iā€™m about to install it now, thanks!

@aronbeurskens Thank you very much!!! I was looking for this.

I have the binding running smoothly. I have my plex server and clients added as things and all available channels set. Everything is reporting correct info.

One question: Is it correct that the binding is ā€œonlyā€ displaying information from the clients. So I cannot control the clients? For example, start/stop playback.

Edit: Are there any plans (or is it even possible) to control Plex clients in the future? For my setup it would be amazing if I could send commands from openhab to control playback on specific client with defined Plex Home User.

Thanks very much! This is the main binding that I use so very impressed that it now copes with audio as well :slight_smile:

Hi Kristian.

It is correct that this binding will only display information. It currently is not possible to control the player.

I can investigate the possibility. Can you describe the use case you want it for?

Are there other people who want to control te player?

The original concept had planned on player control as can be seen in the old .items file but I had to remove the control items to get the OH3 iteration working properly.

@aronbeurskens play, pause, stop control would be amazing.

My use case, when there is motion in the theatre the media would pause and when motion stopped media would resume. if motion was detected in the theatre and then the hallway outside then the media would stop.

If we could have the ability to open different libraries I would integrate it into prepare the theatre on rule I have that I trigger with Siri. It currently sets the lighting, heating/cooling, turns the amp and sub on selects the correct input and also turns the Apple TV on and opens the plex app. I would love to have it open the movie libary in plex too!

Iā€™ve added support to control the player. It is in really early state and I would really appreciate some help with testing. For now Iā€™ve added a control channel which supports PLAY/PAUSE/NEXT/PREVIOUS.

I could not find a stop option in the player control channel and the seekTo method of the plex API just times out at this point. When I find the mood I will investigate a bit more.

Any feedback from testing this version is appreciated.

5 Likes

Hi @aronbeurskens,

sorry, it took me so long to get back to this. As I see, you already started to work on the control. That is awesome, thank you so much!

Just quickly to my 2 use cases:

1: I have automated music in certain rooms. If someone enters the room, motion or light switching is detected and accordingly music is played from tablets (connected to speakers) displaying the Plex music library. Right now, I achieve this use case with the OH3 ADB binding. Where the ADB binding controls playback on the android tablets, according to different sensor inputs.

This, I would like to switch over to the Plex binding again (as it was in OH2). For my purpose, PLAY/PAUSE is in this context sufficient.

So, use case checked!

  1. I have several scenes which set devices, lights and music. Thus far, I use the Spotify binding to play certain playlists according to the mood of the scene.

Here, I would like switch over to Plex and my own music collection. In this regard my wish scenario is to select what playlist, artist or song is played (shuffle ON/OFF) from Plex on a certain device. Also setting which Plex Home user is used for playback would be on the wishlist, because I have a Plex Home User dedicated to the Smart Home and individual users for all the real people here. I keep the streams from all users separate to collect accurate statistics in Tautulli.

I know this is far out of scope from the current functionality or might not be possible with the Plex API. As mentioned above, wish scenario :wink:

Thank you again for your great work :slight_smile: