Plex binding for OH3 | Will it be ported?

Hi Community,

I wonder if anyone has an idea if the Plex binding will be ported to OH3?

https://github.com/openhab/openhab-addons/issues/6179#migrated

The list shows Plex to be migrated but the github entries are from 2019.
Does anyone know? My OH3 home cinema rules and habpanel are relying on the plex binding :slight_smile:

Cheers,
Henning

1 Like

The list shows a link to an issue to have a plex binding. That seems to be the only information available. Which seems to indicate no one is working on it. You could post a question on the issue to see if there is some activity or if someone is working on it.

Thanks, as there seems to be really no activity although the polls showed many are using the plugin - I will try the MQTT plex variant to get things going again.

Cheers

I’m working on a PLEX binding for OH3. It’s currently not going to be like the one for 2.5, but more suited to OH3. It’s not a port, it’s a rewrite. Currently sets up through PaperUI 100%, just working out a few issues and I’ll probably attempt to submit it for a PR. It’s basically a bridge thing and then things that will be associated with a specific machineIds.

I don’t particularly care about the volume controls and such through plex as that’s all done through other methods at my house so mine might not fit the bill for some people but it will work for getting status of things and maybe I’ll add some more advanced stuff. Still in the playing stage although it does work without issue at this point.

I’ve never submitted something for a PR before w/ OH, so we’ll see. Probably have something ready for that this week.

12 Likes

I used the Plex plugin to drive light changes and a Telegram/ Discord notification. Look forward to the PR!

2 Likes

That’s exactly what I am doing it for. Will likely implement some other things as I go along here, but really for the fluff, not something I’m going to use. Last thing I need to do I think is implement the username/password thing, as I’m currently only using the token, I’ll be working on that a bit tomorrow night.

Also don’t know what name I should be using, since “org.openhab.binding.plex” is technically slated to be updated at some point. I’m currently using it but will change it prior to the PR.

4 Likes

Thank you for the rewrite, I am happy to test as well :slight_smile:

Thanks for your job. I can’t wait this binding :laughing:

same here, thanks for a coming rewrite. I’m not on OH3 just yet but will be missing a plex binding when i get there

Just doing some more testing here, seems to work ok. I have found a minor issue with my approach but I guess it’s workable. If you have 2 devices that are technically able to display on a single device it gets weird.

Example : You have a chromecast hooked up to a TV and that TV also has PLEX installed on it(through Roku I think). You’ll need to set them both up or you won’t get notified that things are happening.

I may look to have some sort of provision for this but it would need to be backwards of how I have done it. Right now you have one Bridge thing which polls the sessions API for PLEX, then you have multiple “Player” Things which have all the channels(which can be linked to items).

I’d almost like to have a second bridge thing which would be “Livingroom TV” and then Things attached to that would be the players. Not sure if that’s possible, but I may give it a go.

Also, could any maintainer or dev comment on the naming? I’d prefer not to use a namespace if someone is going to attempt to port the original v1 plex binding to OH3. ( I did look at this, but it was a little more of a mess than I was willing to take on ).

This seems like a logical structure. Bridge things are to have the connection information in a single thing, and the players are then things connected to the bridge. I’m not sure why you need a second bridge, unless this would be for a different account.

I’m guessing your binding implements part of what is possible with plex. So even if it doesn’t cover the same features. I assume it’s still possible to add those later (by you or someone else). So I would just go for the plex naming.

I actually posted an example above. Two devices that can “display” on a single device.

I obviously have it working with a single bridge, the problem is that there can be 2 “things” that could possibly be displaying there(or in the case of a picture in picture setup you could have both).

From an actual usability standpoint, most users I would think are more interested in “is something playing on the TV”, not “is the living chromecast playing”. For now you’ll need to do rules for both devices to get if something is playing, but that’s not really how people are going to use this I don’t think.

It would be ideal to have :
Bridge(Connection to PLEX) -> Bridge (TV) -> Things(Chromecast and/or Roku)

Where the Bridge TV would also have channels that would represent the device status. I don’t think it’s possible with the current backend, though not a hard problem to solve with rules and such.

I’ll keep the naming and am perfectly ok with adding to it as I go on if there is a need or a want. Need to read up a bit on the proper method to actually submit a proper pull request and I’ll get something up there in the next couple days.

1 Like

I’m also happy to test. Lack of Plex binding is the only thing stopping me migrating to OH3, as one of my main uses is to display cover art for currently playing items which works great with the current binding :slight_smile:

4 Likes

I’ll be putting it up very soon. It’s working currently, just need to comment the classes/methods and such as well as some sort of documentation to start off with.

It does have the same ability as the current Plex binding short of the controls(which is something I’ll be adding a little while later I think). You’ll be able to get the cover art as well as the background art if you need it.

This is not 100%, I’m mid-switching to HttpClient as per the coding guidlines and some other things aren’t quite there yet, but here is a first stab at it if anyone wants to give it a go :

Have a Happy New Year everyone!

2 Likes

hi @bhomeyer amazing work! ive just installed to test and have got both the server and 2 clients added and showing online. all that I need in my setup is the player states of playing, paused, Buffering and stopped. the playing, buffering and paused are working but with a delay of about a second and a half vs the old v1 binding which was almost instant and stopped does not appear to be working on either clients.

the only thing that I can see in the logs is.

2021-01-02 22:28:39.919 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'plex.items'
2021-01-02 22:28:45.069 [WARN ] [x.internal.handler.PlexPlayerHandler] - Handling command 'REFRESH' for plex:player:82a07372b6:23a264a2f8:state
2021-01-02 22:28:45.077 [WARN ] [x.internal.handler.PlexPlayerHandler] - Handling command 'REFRESH' for plex:player:82a07372b6:357458c2ab:state

I was going through and playing then pausing then stopping and repeating with no stopped status update.

01-02 22:24:22.925 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from NULL to Playing
2021-01-02 22:24:22.933 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from NULL to null
2021-01-02 22:24:53.104 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:24:58.132 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Paused to Playing
2021-01-02 22:25:03.219 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:25:08.243 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Paused to Playing
2021-01-02 22:25:13.352 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:35:41.861 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Paused to Playing
2021-01-02 22:36:24.322 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:36:28.458 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Paused to Playing
2021-01-02 22:36:34.525 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:36:40.629 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Paused to Playing
2021-01-02 22:36:44.772 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:36:48.813 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Paused to Buffering
2021-01-02 22:36:50.833 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Lounge_Apple_TV_PlexTVStatus' changed from Buffering to Playing
2021-01-02 22:38:42.607 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from null to Playing
2021-01-02 22:38:46.649 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:38:48.668 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from Paused to Buffering
2021-01-02 22:38:50.688 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from Buffering to Playing
2021-01-02 22:38:54.737 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from Playing to Paused
2021-01-02 22:38:56.761 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Master_Bed_Apple_TV_PlexTVStatus' changed from Paused to Playing

Yea, I’ll fix that here in a few minutes . It’s actually because of how I am doing this that causes that. When the media is “stopped” on plex, it actually disappears from the sessions list. So it no longer gets updated, which is why it get stuck in whatever state it was in.

As far as the refresh, I have that in there as I’m going to be adding in the volume and player controls, so that was some debug stuff, I’ll comment that all out for now until it’s more official. Keep you posted.

Awesome, thanks for the quick reply. Are you aware of why there is a delay of about a second and a half from when you play or pause to when the binding reflects the update, are you seeing that on your end too?

It’s been fixed and I updated the release jar file.

And yes, it can be as little as a second(change the refresh interval from 5(default) to 1 if you want. I was originally going to use the same method that the OH1 binding used(web sockets) which are “pushed” to the binding so the updates are more immediate, but I noticed on my system here that the websockets messages from Plex were never that immediate anyway, there was always a 1-2 second delay from when I “paused” something to when the message came.

So I just decided to simplify that and just use the method that I did. My Plex server is on some pretty ridiculous hardware so I can’t imagine that’s the problem, though if it becomes an issue I’ll look to switching it to the websockets method.

Awesome, thanks., that was crazy fast!

Ive just installed the update and can confirm that stopped is now showing up in the status updates!
I have tried to update the refresh interval to 1 second but it appears to have a 2 second hard coded minimum? would it be possible to have that changed to a 0.5 second minimum instead? that would be pretty close to the v1 Plex binding here for me and help out with the W.A.F. massively :blush:

Im not running anything crazy powerful for my Plex server, its just a m1 Mac mini.