openHAB2 + Plex

Hi davorf,

thanks for your reply and the code cleaning. I had a look in the console and the output loks like this:

Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * Host => 192-168-0-14.3af68f25ecb44a2d950c2577c8235fd8.plex.direct:32400
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * Accept-Encoding => deflate, gzip
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * Accept => text/plain, */*; q=0.01
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * Referer => https://plex.tv/web/tv/ps4-181
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * Origin => https://plex.tv
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * Accept-Language => en
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * User-Agent => Mozilla/5.0 (PlayStation 4) AppleWebKit/531.3 (KHTML, like Gecko) SCEE/1.0 Nuanti/2.0
Oct 22, 2018 16:31:20.491 [0x7fb71726b700] Erweitert —  * X-Plex-Client-Identifier => myID
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Device => PlayStation 4
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Device-Screen-Resolution => 1280x720
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-No-Cache => 15402186772701179
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Platform => WebMAF
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Platform-Version => 01.81
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Product => Plex for PlayStation 4
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Session-Identifier => 1h10ams1iogox4wb41ogjl5m
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Token => xxxxxxxxxxxxxxxxxxxx
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Version => 3.13.25
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * hasMDE => 1
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * ratingKey => 3022
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * key => /library/metadata/3022
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * state => stopped
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * playQueueItemID => 496
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * time => 4473266
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * duration => 6041046
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-No-Cache => 15402186772701179
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Client-Identifier => myID
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Device-Screen-Resolution => 1280x720
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Version => 3.13.25
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Product => Plex for PlayStation 4
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Platform => WebMAF
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Platform-Version => 01.81
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Device => PlayStation 4
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Token => xxxxxxxxxxxxxxxxxxxx
Oct 22, 2018 16:31:20.492 [0x7fb71726b700] Erweitert —  * X-Plex-Session-Identifier => mySessionID
Oct 22, 2018 16:31:20.493 [0x7fb71726b700] Fehlersuche — Client [mySessionID] reporting timeline state stopped, progress of 4473266/6041046ms for guid=, ratingKey=3022 url=, key=/library/metadata/3022, containerKey=, metadataId=3022
Oct 22, 2018 16:31:20.551 [0x7fb723d11700] Fehler — Error parsing allowedNetworks 'http:/192.168.0.14:8090': Invalid argument
Oct 22, 2018 16:31:20.551 [0x7fb723d11700] Fehler — Error parsing allowedNetworks 'http:/192.168.0.14:32400': Invalid argument
Oct 22, 2018 16:31:20.551 [0x7fb723d11700] Erweitert — Auth: We found auth token (xxxxxxxxxxxxxxxxxxxx), enabling token-based authentication.
Oct 22, 2018 16:31:20.551 [0x7fb723d11700] Fehlersuche — Auth: authenticated user 1 as FluffyCake
Oct 22, 2018 16:31:20.551 [0x7fb723d11700] Erweitert — Auth: Came in with a super-token, authorization succeeded.
Oct 22, 2018 16:31:20.552 [0x7fb71c1a1700] Fehlersuche — Request: [192.168.0.25:59723 (Subnet)] GET /video/:/transcode/universal/stop?session=90lanc633k96tqwe7wdcvgdx (19 live) TLS GZIP Signed-in Token (FluffyCake)
Oct 22, 2018 16:31:20.552 [0x7fb71c1a1700] Erweitert —  * Host => 192-168-0-14.3af68f25ecb44a2d950c2577c8235fd8.plex.direct:32400

I didnt’t see the logInfo(“PlexLight”, “Stopped”) in the Server log. Moreover I get these Error parsing allowedNetworks ‘http:/192.168.0.14:32400’: Invalid argument Exceptions I can’t really classify.

My plex.rules look now like this:

val Functions$Function1 dimLiving = [ int dimlevel | 
		sendCommand(EG_Wohnzimmer, dimlevel)		
]

rule "Plex TV Status changed"
when 
    Item PlexTVStatus changed
then
    if (PlexTVStatus.state == "Paused") {
        logInfo("PlexLight", "Paused")
       dimLiving.apply(80)
    } else if (PlexTVStatus.state == "Stopped") {
        logInfo("PlexLight", "Stopped")
        dimLiving.apply(150)
    } else {
        logInfo("PlexLight", "Playing")
        dimLiving.apply(10)
    } 
end

cheers

Udpate:
Both networks are defined in plex as no auth ip adresse, comma seperated

http://192.168.0.14:8090,http://192.168.0.14:32400

hope this helps

Update:
network problems solved the ip synthax was wrong, it’s:

192.168.0.14

Hey guys this is new
After I changed my router to a fritzbox I have serious problems to get plex binding again.
In PaperUi I add the token of my plex media server running on my nas and get the log message:

[WARN ] [b.binding.plex.internal.PlexConnector] - [192.168.0.16]: Websocket closed

i tried every token from the device list for PS4 or Plex Server changed nothing
Executing ‘PlexTVPlay’ command in OH2 from my android ends in

17:49:59.903 [WARN ] [org.apache.karaf.services.eventadmin ] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/PlexTVPlay] {item=PlexTVPlay, bridgemarker=true, command=ON, timestamp=1541526599883} | {org.osgi.service.event.EventHandler}={port=32400, service.id=327, service.bundleid=203, service.scope=bundle, refresh=5000, component.name=org.openhab.binding.plex.binding, component.id=197, password=:password, token=token, host=192.168.0.16, event.topics=openhab/command/*, username=username, service.pid=org.openhab.plex} | Bundle(org.openhab.binding.plex_1.12.0 [203])]
java.lang.NullPointerException: null
        at org.openhab.binding.plex.internal.PlexConnector.getHost(PlexConnector.java:417) [203:org.openhab.binding.plex:1.12.0]
        at org.openhab.binding.plex.internal.PlexConnector.sendCommand(PlexConnector.java:238) [203:org.openhab.binding.plex:1.12.0]
        at org.openhab.binding.plex.internal.PlexBinding.internalReceiveCommand(PlexBinding.java:147) [203:org.openhab.binding.plex:1.12.0]
        at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:94) [204:org.openhab.core.compat1x:2.3.0]
        at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:45) [204:org.openhab.core.compat1x:2.3.0]
        at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415) [3:org.apache.karaf.services.eventadmin:4.1.5]
        at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:82) [3:org.apache.karaf.services.eventadmin:4.1.5]
        at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104) [3:org.apache.karaf.services.eventadmin:4.1.5]
        at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:166) [3:org.apache.karaf.services.eventadmin:4.1.5]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

Attention: But when I add the client-Id of my PS4 into the plex binding token

17:54:24.718 [INFO ] [b.binding.plex.internal.PlexConnector] - Plex websocket connected to 192.168.0.16:32400

PlexTVPlay command again:

17:55:20.817 [INFO ] [smarthome.event.ItemStateChangedEvent] - PlexTVPlay changed from OFF to ON

But still nothing happens on the ps4 plex app but it’s weird that a clientid used as a token connets the binding succesfully to the websocket and no more errors occurs

here’s the device.xml

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<MediaContainer publicAddress="xx.xx.xxx.5">
<script/>
<Device name="Plex for PlayStation 4" publicAddress="xx.xx.xxx.5" product="Plex for PlayStation 4" productVersion="3.13.25" platform="WebMAF" platformVersion="01.81" device="PlayStation 4" model="" vendor="" provides="" clientIdentifier="clientid" version="3.13.25" id="239676269" token="xxxxxxxxxxxxx" createdAt="1540804504" lastSeenAt="1541524015" screenResolution="1280x720" screenDensity=""> </Device>
<Device name="Chrome" publicAddress="xx.xx.xxx.xxx" product="Plex Web" productVersion="3.73.2" platform="Chrome" platformVersion="70.0" device="Windows" model="" vendor="" provides="client,player,pubsub-player" clientIdentifier="clientid" version="3.73.2" id="240927055" token="xxxxxxxxxxxxx" createdAt="1541509907" lastSeenAt="1541522699" screenResolution="1920x938,1920x1080" screenDensity=""> </Device>
<Device name="admin" publicAddress="xx.xx.xxx.xxx" product="Plex Media Server" productVersion="1.13.8.5395-10d48da0d" platform="Linux" platformVersion="4.2.8 (#1 SMP Sat Oct 13 05:24:45 CST 2018)" device="PC" model="x86_64" vendor="ubuntu" provides="server" clientIdentifier="clientid" version="1.13.8.5395-10d48da0d" id="239681601" token="xxxxxxxxxxxxx" createdAt="1540810004" lastSeenAt="1541505689" screenResolution="" screenDensity="">
<Connection uri="http://192.168.0.16:32400"/>
<Connection uri="http://xx.x.x.1:32400"/>
<Connection uri="http://xx.x.x.1:32400"/>
<Connection uri="http://xx.x.xxx.5:32400"/>
</Device>
<Device name="openHAB" publicAddress="xx.xx.xxx.xxx" product="openHAB" productVersion="1.12.0" platform="Java" platformVersion="1.8.0_191" device="Java(TM) SE Runtime Environment" model="" vendor="" provides="controller" clientIdentifier="clientid" version="1.12.0" id="236277319" token="xxxxxxxxxxxxx" createdAt="1538926331" lastSeenAt="1541356281" screenResolution="" screenDensity=""> </Device>
</Device>
<Device name="Plex for PlayStation 4" publicAddress="xx.xx.xxx.xxx" product="Plex for PlayStation 4" productVersion="3.13.25" platform="WebMAF" platformVersion="01.81" device="PlayStation 4" model="" vendor="" provides="" clientIdentifier="clientid" version="3.13.25" id="239610538" token="xxxxxxxxxxxxx" createdAt="1540762891" lastSeenAt="1540763019" screenResolution="1280x720" screenDensity=""> </Device>
<Device name="Plex for PlayStation 4" publicAddress="xx.xx.xxx.xxx" product="Plex for PlayStation 4" productVersion="3.13.25" platform="WebMAF" platformVersion="01.81" device="PlayStation 4" model="" vendor="" provides="client,player,pubsub-player" clientIdentifier="clientid" version="3.13.25" id="238912957" token="xxxxxxxxxxxxx" createdAt="1540380763" lastSeenAt="1540667944" screenResolution="1280x720" screenDensity=""> </Device>
<Device name="Plex for PlayStation 4" publicAddress="xx.xx.xxx.xxx" product="Plex for PlayStation 4" productVersion="3.13.25" platform="WebMAF" platformVersion="01.81" device="PlayStation 4" model="" vendor="" provides="client,player,pubsub-player" clientIdentifier="clientid" version="3.13.25" id="226788558" token="xxxxxxxxxxxxx" createdAt="1533837279" lastSeenAt="1540380541" screenResolution="1280x720" screenDensity=""> </Device>
<Device name="Plex for PlayStation 4" publicAddress="xx.xx.xxx.xxx" product="Plex for PlayStation 4" productVersion="3.13.13" platform="WebMAF" platformVersion="01.40" device="PlayStation 4" model="" vendor="" provides="client,player,pubsub-player" clientIdentifier="clientid" version="3.13.13" id="219089819" token="xxxxxxxxxxxxx" createdAt="1529428302" lastSeenAt="1533810093" screenResolution="1280x720" screenDensity=""> </Device>
</MediaContainer>

This drives my nuts, any ideas?