Plex binding for OH3 | Will it be ported?

I use it mainly tied in with Telegram module to send me notifications when a show is started on either devices or roku’s, so I know when the kids are trying to watch something rated R.

Okay, I’ll bite:

  1. Activation of lighting scenes when content state changes to playing/paused (Dim lights / increase ).
    Activation of specific lighting scenes when:
    Movie playing - cinema mode
    Episode - tv series mode

  2. kid bedroom door: pi or tablet showing what content is being played, by using these items:
    Playback/cover
    State
    Playback/endTime

  3. add following buttons to google / Alexa to voice control plex:
    Play
    Stop
    Volume up/down
    Skip forward
    Skip reverse
    Pause

  4. pause plex when light in room above x lumens

  5. (with use of ESPresence) send the stream/cast to new device.
    E.g.: user listening to music in kitchen. Moves to living room. OpenHAB knows user moved to new room. Send command to plex to cast stream url specified living room device.

…. Got nothing else right now.

I use the binding specifically with plex movies and lighting, mostly because I haven’t figured out how to use it with plexamp for music, or for anything else yet.

How it works - all of my AV gear is controlled via RS232 using Global Itach devices, or directly if they have ethernet control ports (not many do). Lighting is Insteon (insteon went out of business but all devices stayed in control via openhab, Insteon the company seems to be trying to revive now)

In openhab I have setup each ITACH as a thing. Things need items - so I created VIRTUAL ITEMS, these are simply strings that hold “keywords” that I made up, such as CINEMAON. Then I have rules that poll for statechange in the item, the rules are blockly and issue the direct RS232 control commands.

I have a string item for PLEX PLAYER STATE - CINEMA and other string items for other rooms like PLEX PLAYER STATE - FAMILY ROOM

A standalone rule can check the state and turn off the lights when the movie starts, on pause or stop it can bring up the lights.




I’ve just installed the binding by dropping the latest jar (0.12) in the addons folder on my dev openHAB instance running 3.4.0,M2. The Bridge Thing would not connect, constantly reporting an error. I discovered that I needed to change the thing to use an IP Address as the server, a DNS entry wouldn’t work even though the name is resolvable from the CLI of the openHAB server and other bindings are working with DNS entries (Remote openHAB binding, MQTT broker, network binding).

Can anyone explain why it won’t work with a DNS entry?
.

The binding still has pending changes so I guess that there are some fixes still required.
It’s too bad that it’s taking so long :frowning:

Hi,

Been using the Plex binding for some time now, like most users I am simply controlling lights when the player starts / stops, so nothing too complicated.

However recently my Openhab would constantly crash overnight and run into memory issues - to cut a long story short: I narrowed down the cause of the issue to the Plex binding which I thought was strange as it has been quite reliable and then I realized that I had made a change to my automations, and I believe that this is what is causing the binding to have a memory leak.

Previously my Plex server used to run 24/7/365, however with the ever rapidly increasing costs of electricity I changed my system so that during the week the server would shutdown at 11pm and only restart again the following day at 5pm (so it’s off when I’m asleep and at work!), at the weekends it still stays on all day/night.

It appears that if the Plex server is not available on the network ‘something’ is happening and the binding is causing a memory leak. Have removed the binding and Openhab has run again for over a week without any issues. Put the binding back and it crashed overnight again, so I am fairly confident that it is the cause’ of the crash.

Has anyone else experienced this behavior / Is anyone else not running their Plex server 24/7?

The plex binding hasn’t been ported to 3.3 yet so I have no clue.
Speaking of which, need to check GitHub about it, wonder where it is stuck now… hum

Status of PR is lots of review comments without any feedback.

Ah. Unngh.

While waiting for the binding I use this : GitHub - lkn94/Plex-Mqtt-Connector: A MQTT connector for webhooks of Plex Media Server written in python for home automation
Simple python script that uses webhook to publish (MQTT) player info, works fine.

1 Like

Loaded questions…

First, I’m using the following rule to notify me what’s being watched (and where… different rules for each “location”).

rule "Send telegram with title for LivingRoom"
when
    Item PlexTVTitle02 changed
then
	if(!PlexTVTitle02.state.toString().isEmpty()){
		val telegramActionPlexBot = getActions("telegram","telegram:telegramBot:PlexPrivBot")
		telegramActionPlexBot.sendTelegram("Living Room TV is watching %s", PlexTVTitle02.state.toString)
	}
end

The question is, can I somehow add the user to that? that way I know which account is watching as well.

And I see OH4 is on the horizon, is someone looking into porting this to that?

Funny you ask that today

1 Like

That’s too funny…. Curious how far apart the postings were…

I took the screenshot moments before I posted, and at that time it had been 5 hours since :slight_smile:

Currently the user is not part of any object, so you can’t use it in scripts. When I am ready getting the binding compatible with 4.0 I can look into this option.

2 Likes

I’ve made some progress in this binding today.

  • Made it compatible and working with OpenHAB 4.0.0
  • Added the users name to the Player Thing so you can use this in the scripts

@aarondvail I am curious what you want to achieve with the user in the script. Can you explain us your use case?

Next step is to process the feedback from @fwolter and update the PR

2 Likes

HYPE

Not directly at me, but I can give some basic examples, if we are talking about knowing which user is playing what…
My plex is mostly used at home and both my wife and I watch together. I have a TV in the living room and a mi box in the bedroom.
Apart from the user profiles, I also created “room profiles”, so my plex home looks like this:
My admin account
My wife home account
Living room TV
Bedroom TV
Hypothetical child account**

We watch 90% of the content on the living room TV account. And that account is only used in the living room - I would create a specific scene for it, dimm lights so on and so forth, additionally, we always have some tea or coffee, so I’d probably add a “start boiling water” after a stream starts there. We always forget, and more often that not we’re pausing the stream 15 minutes after it starts to boil water anyway :confused: it’s a weird think we have, and honestly I wouldn’t change it lol.

But for our personal accounts I wouldn’t set up anything of the sort, since I use it on my everyday devices - smartphones and tablet and frequently in the bedroom mi box, which is where we frequently cycle through our personal accounts for the series that one or the other don’t particularly follow through.

Meanwhile, the hypothetical child account would have a “kill stream” after 21:00 because I’d rather not have my future son watching TV for too long during the night… or at least a message to my telegram smarthome group with the details, so I could have an awareness chat.
This could be done in tautulli as well I believe, but depending on the effort… I’d say it’s a good idea to have it here as well (because o particularly have use cases for it as stated above.)

Does this help?

Happy New Year!

2 Likes

Thnx for the input. I can understand the concept of having logic conditional on the user playing.
As for me I would not misuse a profile to determine the location. For instance the living room tv has a unique player thing, which I would use rather than a profile. But feel free to use it however you want…

1 Like