openHAB2 + Plex

look for input on how to integrate Plex into OpenHAB2

Can you give some details about what you want to include in openHAB?
There certainly are some APIs available, a random module for that:


https://pypi.python.org/pypi/PlexAPI

One would need to couple openHAB to one of these…

i found this but i cant seem to get it to work as in openhab1

There was a binding after all. I didn’t recall.
But still, you need to give more details. How do you expect me or others to help you if you do not give any kind of information…?

Did you get the binding installed? Is it listed in PaperUI or in Karaf console as installed and active?

Did you fill the service configuration? You’ll need to create the file <openhab-config>/services/plex.cfg with the content as shown but without “plex:”. Example:

# IP address of the Plex server
host=192.168.1.15

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

# Refresh interval in ms. Default = 5000. 
refresh=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. 
#username=Plex username

# Plex password
#password=Plex password

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

After that you can define items just as described in the wiki.

What does your log say?

thanks for the help! i got it had the jar file in the wrong location

Where do you place the jar file for openhab2?.. what all needs to be configured I’ve been trying to drop that jar file in the addons folder but it doesn’t look like it works.

i created a file called plex.cfg and put it into the services folder and added the config i had for openhab1

you are correct the jar need to be in the addons folders

1 Like

Are you then able to see the Plex binding in the paperui to setup a rule to turn lights on and off?. I’ve added the jar file to the addons folder and also created a plex.cfg file but I can’t see Plex in the ui so I’m not sure what the next step to take is. Also does this need to be named plex.config instead?

Just follow the Plex Wiki . Once the items are created they will show in the ui as an item not a thing

you are correct with plex.cfg

Ok so I got it to show up as an item… I’m using the token instead of a username and password. But it doesn’t seem to run my rule. Any insite or example of how yours is setup. I have a Plex home setup where I have multiple family members that access the Plex server. I’d like to only have a single client run a rule but I’m not sure if this is possible or not.

I need to redo my rules for plex as they are pretty crude

Item
String FF_MasterBedroom_Samsung_Plex_Status “Status [%s]” (gpMasterBedroom) {plex=“u7ca3m6bdbhf6#state”}

rule "Lights on when paused or stopped"
when
Item FF_MasterBedroom_Samsung_Plex_Status changed to Paused or
Item FF_MasterBedroom_Samsung_Plex_Status changed to Stopped
then
logInfo(“PlexLight”, “Play to pause”)
sendCommand(FF_MasterBedroom_Nightstand_Light, ON)
end

rule "Lights dimmed when playing"
when
Item FF_MasterBedroom_Samsung_Plex_Status changed to Playing
then
logInfo(“PlexLight”, “Pause to play”)
sendCommand(FF_MasterBedroom_Nightstand_Light, OFF)
end

1 Like

Ahh so your Plex item is the client?.. how did you find out what the client name would be for this… I’m using a PC with Plex Media player as my client.

My plex server is my openhab server, my smart tv are the clients

you might find a list of your clients id

http://127.0.0.1:32400/web/index.html#!/status/playing
or
https://plex.tv/devices.xml

Actually I think I’m starting to get my head wrapped around how to do this after seeing your example. The wiki was a little confusing because of how generic it was.

Hey @antasp3136 that’s nice to hear. Feel free to improve the wiki article! Help - as little as it may be - is always welcome!

1 Like

I was looking at the items example in the wiki and didn’t put two and two together to realize the playerid# was the Plex client. Lol :blush:

Ok so for example…
Switch PlexTVPower “Power” {plex=“playerid#power”}

The playerid is my plex client correct?.. is this the client identifier?.. or device name?.. not sure what to put…
also for {plex=“playerid#power”} Am i just replacing the playerid with that name or is it playerid# im replacing?.. just not sure… maybe i need anther example of a item list so i can understand what to put.

I do not own a Plex installation but the wiki article states:

{plex="<client-id>#<property>"}

A Plex server can have multiple clients. You’ll have to find the client ID of your Plex client yourself. This can be found by signing into plex.tv and then visiting https://plex.tv/devices.xml. It’s listed as Device -> clientIdentifier here.

So without knowing what a typical playerid may look like, I would expect a result similar to this: {plex="player12345678#power"}

1 Like

ok so if im looking at the xml which one would be the actual client id…

I believe clientIdentifier