Plex Binding on Plex Home setup

Hi all!
I’ve been trying to use the Plex binding for a while now, with no success. I think the problem is that I have activated the Home feature in plex, and that changes some of the auth settings.
I was wondering if anyone have got the plex binding to work with plex home?

Thanks
Gaute

Hey @gaute91,
Unfortunately I’m not a PlexPass user so I can’t really test this but 2 things I could suggest trying:

  • From your OpenHab server, try and look at the sessions interface whilst playing some media. It may give you some info on whether there is an auth problem. URL should be http://:32400/status/sessions
  • You can also a list of networks which are allowed without auth. In the server settings, go to network and make sure you have the advanced options showing. There you could try entering your local subnet.

The above is assuming that you’ve got the items, config and sitemap setup correctly. I followed the guide at https://github.com/openhab/openhab/wiki/Plex-Binding which was fairly straight forward.

Let us know how you go.
Murray

Same here, the Plex binding can not be used with Plex Home Setup. How should i asked to commit an update? :smile: I love openHab (started yesterday) and really want to use the Plex Binding.

Hmm,
I do not know, if this is a OpenHab or Plex related issue. I’m afraid that, with Plex home they have closed all data connections to the server…

They did not close the server connection just restrict the access. The binding needs and update so we can add user and password to communicate with the server.

If you are a Plex Pass subscriber then the new 1.8 binding will work. Once you install the new binding you need to get your authentication token and username/email/password added to openhab.cfg like so:

plex:username=
plex:email=
plex:authenticationToken=

I can’t figure out how to get it to work…

The plugin outputs this message every 5 sec

2015-11-29 12:36:15.924 [DEBUG] [.b.plex.internal.PlexConnector] - Server returned HTTP response code: 401 for URL: http://192.168.1.13:32400/clients
java.io.IOException: Server returned HTTP response code: 401 for URL: http://192.168.1.13:32400/clients
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1838) ~[na:1.8.0]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439) ~[na:1.8.0]
at org.openhab.binding.plex.internal.PlexConnector.doHttpRequest(PlexConnector.java:492) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector.getDocument(PlexConnector.java:472) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector.refresh(PlexConnector.java:464) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexBinding.execute(PlexBinding.java:66) [bundlefile:na]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.7.1.jar:na]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.7.1.jar:na]

And when I try to send a command to plex it says:

2015-11-29 12:41:56.707 [DEBUG] [.b.plex.internal.PlexConnector] - Calling url http://192.168.1.13:32400/player/playback/play
2015-11-29 12:41:56.742 [ERROR] [.b.plex.internal.PlexConnector] - Error while sending command to Plex: Internal Server Error

<?xml version='1.0' encoding='utf-8'?> Traceback (most recent call last): File "bundles-release/Framework.bundle-dist-ninja/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 843, in handle_request File "/usr/lib/plexmediaserver/Resources/Plug-ins-a10e3c2/System.bundle/Contents/Code/playerservice.py", line 50, in process_remote_command raise FrameworkException('Unable to find player with identifier %s' % identifier) FrameworkException: Unable to find player with identifier ca6724e6-98fe-4670-bf41-42fb43b183a1

It seems to get that I start playing something in plex. When I watch something it outputs this message:

2015-11-29 12:42:05.190 [DEBUG] [.b.plex.internal.PlexConnector] - [192.168.1.13]: Message received: {“_elementType”:“NotificationContainer”,“type”:“playing”,“size”:1,“_children”:[{“_elementType”:“PlaySessionStateNotification”,“sessionKey”:“2”,“guid”:“”,“ratingKey”:“1539”,“url”:“”,“key”:“/library/metadata/1539”,“viewOffset”:11181,“state”:“paused”,“transcodeSession”:“tsm6d3n30epnwmi”}]}
2015-11-29 12:42:05.191 [DEBUG] [.b.plex.internal.PlexConnector] - Refreshing Plex sessions
2015-11-29 12:42:05.215 [DEBUG] [.b.plex.internal.PlexConnector] - Server returned HTTP response code: 401 for URL: http://192.168.1.13:32400/status/sessions
java.io.IOException: Server returned HTTP response code: 401 for URL: http://192.168.1.13:32400/status/sessions
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1838) ~[na:1.8.0]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439) ~[na:1.8.0]
at org.openhab.binding.plex.internal.PlexConnector.doHttpRequest(PlexConnector.java:492) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector.getDocument(PlexConnector.java:472) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector.refreshSessions(PlexConnector.java:292) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector.getSession(PlexConnector.java:343) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector.access$5(PlexConnector.java:341) [bundlefile:na]
at org.openhab.binding.plex.internal.PlexConnector$PlexWebSocketListener.onMessage(PlexConnector.java:444) [bundlefile:na]
at com.ning.http.client.providers.netty.NettyWebSocket.onTextFragment(NettyWebSocket.java:202) [async-http-client-1.8.4.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider$WebSocketProtocol.handle(NettyAsyncHttpProvider.java:2380) [async-http-client-1.8.4.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.messageReceived(NettyAsyncHttpProvider.java:1220) [async-http-client-1.8.4.jar:na]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [netty-3.9.0.Final.jar:na]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [netty-3.9.0.Final.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]

Do you have any idea whats wrong?

thanks.
G

Did you delete the old binding as well?

Yepp,
I did manage it to work. Seems like I missed the plex:password= attribute.

Now I have another issue…
It works fine, as long as the player is inside my home network, but when I try to control a player on another network (openhab and plex in my summerhouse) it does not register on the ip:34200/clients list.
I have tried to open the right ports according to https://support.plex.tv/hc/en-us/articles/201543147-What-network-ports-do-I-need-to-allow-through-my-firewall- but no luck.

Any ideas?

This may be a stupid question, but where do I find/how do I install the 1.8 binding?

thanks!

Download *addons.zip on cloudbees, unzip and then just copy the jar you want to use in your /addons folder.

thank you all - 1.8 is now working perfectly for reading the status of Plex. However it won’t send commands to Plex - I get an error if (for example) I press the “up” key::

ERROR o.o.b.p.internal.PlexConnector[:329]- Error while sending command to Plex: Bad Request
<html><head><title>Bad Request</title></head><body><h1>400 Bad Request</h1></body></html>

I’d be grateful for any suggestions!

did anyone get the binding working with plex media player on raspberry pi? I can not get status or commands working. I have runtime and addons in version 1.8. I do not get errors, config is fully done with user, password and token.

I’m getting the same error as @dan12345.

1.8 is working great for reading the status of plex but all of my commands fail with a “400 bad request”

I’d appreciate any help!

I’m having the same issue. Were you able to figure this out?

I can only see Status, the percentage played, movie title and media type in my Plex Media Player running on Raspberry Pi 2. Can’t control anything with openhab.

I wasn’t able to fix this, and I also had problems with openHAB losing its connection to Plex for no apparent reason. So I’ve uninstalled the binding and am using the Harmony binding for now to do some of the same stuff.

Guys, I can’t find the jar file at https://github.com/openhab/openhab/wiki/Plex-Binding. Can anyone point me in the right direction to it?

Many thanks

Here are the ones that I’ve tried. I was never able to get them to work though:

https://www.versioneye.com/java/org.openhab.binding:org.openhab.binding.plex/1.9.0.b2

Hi all,

I’ve installed the Plex binding from the list of bindings for OH2 in PaperUI.

I installed it according to the wiki, but to no avail in that the commands do not control the player.

I’m on a RPi 3 B, the Plex server is running well and works with the clients on my Windows PC as well as on 2 androids (running the official Plex clients).

For example I pressed two commands from BasicUI, here’s the tail:

tail: /var/log/openhab2/openhab.log: file truncated

==> /var/log/openhab2/events.log <==
2017-01-31 21:52:16.744 [ItemCommandEvent          ] - Item 'PlexTVPlay' received command ON

==> /var/log/openhab2/openhab.log <==
2017-01-31 21:52:16.751 [WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/PlexTVPlay] {bridgemarker=true, item=PlexTVPlay, command=ON} | {org.osgi.service.event.EventHandler}={component.name=org.openhab.binding.plex.binding, port=32400, token=xxxxxxxxxxxxxxxxxxxx, username=UglyKidJoe888, refresh=5000, service.pid=org.openhab.plex, component.id=178, password=xxxxxxxx, event.topics=openhab/command/*, host=http://192.168.178.153, service.id=309, service.bundleid=195, service.scope=bundle} | Bundle(org.openhab.binding.plex_1.10.0.201701300211 [195])]
java.lang.NullPointerException
        at org.openhab.binding.plex.internal.PlexBinding.internalReceiveCommand(PlexBinding.java:147)[195:org.openhab.binding.plex:1.10.0.201701300211]
        at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:97)[183:org.openhab.core.compat1x:2.1.0.201701231811]
        at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:42)[183:org.openhab.core.compat1x:2.1.0.201701231811]
        at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[6:org.apache.karaf.services.eventadmin:4.0.8]
        at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[6:org.apache.karaf.services.eventadmin:4.0.8]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

==> /var/log/openhab2/events.log <==
2017-01-31 21:52:16.755 [ItemStateChangedEvent     ] - PlexTVPlay changed from OFF to ON
2017-01-31 21:52:18.610 [ItemCommandEvent          ] - Item 'PlexTVStop' received command ON

==> /var/log/openhab2/openhab.log <==
2017-01-31 21:52:18.617 [WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/PlexTVStop] {bridgemarker=true, item=PlexTVStop, command=ON} | {org.osgi.service.event.EventHandler}={component.name=org.openhab.binding.plex.binding, port=32400, token=xxxxxxxxxxxxxxxxxxxx, username=UglyKidJoe888, refresh=5000, service.pid=org.openhab.plex, component.id=178, password=xxxxxxxxx, event.topics=openhab/command/*, host=http://192.168.178.153, service.id=309, service.bundleid=195, service.scope=bundle} | Bundle(org.openhab.binding.plex_1.10.0.201701300211 [195])]
java.lang.NullPointerException
        at org.openhab.binding.plex.internal.PlexBinding.internalReceiveCommand(PlexBinding.java:147)[195:org.openhab.binding.plex:1.10.0.201701300211]
        at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:97)[183:org.openhab.core.compat1x:2.1.0.201701231811]
        at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:42)[183:org.openhab.core.compat1x:2.1.0.201701231811]
        at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[6:org.apache.karaf.services.eventadmin:4.0.8]
        at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[6:org.apache.karaf.services.eventadmin:4.0.8]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

My playerid is “Plex Web (Chrome)” which I got from the xml details from the Plex Web Player.

I’m only working on my LAN as I’m in a guesthouse and can’t forward any ports. If I put the details to list the clients in the URL in chrome I get a “401 Unauthorised” error. Maybe this is the root cause?

<Device name="Plex Web (Chrome)" 

I’ve tried it with another device with a cleaner name, I.e. B1-760HD, but no difference. I’ve also tried it with the clientIdentifier=“wpbyyjxxxx5x6cfqevxxxxxx”, still no luck.

Sample .items (copy and pasted from the wiki but changed the identifier):

/* -----------------Plex----------------- */
Switch PlexTVPower      "Power"         <video>     	(gMedia)	{plex="Plex Web (Chrome)#power"}
String PlexTVStatus     "Status [%s]"   <video>     	(gMedia)	{plex="Plex Web (Chrome)#state"}
String PlexTVTitle      "Title [%s]"    <video>     	(gMedia)	{plex="Plex Web (Chrome)#title"}
String PlexTVType       "Type [%s]"     <video>     	(gMedia)	{plex="Plex Web (Chrome)#type"}
String PlexTVCover      "Cover"         <video>     	(gMedia)	{plex="Plex Web (Chrome)#playback/cover"}

Are there maybe dependent bindinds maybe that I missed? I have a very basic installation, no MQTT or HTTP bindings.

Any clues?

Edit:
Also tried this from looking at other posts…

Still not working. Any ideas would be much appreciated.