What have you done with your Plex binding?

I’m looking for some good ideas about how to use the plex binding (we use plex through out the house via rokus)

Currently I have done the following:

  • Hue light goes from green through to red mapped against progress (So it’s red when the program finishes)
  • A lamp comes on when a program is paused/stopped and it’s after 7.

I can’t quite get wife approval for pausing the current show when the doorbell goes off, but I’m hoping that if I make it after 7 it should get approved :smile:

I’m thinking about also implementing voice control “Play xxx on xxx” I’m guessing it should be possible.

Has anyone else done anything interesting with this binding?

I’m interested in what people are doing with the Plex binding as I too have Plex throughout the house on Rokus and on the go on my phone. But I’ve yet to some up with a compelling use case or problem to solve with the binding. When it comes to home automation “because I can” is not a good enough reason for me to implement something anymore. When I was first learning OH it was a great excuse but now I need my home automation to solve a problem and do so in a way that is faster/better/easier than manual alternatives.

I have three that involve my roku/plex:

A) in the morning I switch on my tv roku, so I tell my roku to start the plex channel since that’s the only one I use. Saves literally milliseconds :confused:
B) If it’s after 7pm and I pause/stop a program I turn a lamp on (and I turn it off when it’s running). Just means if it’s dark after a show I don’t have to stumble around for a light
C) If the doorbell goes off I paused plex.

I am thinking about trying to add voice automation to start programs on plex

My setup is the same a bunch of Rokus with a central Plex server. The problem is my family uses several apps on the Rokus such as NetFlix and Amazon, so Plex is not always in the loop.

Hi guys,

I just installed the plex binding, and have setup the lights to dimm down when playing and back on when pause/stop, that works fine. I am now trying to pause on incoming phone call / door bell but the pause/play switches are not working outbound. The switches do report (inbound) the status of the player but flicking them doesn’t pause/play.
These are my items:

String PlexTVStatusSamsung     "Plex [%s]"  {plex="id#state"}
Switch PlexTVPauseSamsung     "Pause"      {plex="id#playback/pause"}
Switch PlexTVPlaySamsung       "Play"          {plex="id#playback/play"}

I have two players (AppleTv and Samsung smart TV) and behavior is the same on both.

Any ideas?[quote=“rlkoshak, post:2, topic:5846”]
I’m interested in what people are doing with the Plex
[/quote]
So far I’ve just implemented what I described above, but I would like to display text on screen (caller id, if a motion sensor goes off, etc.). But I guess another use might be to do parental control (how much TV have the kids watched, appropriate content…) the problem is, as @sipvoip says, plex is just one of the many options for watching content.

Some players (like RasPlex and the Mac app) just ‘toggle’ the play/pause state if you send either the play or the pause command. Others, like the iOS clients, want the specific command the for the current state of the player. For this I just added the ‘playback/playpause’ property. Code is here: https://github.com/openhab/openhab/pull/4004 . There’s also an updated binding jar there which contains this change if you want to try this out.

Edit: code has been merged, it’s also in the latest nightly build of the 1.x bindings.

Hi @idserda, tried your new binding (org.openhab.binding.plex_1.9.0.201602082125.jar) but it doesn’t pause my Plex (both on AppleTV and Samsung clients). In fact, with the previous binding the UI was showing if the client was playing or in pause and with the new one it doesn’t show.
My items are as follows

Switch PlexTVPauseAppleTv      "Pause AppleTv"       {plex="id#playback/playpause"} 
Switch PlexTVPlayAppleTv       "Play AppleTv"       {plex="id#playback/play"}

Thanks

Weird stuff… just tested it with both RasPlex and an iOS player, both seems to work fine. Could you set the log level to debug for the binding and see if there are any clues there?

I get all sorts of errors (tried also to download the nightly build):

2016-02-09 21:07:41.402 [DEBUG] [.b.plex.internal.PlexConnector] - Error connecting to Plex
java.util.concurrent.ExecutionException: java.net.ConnectException: wss://IP+token.plex.direct:32400/:/websockets/notifications
	at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:341) ~[async-http-client-1.8.4.jar:na]
	at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:107) ~[async-http-client-1.8.4.jar:na]
	at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145) ~[netty-3.9.0.Final.jar:na]
	at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1130) ~[async-http-client-1.8.4.jar:na]
	at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:927) ~[async-http-client-1.8.4.jar:na]
	at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:524) ~[async-http-client-1.8.4.jar:na]
	at com.ning.http.client.AsyncHttpClient$BoundRequestBuilder.execute(AsyncHttpClient.java:236) ~[async-http-client-1.8.4.jar:na]
	at org.openhab.binding.plex.internal.PlexConnector.open(PlexConnector.java:189) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexConnector.connect(PlexConnector.java:474) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexConnector.run(PlexConnector.java:177) [bundlefile:na]
Caused by: java.net.ConnectException: wss://IP+token.plex.direct:32400/:/websockets/notifications
	at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:103) ~[async-http-client-1.8.4.jar:na]
	... 9 common frames omitted
Caused by: java.nio.channels.UnresolvedAddressException: null
	at sun.nio.ch.Net.checkAddress(Net.java:101) ~[na:1.8.0_65]
	at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622) ~[na:1.8.0_65]
	at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:108) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:70) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.handler.ssl.SslHandler.handleDownstream(SslHandler.java:608) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:54) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:97) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.channel.Channels.connect(Channels.java:634) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:207) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:229) ~[netty-3.9.0.Final.jar:na]
	at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:182) ~[netty-3.9.0.Final.jar:na]
	at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1091) ~[async-http-client-1.8.4.jar:na]
	... 6 common frames omitted

I tried again with 1.8.1 binding and I get no errors.

Hmm ok… can you resolve/ping the IP+token.plex.direct host? If not, there might be a solution on this page https://support.plex.tv/hc/en-us/articles/206225077-How-to-Use-Secure-Server-Connections under ‘DNS Rebinding’. The latest version of the binding connects to this URL to support ‘secure only’ Plex servers.

@idserda, thanks for the help. I have added the rebinding configuration to my openwrt router:

in /etc/config/dhcp:

list rebind_domain 'plex.direct'

And checked that IP+token.plex.direct can de resolved.

now I am getting this in the logs:

2016-02-10 11:07:50.108 [DEBUG] [.b.plex.internal.PlexActivator] - Plex binding has been started.
2016-02-10 11:07:50.302 [INFO ] [p.i.PlexGenericBindingProvider] - Plex item PlexTVStatusSamsung bound to client xtcb3exsmw6qi property state
2016-02-10 11:07:50.304 [INFO ] [p.i.PlexGenericBindingProvider] - Plex item PlexTVPauseSamsung bound to client xtcb3exsmw6qi property playback/playpause
2016-02-10 11:07:50.306 [INFO ] [p.i.PlexGenericBindingProvider] - Plex item PlexTVPlaySamsung bound to client xtcb3exsmw6qi property playback/play
2016-02-10 11:07:50.319 [INFO ] [p.i.PlexGenericBindingProvider] - Plex item PlexTVStatusAppleTv bound to client E5615CED-D8A2-4687-80E7-F80A11116BE0 property state
2016-02-10 11:07:50.321 [INFO ] [p.i.PlexGenericBindingProvider] - Plex item PlexTVPauseAppleTv bound to client E5615CED-D8A2-4687-80E7-F80A11116BE0 property playback/playpause
2016-02-10 11:07:50.323 [INFO ] [p.i.PlexGenericBindingProvider] - Plex item PlexTVPlayAppleTv bound to client E5615CED-D8A2-4687-80E7-F80A11116BE0 property playback/play
2016-02-10 11:07:50.401 [DEBUG] [.o.b.plex.internal.PlexBinding] - Plex config, server at 192.168.0.XXX:32400
2016-02-10 11:07:54.029 [DEBUG] [.b.plex.internal.PlexConnector] - Connecting web socket to Plex
2016-02-10 11:07:54.134 [INFO ] [.service.AbstractActiveService] - Plex Refresh Service has been started
2016-02-10 11:07:54.450 [DEBUG] [.b.plex.internal.PlexConnector] - Remote host closed connection during handshake
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) ~[na:1.8.0_65]
	at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) ~[na:1.8.0_65]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) ~[na:1.8.0_65]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513) ~[na:1.8.0_65]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) ~[na:1.8.0_65]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) ~[na:1.8.0_65]
	at org.openhab.binding.plex.internal.PlexConnector.doHttpRequest(PlexConnector.java:603) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexConnector.getDocument(PlexConnector.java:580) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexConnector.refresh(PlexConnector.java:573) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexBinding.execute(PlexBinding.java:59) [bundlefile:na]
	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.0.jar:na]
	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.0.jar:na]
Caused by: java.io.EOFException: SSL peer shut down incorrectly
	at sun.security.ssl.InputRecord.read(InputRecord.java:505) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973) ~[na:1.8.0_65]
	... 14 common frames omitted
2016-02-10 11:07:56.926 [DEBUG] [.b.plex.internal.PlexConnector] - Error connecting to Plex
java.util.concurrent.ExecutionException: java.net.ConnectException: wss://192-168-0-XXX.token.plex.direct:32400/:/websockets/notifications
	at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:341) ~[na:na]
	at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:107) ~[na:na]
	at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) ~[na:na]
	at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:413) ~[na:na]
	at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:380) ~[na:na]
	at org.jboss.netty.handler.ssl.SslHandler.channelDisconnected(SslHandler.java:661) ~[na:na]
	at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:102) ~[na:na]
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[na:na]
	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[na:na]
	at org.jboss.netty.channel.Channels.fireChannelDisconnected(Channels.java:396) ~[na:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:360) ~[na:na]
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:93) ~[na:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) ~[na:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318) ~[na:na]
	at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[na:na]
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[na:na]
	at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[na:na]
	at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[na:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_65]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_65]
	at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_65]
Caused by: java.net.ConnectException: wss://192-168-0-XXX.token.plex.direct:32400/:/websockets/notifications
	at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:103) ~[na:na]
	... 19 common frames omitted

PS: I’ve also noticed that with binding version 1.8 I also have those errors, it’s just that prior to this I had not set the logs to DEBUG.

What Java version are you using? Could you try with 7 or 8 to see if that makes any difference?

java version "1.8.0_65"
Java™ SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot™ Client VM (build 25.65-b01, mixed mode)

I upgraded java and the problem disappeared with binding version 1.8 (no more errors on logs). With 1.9, I am now getting this error:

2016-02-11 12:25:29.896 [DEBUG] [.b.plex.internal.PlexConnector] - java.security.cert.CertificateException: No subject alternative DNS name matching 192-168-0-XXX.token.plex.direct found.
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching 192-168-0-110.e9fbf58aef054c5bbd29c24c35149ccd.plex.direct found.
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) ~[na:1.8.0_65]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) ~[na:1.8.0_65]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) ~[na:1.8.0_65]
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) ~[na:1.8.0_65]
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) ~[na:1.8.0_65]
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) ~[na:1.8.0_65]
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) ~[na:1.8.0_65]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) ~[na:1.8.0_65]
	at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) ~[na:1.8.0_65]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) ~[na:1.8.0_65]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513) ~[na:1.8.0_65]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) ~[na:1.8.0_65]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) ~[na:1.8.0_65]
	at org.openhab.binding.plex.internal.PlexConnector.doHttpRequest(PlexConnector.java:603) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexConnector.getDocument(PlexConnector.java:580) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexConnector.refresh(PlexConnector.java:573) [bundlefile:na]
	at org.openhab.binding.plex.internal.PlexBinding.execute(PlexBinding.java:59) [bundlefile:na]
	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:156) [org.openhab.core_1.8.0.jar:na]
	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173) [org.openhab.core_1.8.0.jar:na]
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching 192-168-0-XXX.token.plex.direct found.
	at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:204) ~[na:1.8.0_65]
	at sun.security.util.HostnameChecker.match(HostnameChecker.java:95) ~[na:1.8.0_65]
	at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455) ~[na:1.8.0_65]
	at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436) ~[na:1.8.0_65]
	at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200) ~[na:1.8.0_65]
	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) ~[na:1.8.0_65]
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) ~[na:1.8.0_65]
	... 18 common frames omitted

Hi guys,

It there any way of playing particular playlist from OH on a Plex player?
I’ve got RasPlex connected to the audio system but when I stop playing a track I cannot resume it until I select something on my Android Plex remote.
Thanks!

I’m pretty sure you can play a playlist using the plex api, but you can’t do things like shuffle it which made it a bit pointless for me.

@rossdargan As long as I can start playing a playlist from OpenHAB I will be really happy :slight_smile:
It’s pretty easy to make several random playlists.
Any ideas how can I do that?
Cheers!

1 Like

@idserda
Hi, I’ve just a question, which of the properties work on a iOS Plex (I run it on my MacMini). It seems, that
playback/play, playback/stepForward, title, and some others won’t work.
Is this correct?
For example playback/volume or navigation/move* work.
Am I doing something wrong, or is it what you mean in the wiki with
"Note: not all Plex clients support all properties. Status properties work on all platforms, except for the power property in the web client. Navigation commands are not support by the Android nor the web client. "

Kind regards,
Michael

Hi Michael, I’m afraid some actions just don’t work on some client platforms. Which client are you using exactly? The macOS Plex Media Player, or the Plex app on iOS?

Hi Jeroen,
thanks for your reply. I know that there are not all functions available with all players. Just to be sure I’m doing right, I’ld appreciate your confirmation. I’m only using the macOS Plex Media Player.
For example I can’t get

{plex=“xxxx#title”}
{plex=“xxxx#type”}
{plex=“xxxx#playback/progress”}
{plex=“xxxx#playback/endTime”}

running. Other commands work fine, like

{plex=“xxxx#playback/pause”}
{plex=“xxxx#playback/stop”}
{plex=“xxxx#playback/play”}

BTW I want mention, that

{plex=“xxxx#state”}

shows always “stopped”, even when a movie is running. I use my plex just for viewing movies, I don’t use it as music player.

Thanks,
Michael