Plex Binding: Player State not updating/no updates on stop


i am using the Plex Binding snapshot (#1324) with openHAB2 (build #560).

So far i get some information from the binding, like current title, progress, if the client is online, etc. However i don’t get the Player State (Playing, Paused, Stopped) and after the show or movie finishes the items arent cleared. So i don’t now if a movie was playing yesterday or just now.

Should i open a github issue for that?

Thank you

hello all,

This is worst for me, I can send order to my player but I can’t get any information like Title, cover, time, etc.
I retrieved my token like explain in the binding wiki.
When I going to online webapp and get a detailed media xml, this is what the url looks like :

I checked directly from my server CLI with a curl and it work, I can see the current playing status of my rasplex.

So in /conf/services/plex.cfg I set :

I also retrieved my Rasplex Device ID and set the items file like the Wiki.

Here is the OpenHAB logs in loop:

[DEBUG] [javax.xml.bind] - Trying to locate org/openhab/binding/plex/internal/communication/
[DEBUG] [.www.protocol.http.HttpURLConnection] - pairs: {GET /clients HTTP/1.1: null}{X-Plex-Provides: controller}{X-Plex-Device: Java™ SE Runtime Environment}{X-Plex
-Client-Identifier: 3e4e9b32-d366-47e2-a378-03044e9d1338}{X-Plex-Platform-Version: 1.8.0_111}{X-Plex-Token: tokenhere}{X-Plex-Device-Name: openHAB}{X-Plex-Product: openHAB}{X-Plex-Version:}{X-Plex-Pla
tform: Java}{User-Agent: Java/1.8.0_111}{Host:}{Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2}{Connection: keep-alive}
[id: 0x74a4b9b0, null :>]
[DEBUG] [.binding.plex.internal.PlexConnector] - []: Websocket error: Invalid Status Code 401
[DEBUG] [.binding.plex.internal.PlexConnector] - []: Websocket error: Invalid Status Code 401
[DEBUG] [oviders.netty.NettyAsyncHttpProvider] - Channel Closed: [id: 0x74a4b9b0, null :>] with attachment NettyResponseFuture{cu
[oviders.netty.NettyAsyncHttpProvider] - Closing Channel [id: 0x74a4b9b0, null :>]

Controlling the rasplex player with play/pause, navigations, etc commands works and on the logs I can see :
[DEBUG] [.binding.plex.internal.PlexConnector] - Calling url

so it seem it can correctly retrieve the player IP Address.

I also tried to use localhost IP, LAN IP as Plex and OpenHAB is on the same boat with no success.
I test also without the token in plex.cfg but with username and password, and I saw in the logs that the binding correctly retrieved a valid Token, but same error on websocket.

Plex Media Server Version : without PlexHome activated. (EDIT : Just tried with PlexHome Activated with same errors)
Openhab Version : 2.0
Plex Binding Version Tested :

At this point I don’t know what to do more …

I hope to see someone with an idea for me :slight_smile:

1 Like

Another strange thing, but I’m not sure this is the right way :
I noticed the line uri=ws://,
( I have wws:// in the 1.9.0:2 jar)
When I try this in http with curl :


401 Unauthorized

But when I add the token to the request, I have no more error :
result : curl: (52) Empty reply from server
(But no 401 error)

Not sure, but does the websocket require a token too ?

EDIT : Ok, so I found a javascript to test websocket :

Testing with ws:// and got errors. But with token it work : ws:// and I receive playing notification.

On plex binding, when I watch the logs more deeper I can see :

GET /:/websockets/notifications HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Key: ovT0B+TVWkrzeFEe6VmGXeg==
Sec-WebSocket-Version: 13
Accept: /
User-Agent: NING/1.0,
httpResponse=DefaultHttpResponse(chunked: false)
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
X-Plex-Protocol: 1.0
Cache-Control: no-cache
Access-Control-Expose-Headers: Location
Access-Control-Allow-Origin: *
Date: Thu, 24 Nov 2016 18:37:00 GMT,

So it seem to forget to put the token … and I just don’t know why…

After looking in the binding sources, it seem that changing only one line is enought (or maybe I’m wrong), but I don’t know how to build the binding.

File : org.openhab.binding.plex/src/main/java/org/openhab/binding/plex/internal/

Line 149:

Original :

 this.wsUri = String.format("%s://%s:%d/:/websockets/notifications",

Probable modification :

  this.wsUri = String.format("%s://%s:%d/:/websockets/notifications?X-Plex-Token="+connection.getToken(),

I will try to look how to build this thing…

I edited the binding source and websocket works with the Token.
It is more related to a Plex Media server update (1.3 ATM) and it is not the only change :
The Json response has also been modified so the Json parsing doesn’t work anymore.

This is a message from a 1.1.4 Plex server :

and This is a 1.3 websocket message :

{“NotificationContainer”: {

Can anyone confirm if they’re having a similar problem?

I can pause/play/stop. So I can seemingly SEND commands. But nothing else works. my PlexTVStatus is coming in as STOPPED, no matter what. If I force Progress, Title, etc. to stay visible, they’re all just blank.

But for some reason, I can stop and start and pause. I cannot for the life of me figure this out.

Are you using the latest nightly build of the binding?

should be. just installed it fresh a few days ago.

Looks similar to this issue:

Could you turn on debug logging for the binding? And please let us know what version of the Media Server you are using and which clients.

Is there any update on this issue? I noticed that the issue (4875) has been closed for no apparent reason.

I definitely see the no update on stop issue and I have a fairly recent 2.1.0-SNAPSHOT

Small update (some debugging info?

I get the following in my log file (repeating over and over again) when playing:

2017-01-29 10:22:03 org.openhab.binding.plex.internal.PlexConnector$PlexWebSocketListener.onMessage( - []: Message received: {"NotificationContainer":{"type":"playing","size":1,"PlaySessionStateNotification":[{"sessionKey":"166","guid":"","ratingKey":"22840","url":"","key":"/library/metadata/22840","viewOffset":396552,"state":"paused","transcodeSession":"1hciplcix2f56hil41ns46lx"}]}}
2017-01-29 10:22:03 org.openhab.binding.plex.internal.PlexConnector$PlexWebSocketListener.onError( - []: Websocket error: null

I’m running the latest plex binding jar file (from the other thread)

191 | Active   |  80 |    | openHAB Plex Binding

Here is my items file:

// Chrome player on new iMac
String ChromePlexTVStatus     "Chrome Status [%s]"   <video>     {plex="nlji4n02ywtvkkaxwc67axla#state"}

// Chrome player on new iMac
String AppleTVPlexTVStatus     "Apple TV Status [%s]"   <video>     {plex="871ADCDB-B844-47B8-A94C-286BF43729FE#state"}

and my rules file

rule "Apple TV Pause/resume"
    Item AppleTVPlexTVStatus received update
    logInfo("rulelog", "Apple TV Play to pause")
rule "Chrome TV Pause/resume"
    Item ChromePlexTVStatus received update
    logInfo("rulelog", "Chrome Play to pause")

Here is my plex.cfg

# IP address or hostname of the Plex server

# Optional, port that the Plex server is running on. Default = 32400

# Refresh interval in ms. Default = 5000.

# If you're using Plex Home you need to supply the username and password of your
# Plex account here. If you don't want to enter your credentials you can also
# directly set your account token below instead.

 # Plex password

# Plex account token, use instead of username/password when using Plex Home.

I never get a pause or play when I pause and/or play in Chrome

That Websocket error: null does not look good. What version of the Plex Media Server are you using? And could you try and find this line in the log for the Plex binding: Server found, version xxx, api level xxx ? You’ll have to enable debug logging for this. I’ll try to reproduce this with the web client and maybe add some more debug logging.

Thanks for looking into it:
Server found, version, api level v1

Okay that’s odd. You have the new websocket message format on v1.2 of PMS, which we thought was there only after v1.3. Upgrading PMS >= will definitely fix this but we might have to change this in the binding.

I cannot upgrade the PMS, since I am running the Plex DVR beta (on QNAP). Good to know that a fix is there waiting for me for when they release a new DVR version!