I thought I had that at 1 second, but maybe changed that at some point.
I’d prefer not to be hammering away at the plex server (and OH) at some rate like that. Remember, this binding is polling the server, so it’s a bit different than the OH1 version. I’ll code a bit for the websockets updates and see if that’s going to make any sort of improvement in regards to this. If I’m going to gain 1/4 of a second, I don’t know that it’s worth the effort or complexity, but if it’s something where it can make a big difference then I’ll certainly switch it up.
For what I am using this for a second or so doesn’t matter, but I guess I can see that you might want lights to come on immediately when you pause a movie. I’ll look into that. Thanks for the feedback, it’s appreciated!
Awesome, thanks. No rush, it’s working now with the same functionality as the v1 binding, just a little slower. I get that it’s probably a massive task to change the approach to using webhooks. but if you do get a chance to have a look that would be fantastic and I’d obviously be more than happy to do any testing necessary to help.
Yup you’ve got it in one. That’s exactly what we use it for. We watched a movie tonight and my wife hit pause to grab a drink and asked what I’d changed for it to now have a delay
Glad to hear it’s working for you, albeit a minor issue.
I’ll look tonight and make some adjustments in the coming days if I think it will help with this situation, not really a huge deal. I’ll likely keep the same code, but add the handling for the websocket so it might update more frequently(which would reduce the possible lag). The only data the comes in from the websocket is the media playing progress and the state so it’s pretty easy to handle that.
My job is to keep wives happy, lol… thanks again for testing! Probably will update it again Tuesday or so, apologies to the wife.
Just a heads up here, might take me a little bit longer to get this 100%. PLEX currently supports only JSON on their websocket implementation and only XML on other parts of their stuff. So I’m going to do a little work on cleaning this up a bit so it’s not a jumbled mess. It will need to support both XML and JSON to make it work right, so I’ll get that done. I’m going to stick with the same method I am currently using as far as using machineIDs and such, though I am going to use the websocket only for the state and possibly the viewOffset(progress of media).
I have the websockets working and updating so I’m going to do some timing tests here before I go to far with this, from what I can tell now I save about 300-450ms by using the web sockets. Which I think is a valid case for making the change.
Should have something updated a little more cleanly for tomorrow or Monday night to make your wife happy again.
once again amazing work and speed! thanks mate! We really appreciate the time you are putting into this for the community. Any way we can shout you a beer or a bottle of wine?
No problem at all. Pay it forward man.
Just an update. I’ll be finished with the changes and tomorrow I will update it then after I have a chance to document all the changes, etc. I’ll also make an “official” post on the bindings forum looking for more testers.
Changed a bunch of things, but nothing serious and nothing that should affect your usability. I’ve added the websocket to plex which should cut the delay time down to anywhere between 220ms and 480ms from what I can tell. Wives everywhere will be thrilled.
good work mate, can’t wait to install and test!
Give it a go :
Still have a small timing issue bug with the websocket, but I’ll get that fixed tomorrow. I like to meet deadlines. This should work fine for you though, still maintains the same setup and config, just adds in the websocket connection that will refresh the player status. You might see a “Failed to update” message in the logs when you first add a player, or on a restart, that’s what I’m calling a known issue. It’ll get addressed tomorrow.
This update fixes a small issue with the websocket reconnect logic as well as adds a discovery process.
To discover player things you’ll just need to click “Scan” at the top of the binding page once the server(bridge) is configured. Any device that is currently on your local network and is playing something will show up as a player thing that you can then add.
This does nothing but save you from having to manually find your token and request a sessions page to figure them all out. I didn’t make it automatic as that could be somewhat annoying for players you won’t usually care about(people’s phones, tablets, etc).
That was fast! Sorry for the delay. We’ve just got 2 new kittens so things have been a little crazy around here. I’ve just installed the latest version and I’m authenticating with a username and password and it’s not working. In the api it says… CONFIGURATION_ERROR
Unable to fetch API, token may be wrong?I’ve deleted the things and re added them with no luck.
So I tried with a token and get the same result. I’ve double checked that everything else is correct.
2021-01-08 18:45:50.265 [WARN ] [x.internal.handler.PlexServerHandler] - Bridge: Monitor handler was disposed for plex:player:82a07372b6:23a264a2f8 with id 00E21940-D840-4B0F-AB72-A6924D0512ED
2021-01-08 18:45:50.290 [WARN ] [x.internal.handler.PlexServerHandler] - Bridge: Monitor handler was disposed for plex:player:82a07372b6:357458c2ab with id 0036F8F4-A2E6-4972-BA32-8E65C6774999
2021-01-08 18:45:56.004 [WARN ] [x.internal.handler.PlexServerHandler] - Bridge: Monitor handler was initialized for plex:player:82a07372b6:23a264a2f8 with id 00E21940-D840-4B0F-AB72-A6924D0512ED
2021-01-08 18:45:56.012 [WARN ] [x.internal.handler.PlexServerHandler] - Bridge: Monitor handler was initialized for plex:player:82a07372b6:357458c2ab with id 0036F8F4-A2E6-4972-BA32-8E65C6774999
Edit… after a reboot its up… ill have a quick look now and report back shortly!
you are seriously a legend! its back to being almost instant again! the wife stoked.
Glad it’s all working out for you. Any suggestions, comments, complaints, spelling mistakes?
Fairly easy to setup and understand I hope?
When you plan to insert it on the binding store?
Was just hoping for some more feedback, but probably this week at some point I’ll submit it.
I just started testing OH3 and I try to get this to work with my plex server and player.
The server connections seems to be fine, since the bridge item is showing online.
However trying to create a Monitor Item for my Shield running Plex App I get nothing but “unkown” and the channels do not update when I link them.
The openhab.log states
Handler PlexPlayerHandler of thing plex:player:4b36ca7b99:041c40b2bd tried updating channel endtime although the handler was already disposed.
I am not sure if I use the right id in the config. What id should go there? Where do I get it from?
I tried with the
clientIdentifier from plex.tv/devices
You should just be able to scan while you’re playing something on the client and it’ll show up.
Yeah, that doesn’t work.
If the connection to my Plex server would actually work, should’t the two channels for playercount show something else but NULL?
I have the feeling that the connection to my Plex server is actually not working, even though it says its online.
I am running OH3 in a docker container on a macvlan that is logically attachted to my home network, btw.
Did a clean instance OH3.1.0 snapshot, only added the Plex binding, still doesn’t work.
Plex does run in a container on the exact same network, too. Just like OH2, with Plex Binding v1.
The only difference I can tell is, that my server is not reachable from the new Plex binding when I just type in the container name in OH3.
In OH2 with the old Plex binding this works.
I tried both the internal LAN IP of the container (online) and the external URL that I setup in my domain (online)
Still thinking that I actually do not reach the Plex Server, even though it says it does.
If someone tells me what logs are needed, I’ll gladly provide them
Hmm, I’ll check, I think what puts that online is a successful connection to the API(not the actual plex server) since that was something that happened as an afterthought.
But I guess if you have connectivity issues there then that might be something that would cause it to not work. I have plex in a docker container here and that works without issues, but I’m binding it to the host network, so it’s not on a separate lan.
congratulations nice work
here is the things Files
Bridge plex:server:plexrServer “Bridge Plex” [host=“xxx.xxx.xxx.xxx”, password=“xxxxxx”, refreshRate=5, portNumber=32400, token=“xxxxxxxxxx”, username=“xxxxxxxx” ]
Thing plex:player:plexrServer:xxxxxxxxxxx-com-plexapp-android “Plex Player” (plex:server:plexrServer)
the bridge works but the Thing plex:player:plexrServer:xxxxxxxxxxx-com-plexapp-android
it probably does not work, I am doing something wrong
auto discovery works player id : xxxxxxxxxxx-com-plexapp-android