I got this working. The track information for the music played on my plex server will show up on the "current states" on the hubitat device page. It works for my iphone, chrome browser, my fire TV, etc. However, the only thing that doesn't appear to be showing is the states for the "Plex for Alexa" client. Sometimes, I'll play my plex music library through an echo device (I have to say "tell plex to shuffle playlist 90's rock"). On my server dashboard, it does show the music playing under the device "Plex for Alexa" however I'm not seeing the track information in the hubitat device page. Any thoughts?
Hey, the device you have added is some form of generic Alexa device, likely to link the account, the device itself doesn't show in the "Devices" API list of plex, so in order to finds it you need to check a now playing API, it's just a terrible API by plex.
However my code was only looking for video players not music, I've bodged together an updated version on the github page that will now find them.. start your device playing then search for devices, your device should have a play icon next to it..
If I find time in the future I'll put a more elegant solution in place.
Would you know if this will work if the Plex server is run in the cloud?
Works perfect! Thanks!
I thought I'd share what this app helped me with, in case it helps anyone in the future. I have a pretty exhaustive plex music library (custom songs, ambient music to use for sleep for the kids, etc.) that cannot be found on Amazon Music, Apple Music, Tidal, etc. Alexa was always able to play my plex music library over echo devices/speakers but it was terribly unstable. I'd ask Alexa to play a playlist and it would stop after 3-4 songs. Now that I can get the current states of the "Plex for Alexa" device, I can make a rule to re-start the playlist in the event it stops (If status = stopped, tell plex to shuffle playlist sleep playlist). My kids love their piano/ambient, calm music at night and it would often stop in the middle of the night. Now, my rule can re-start the playlist based on the status and play continuously. Thanks!
In theory it would work as long as you have the web hook option in Plex, however not exactly how it’s setup right now.
There are two issues, getting devices requires local access, this can be easily fixed as long as there is a solution to the second issue.
The second issue is that the web hook needs to send the data to your Hubitat, for this you can’t port forward as you’d give access to everything, so I need to check to see if the maker API can do this, which I think it can, it’ll take some time to investigate.
Thanks for the reply. My Plex server is running on a linux instance on Oracle clouds infrastructure. I’d be happy to test.
You will need webhooks that I believe is only available if you have plex pass, if you do give it a go, I've just uploaded a new version:
Select "I'm using the cloud on the front page", enter your login details.
Grab the Cloud webhooks URL and add that to Plex.
Under "Select your devices" enable the "Find devices that generate events for 15 minutes"
Start playing on any devices you want to discover and they should appear in the list (selecting and unselecting the list should be sufficient to refresh.)
Hopefully add the found devices
Profit
Well everything installed and Plex is being seen by Hubitat. Now I just need to figure out my lighting automations in RM. Thanks for adding this so quickly!
No worries, it’s untested so any issues let me know, it runs slightly limited as it can only receive info via the web hook, so the option to pull extra data won’t work, but you should get all the standard updates
Hi, Does this app work with Apple Tv?
Yes
Okay. I must be missing something, as when I add my Apple Tv in the Plex Communicator app, it doesn't show as a device to use in my HE devices menu.
Other devices, like my Chromecast (CCwGTV) and Iphone show up as devices and show the current states, so I would assume my webhook is working correctly.
Looking at the log, I'm getting:
Error creating device: java.lang.NullPointerException: Cannot get property 'name' on null object
Are you using the very latest version from GitHub?
If you are can you send me your plexClients list, can be found by opening the app and clicking the cog on the top right
I've just pushed another update, this may or may not help you..
3.4 - Updated default player name to "Unknown" rather than empty for XML
I'm currently on 3.3. I will message you the client list.
Yes. Just found out about this Plex Communicator and working my way through this thread. I was getting the unauthorized access as well until I disabled my 2FA. Being in the Security Field, I strongly recommend enabling Multi Factor Auth where ever you can. And while I am still working my way through this thread, I would love to have MFA (AKA 2FA) enabled on my Plex account.
Did you try disabling and re-enabling after?
Otherwise according to the Plex docs you can just append your auth token to the end of your password and it should work
Oh... No I haven't. I just figured it would break like most other authentications do when you enable 2FA. I'll give it a try.
And by appending the token, you are referring to the 2FA token and not the Plex API token, correct?
Hey! Me again. I updated my Hubitat and mediascene started not working again so I decided it was time to move over to Rule Machine. I have the rules set for play, pause and stop but cant figure out how to set the conditions for media type. This is probably super obvious but any pointer on where to get to media type?