Plex binding for OH3 | Will it be ported?

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:

Previously had the plex 3.1 binding but upgraded to OH3.2 so I added this:

org.openhab.binding.plex-3.3.0-SNAPSHOT.jar

to my : /usr/share/openhab/addons folder

It is the only external addon but I get this message in the log during startup.
As a result none of the plex things work. Have restarted OH3 many times.

Is it cached somehwere, if so how do I purge, or any other ideas?

[WARN ] [core.karaf.internal.FeatureInstaller] - The binding add-on ‘PLEX’ does not exist - ignoring it.

I got rid of the WARN by editing :
/var/lib/openhab/config/org/openhab/addons.config and manually editing the bindings line to remove PLEX.
(There is a super long winded thread on how to remove old bindings, honestly didn’t have the time to read it, it goes in circles quickly.

Also had to do: chown openhab:openhab on the new jar in the addons folder, then it came alive on restart.

Now however - all my existing Plex THINGS are “Unknown” .

I started a plex player and used the SCAN feature when adding a thing and it detected a player running - So I added it and tested it was indeed the one that I was running as the status in the associated ITEM was being updated on play/pause. Inspected the THING and saw the machineid is not what it used to be, its also not listed in : https://plex.tv/devices.xml

It is a real PITA to recreated ALL the PLEX THINGS, so…

Where is the scanner getting its machine ids from?

Hi Stan.

The scanner gets the IDS from: https://plex.tv/devices.xml

Thanks for the response, but I perform a find in the devices xml after the scanner has gotten and ID and the ID is not in devices.xml, not even partial.

For example just added a tablet using scan:
configuration:
playerID: w7pmpadeolobc1zrfyzbijub

loaded devices.xml - can’t find that ID, that device has a totally different id:
clientIdentifier=“b00400f3ebe9c63a-com-plexapp-android”

This device has PlexAmp and Plex installed on it, in testing there seems to be some “cross-talk” if plex and plexamp are both running then start/pause in plexamp seems to update the plex item.

devices.xml identifies the different players as:
product=“Plexamp” productVersion=“4.0.1”
product=“Plex for Android (Mobile)” productVersion=“8.29.1.30697”

I’ll keep plugging away . . .

I’ve found out that on at least Android 12 devices if you play Plexamp alone and do a scan, OH will detect a player with some unknown clientid not listed in devices xml. Closing out PlexAmp and starting only Plex then doing a Scan when adding a Thing - will pickup the correct clientid (that is in devices.xml and use it as machine id in the created thing.

FTR Devices playing PlexAmp show up in the Plex Dashboard, but are presently unpredictable in OH3.2 with the v.11 Plex jar.

Not sure if the Plex API lets you choose playlists or folders to start playing ( I imagine it does, since plexamp seems to essentially make calls to plex) but that would be on my wish list.

e.g.) Power on the stereo in OH3 and it automatically starts playing some folder or playlist.

Hi
Did you guys add webhook configuration to the plex server? I don’t get any player. Server is online.

Hope this isn’t necessary, Guess this is a premium feature, no?


I just tried the new binding myself. And I'm getting my server online, but can't get a player online. What's the required id of that thing? Is that something unique you create yourself? fe 192168123321 (IP of server) Or should that come from plex? Or...?

In https://plex.tv/devices.xml, I see folllowing 3 devices:

  • My server
  • My webbrowser
  • My phone

Got it:
Just go to the link and https://plex.tv/devices.xml you get a list of devices. there you take the “clientIdentifier” and put it to Machine Id in Openhab Plex Player.

I tried this with the 3 devices clientIdentifier I see, but none of them brought my player online. :cry:

did you play something after you add the client player?

1 Like

I’ve noticed that players stay that way until somethings is playing on them…. But I can’t get my “Plex Dash”s to report properly… but i haven’t spending time on it

1 Like

Came online after I started something on my webbrowser.

For the moment, I’m getting a lot of warnings like:

2022-04-05 17:50:20.441 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel art although the handler was already disposed.
2022-04-05 17:50:20.442 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel thumb although the handler was already disposed.
2022-04-05 17:50:20.442 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel progress although the handler was already disposed.
2022-04-05 17:50:20.443 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel endtime although the handler was already disposed.
2022-04-05 17:50:30.481 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel state although the handler was already disposed.
2022-04-05 17:50:30.482 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel power although the handler was already disposed.
2022-04-05 17:50:30.483 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel title although the handler was already disposed.
2022-04-05 17:50:30.484 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel type although the handler was already disposed.
2022-04-05 17:50:30.487 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel art although the handler was already disposed.
2022-04-05 17:50:30.489 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel thumb although the handler was already disposed.
2022-04-05 17:50:30.490 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel progress although the handler was already disposed.
2022-04-05 17:50:30.493 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler PlexPlayerHandler of thing plex:player:fdd117bd6f:3aea92954a tried updating channel endtime although the handler was already disposed.

I am getting out of memory exceptions after a while. I just add my plex server, one player and a rule to switch my lights depending on the player state. It works fine for like 3 hours but then i start getting out of memory exceptions.
I don’t know if it’s relevant or not, but my plex server goes to sleep when inactive, so that may cause the problem.
Any ideas?

Continuing the discussion from Plex binding for OH3 | Will it be ported?:

Okay, I’m sure I am missing something but am looking for some support. I have everything bound and active but as soon as I start playing anything on any local client I get Plex is not returning valid session data. I see that error mentioned a few times above but no consistent answer on how to address the issue. I’m configured using my server IP and the toke retrieved from going to that IP and viewing XML I have also attempted multiple tokens from https://plex.tv/devices.xml but can’t seem to stop it from disconnecting once I hit play. Any help would be greatly appreciated.

Just for an update if you are still on 3.2.0 obviously the 3.3.0 jar update won’t work.

Hi Keil,

Still having problems with the binding or did updating to the correct version solve the issues.