openHAB2 + Plex

so this is my rule so far… but it doesnt seem to be working… not sure if i have the command on the condition right…

{
  "triggers": [
    {
      "id": "trigger_1",
      "label": "Item State Change Trigger",
      "description": "This triggers a rule if an items state changed",
      "configuration": {
        "itemName": "PlexTVStatus"
      },
      "type": "ItemStateChangeTrigger"
    }
  ],
  "conditions": [
    {
      "inputs": {},
      "id": "condition_2",
      "label": "Item state condition",
      "description": "compares the items current state with the given",
      "configuration": {
        "itemName": "PlexTVStatus",
        "state": "stopped",
        "operator": "="
      },
      "type": "ItemStateCondition"
    }
  ],
  "actions": [
    {
      "inputs": {},
      "id": "action_3",
      "label": "Post command to an item",
      "description": "posts commands on items",
      "configuration": {
        "itemName": "lifx_whitelight_D073D5100CD1_brightness",
        "command": "59"
      },
      "type": "ItemPostCommandAction"
    }
  ],
  "configuration": {},
  "configDescriptions": [],
  "uid": "rule_6",
  "name": "Plex Test",
  "tags": [],
  "visibility": "VISIBLE",
  "status": {
    "status": "IDLE",
    "statusDetail": "NONE"
  },
  "enabled": true
}

I haven’t ventured into the new rule system so i cant help you there but id make sure you are seeing the item update it state in the log files

New to openhab2 where are the logs stored?

…\userdata\logs
or
try log:tail in cli

1 Like

hmm doesnt look like its seeing when the client changes state… here is my item… incase im missing something.

String PlexTVStatus “Status [%s]” {plex=“ryz7F9ayxwBZK7dHEWRre675g#state”}

It should show in the log when the state is changed should it not? because im not seeing the state change.

So i finally figured out my problem… I had to go into the advanced settings of plex list the ip of the openhab server so that it doesnt require authentication.

1 Like

hi antasp3136, I’m stuck where you were, not getting the status updates in the log. Can you clarify exactly where you added the IP of the OH2 server in the Plex settings? Many thanks.

Go into the server settings of Plex and choose to show advanced and then choose network. Add the ip of your openhab server to Plex.

Many thanks for that. I’m now getting a lot of java errors in the log:

[WARN ] [org.apache.karaf.services.eventadmin] - EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=openhab/command/PlexTVPlay] | {org.osgi.service.event.EventHandler}={component.name=org.openhab.binding.plex.binding,

Have you come across this?

Hmm cant say that i have. This is what my config file looks like for plex:

# IP address of the Plex server
host=10.0.0.4

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

# Refresh interval in ms. Default = 5000
refresh=5000

And my items look like this.

String PlexTVStatus			"Status [%s]"	<video>		{plex="PlayerID#state"}
String PlexTVType       "Type [%s]"     <video>     {plex="PlayerID#type"}

And here are my rules for the lights:

import org.eclipse.xtext.xbase.lib.*

rule "Lights on when Stopped"
when
    Item PlexTVStatus changed to Stopped
then 
        sendCommand(zwave_device_9e525cd7_node2_switch_dimmer, 100)
        sendCommand(zwave_device_9e525cd7_node3_switch_dimmer, 100)
end

rule "Lights on when Paused"
when
    Item PlexTVStatus changed to Paused
then 
        sendCommand(zwave_device_9e525cd7_node2_switch_dimmer, 10)
        sendCommand(zwave_device_9e525cd7_node3_switch_dimmer, 10)
end

rule "Lights dimmed when playing"
when
    Item PlexTVStatus changed to Playing  
then
        sendCommand(zwave_device_9e525cd7_node2_switch_dimmer, 0)
        sendCommand(zwave_device_9e525cd7_node3_switch_dimmer, 0)
end

Many thanks again. I think its something to do with my configuration. I’ll double check everything. Very useful having your configs. Much appreciated.
Sham

1 Like

I found my problem! I was trying to use the org.openhab.binding.plex-1.9.0-SNAPSHOT.jar but when I reverted back to org.openhab.binding.plex-1.8.2 everything started working fine! Doh.

Many thanks for all your help.

1 Like

No problem I just started with openhab and am still learning as well. So far I have all my lights working, got Plex integrated. Even have alexa and home kit working. I know I can do so much more too!

I have just got Alexa working too. I must say, i think it’s great as an interface to openhab. Now it would be really fantastic if we could control plex via alexa! I’m sure it could be done.

1 Like

Apparently a official plex skill is in the works for alexa… https://forums.plex.tv/discussion/173499/amazon-echo-and-plex-alexa-tell-the-home-theater-to-put-on-a-good-episode-of-always-sunny

that looks amazing. Hope he releases it soon!

hi i have problem adding the plex binding.

I put the org.openhab.binding.plex-1.8.3.jar into this folder /usr/share/openhab2/addons/

then i put a plex.cfg into /etc/openhab2/services

# IP address of the Plex server
host=---.---.--.--

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

# Refresh interval in ms. Default = 5000
refresh=5000

than i enabled in the paper.ui “Include Legacy 1.x Bindings” and restartet my server.
Now i have the following error in my logfile:

[WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.plex-1.8.3.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.plex [193]
  Unresolved requirement: Import-Package: org.codehaus.jackson

	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[8:org.apache.felix.fileinstall:3.5.0]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[8:org.apache.felix.fileinstall:3.5.0]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1207)[8:org.apache.felix.fileinstall:3.5.0]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:504)[8:org.apache.felix.fileinstall:3.5.0]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[8:org.apache.felix.fileinstall:3.5.0]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[8:org.apache.felix.fileinstall:3.5.0]

PS: I solved it by my self. You have to enable it with karaf by using “feature:install openhab-runtime-compat1x”

1 Like

Has anyone else had an issue with the latest version of plex not working?.. getting this error…

09:32:03.210 [ERROR] [.binding.plex.internal.PlexConnector] - Error handling player state change message
java.lang.NullPointerException
at org.openhab.binding.plex.internal.PlexConnector$PlexWebSocketListener.onMessage(PlexConnector.java:494)[213:org.openhab.binding.plex:1.8.3]
at com.ning.http.client.providers.netty.NettyWebSocket.onTextFragment(NettyWebSocket.java:202)[213:org.openhab.binding.plex:1.8.3]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider$WebSocketProtocol.handle(NettyAsyncHttpProvider.java:2380)[213:org.openhab.binding.plex:1.8.3]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.messageReceived(NettyAsyncHttpProvider.java:1220)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)[213:org.openhab.binding.plex:1.8.3]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)[213:org.openhab.binding.plex:1.8.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_111]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_111]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_111]

Yep, the last version of Plex Media Server doesn’t work anymore with the binding.
Not sur about when the modifications have been made, PMS 1.1.4 works but not PMS 1.3.0.

The websocket notification message have been modified.

You can look at this post to see my search about the changes :

but unfortunatly my dev skill isn’t enought strong to update the binding myself so I hope someone will take care of it :slight_smile:

Yes, I’m getting this error too after updating to the latest PMS (1.3.2.3112). I’ll look into it.