Plex binding for OH3 | Will it be ported?

Thanks for the heads up, I’ll take a look here in a little bit.

Yes that’s exactly how you do it.

Do I use a token or do I use a username/password? The token from the xml url doesn’t work.

You need both… the token is specific to the plex user. If you had multiple plex users their passwords AND tokens would be different. I use my plex admin credentials, as it/they can see all the libraries and account activity.

OK. Great. I supplied all but it refuses to get data from plex. The token comes from the xml url from Get Info on a movie?

The ip/hostname in the binding needs to match the url used to pull the xml… i ran into that one earlier… i had the binding set to the ip but was using the hostname for the xml and when i changed it to ip i got the right token in the xml

I used https://10.0.0.253:32400 to start Plex in a browser. I logged in using the correct credentials. I then obtained the X-Plex-Token from the Get Info url. I used 10.0.0.253 and those credentials and the X-Plex-Token in Plex Server Thing. I get COMMUNICATION_ERROR (Plex is not returning valid session data). Ideas?

I have the problem that the server is online, but don’t recognize any players. It shows allways the value NULL. Can someone help me?
Plex Version: 1.21.3
OpenHab: 3.1.0
Jar Binding: org.openhab.binding.plex-3.1.0-SNAPSHOT.jar

@davidsimmonds, I’ve notice in my instance, when I restart my container. Plex (and a few other bridges) have communications errors. I had attributed this to the availability of resources on this machine (the actual box is scheduled to be retired in the next few months). Once everything is up , I go into Settings -> Things and disable the bridge and reenable it (the pause button). My SleepIQ bridge I usually have to do a few times. But, again usually, when it turns from red/grey to yellow, it turns green within 30 seconds.

@Regedit I have a similar problem on startup, and I discovered my fix by accident. I have my rules set to tell me when a show is started and where via Telegram. Well, I was watching a show and a new episode started right after I restarted my plex bridge. All my things where reporting UNKNOWN, but I got a message about the show starting. So I knew the rules where working. I decided to leave it sit over night and go to bed. By morning all of them were green, so my solution, patience. But that’s keeping in mind I know my machine is slated to be retired and replaced with a more powerful machine.

Hope this helps.

If not, I’m sure posting Log data will be crucial in someone being able to assist.

Thanks
a

Hey,

just tried this and cant get Bridge to work. Bridge goes online for about 1 Minute before going offline again. Also discovery doesnt work.

PMS-Version: 1.21.3.4021
Openhab-Version: openHAB 3.0.1
JAR Binding: org.openhab.binding.plex-3.1.0-SNAPSHOT.jar v0.6

Log output:

2021-02-10 16:13:45.420 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘plex:server:265e8db400’ changed from OFFLINE to ONLINE
2021-02-10 16:13:45.422 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘PlexServer_CurrentPlayers’ changed from NULL to 0
2021-02-10 16:13:45.423 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘PlexServer_CurrentPlayersActive’ changed from NULL to 0
2021-02-10 16:14:55.541 [WARN ] [x.internal.handler.PlexServerHandler] - An exception occurred while polling the PLEX Server: ‘null’
2021-02-10 16:14:55.544 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘plex:server:265e8db400’ changed from ONLINE to OFFLINE
2021-02-10 16:15:00.552 [WARN ] [x.internal.handler.PlexServerHandler] - An exception occurred while polling the PLEX Server: ‘null’
2021-02-10 16:15:05.564 [WARN ] [x.internal.handler.PlexServerHandler] - An exception occurred while polling the PLEX Server: ‘null’
2021-02-10 16:15:09.165 [ERROR] [nternal.DiscoveryServiceRegistryImpl] - Cannot trigger scan for thing types ‘[plex:player, plex:server]’ on ‘PlexDiscoveryService’!
java.lang.NullPointerException: null
at org.openhab.binding.plex.internal.handler.PlexServerHandler.getAvailablePlayers(PlexServerHandler.java:154) ~[?:?]

at org.openhab.binding.plex.discovery.PlexDiscoveryService.startScan(PlexDiscoveryService.java:24) ~[?:?]

at org.openhab.core.config.discovery.AbstractDiscoveryService.startScan(AbstractDiscoveryService.java:194) ~[bundleFile:?]

at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:377) [bundleFile:?]

at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScans(DiscoveryServiceRegistryImpl.java:362) [bundleFile:?]

at org.openhab.core.config.discovery.internal.DiscoveryServiceRegistryImpl.startScan(DiscoveryServiceRegistryImpl.java:211) [bundleFile:?]

at org.openhab.core.io.rest.core.internal.discovery.DiscoveryResource.scan(DiscoveryResource.java:105) [bundleFile:?]

at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]

at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) [bundleFile:1.0.9]

at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) [bundleFile:1.0.9]

at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) [bundleFile:1.0.9]

at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) [bundleFile:1.0.9]

at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) [bundleFile:1.0.9]

at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) [bundleFile:1.0.9]

at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [bundleFile:1.0.9]

at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [bundleFile:1.0.9]

at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) [bundleFile:1.0.9]

at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) [bundleFile:1.0.9]

at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) [bundleFile:1.0.9]

at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) [bundleFile:1.0.9]

at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) [bundleFile:1.0.9]

at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) [bundleFile:1.0.9]

at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:220) [bundleFile:1.0.9]

at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [bundleFile:3.1.0]

at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) [bundleFile:1.0.9]

at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) [bundleFile:9.4.20.v20190813]

at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [bundleFile:?]

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) [bundleFile:9.4.20.v20190813]

at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [bundleFile:?]

at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [bundleFile:9.4.20.v20190813]

at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [bundleFile:?]

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.Server.handle(Server.java:494) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]

at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]

at java.lang.Thread.run(Thread.java:834) [?:?]

2021-02-10 08:10:45.783 [WARN ] [ex.internal.handler.PlexApiConnector] - Could not connect webSocket URI wss://10.0.0.253:32400/:/websockets/notifications?X-Plex-Token=RcAFYDy8Gzq8xDPabDU2 message Unable to establish loopback connection:{}
java.io.IOException: Unable to establish loopback connection
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:94) ~[?:?]
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:61) ~[?:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
at sun.nio.ch.PipeImpl.(PipeImpl.java:171) ~[?:?]
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50) ~[?:?]
at java.nio.channels.Pipe.open(Pipe.java:155) ~[?:?]
at sun.nio.ch.WindowsSelectorImpl.(WindowsSelectorImpl.java:142) ~[?:?]
at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:44) ~[?:?]
at java.nio.channels.Selector.open(Selector.java:295) ~[?:?]
at org.eclipse.jetty.io.SelectorManager.newSelector(SelectorManager.java:383) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.io.ManagedSelector.doStart(ManagedSelector.java:110) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.io.SelectorManager.doStart(SelectorManager.java:262) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.client.AbstractConnectorHttpClientTransport.doStart(AbstractConnectorHttpClientTransport.java:64) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.client.HttpClient.doStart(HttpClient.java:244) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.websocket.client.WebSocketClient.doStart(WebSocketClient.java:355) ~[bundleFile:9.4.20.v20190813]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72) ~[bundleFile:9.4.20.v20190813]
at org.openhab.binding.plex.internal.handler.PlexApiConnector.connect(PlexApiConnector.java:291) [bundleFile:?]
at org.openhab.binding.plex.internal.handler.PlexServerHandler.lambda$1(PlexServerHandler.java:120) [bundleFile:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.net.BindException: Address already in use: connect
at sun.nio.ch.Net.connect0(Native Method) ~[?:?]
at sun.nio.ch.Net.connect(Net.java:476) ~[?:?]
at sun.nio.ch.Net.connect(Net.java:468) ~[?:?]
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:694) ~[?:?]
at java.nio.channels.SocketChannel.open(SocketChannel.java:194) ~[?:?]
at sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(PipeImpl.java:127) ~[?:?]
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:76) ~[?:?]
… 35 more

I see this in Plex console:

Request: [10.0.0.253:59358] rejected because secure connections are required

What do I need to do to make secure connections are in place?

I think that I figured it out. Now all is online. I had in Plex in Network Secure settings “Required”. I set it to “Preferred” and Plex Server Thing is now online."

Is there documentation about how to control the lights with this binding now that it is working?

Does this help?

Great, thanks for re-posting. Updated Plex on QNAP to 1.21.3.4021 and installed the v0.6 binding and it’s back to working, however, I did find that the Server item showed as offline - config error until I just edited and then pressed Save without changing anything.

So, I now just have the two issues:

1 - Cover Art not showing (see my earlier post)
2 - Wanting the Show as well as the Episode name (same as @Hendrik_Nielsen)…
:slight_smile:

I’m looking into this, as I have it set to secure connections here and working fine.

I’ll update this likely next week, as well as submit the pull request to get this added into the OH3 repositories.

Thanks everyone for the feedback, it’s appreciated!

2 Likes

Is there an answer please?

Hi mate,

First of all, great job.
I am testing some config out as it’s not clear which token and playerID works.
I have found and used the UI to create the bridge and that seems to be working. It doesn’t find any of the players though.

Can I help you with logs or anything?

Cheers,

Pim

On vacation here, but you’ll need to have something playing for the scan to work.

I had 3 clients playing,but no worries…Enjoy your holidays :sunglasses:

How do I get the player id of the player that I want to control. I need to use this id in Plex Player Monitor thing.