Problems with Plex tokens in an Unraid environment

I need some help configuring Plex. What I’ve done…

  1. got Token using Curl…
    curl -X “POST” “https://plex.tv/users/sign_in.json
    -H “X-Plex-Version: 1.0.0”
    -H “X-Plex-Product: Home-Assistant”
    -H “X-Plex-Client-Identifier: Home-Assistant”
    -H “Content-Type: application/x-www-form-urlencoded; charset=utf-8”
    –data-urlencode “user[password]=mypwd”
    –data-urlencode “user[login]=myuserID”
  2. Enabled GDM (plex server is discovered)
  3. Whitelisted HA IP in Plex

When I go to Plex > Config > devices I see a new device “Home-Assistant” good! But every time I enter the plex token in the HA UI, I get “Failed to register, please try again.”

I’ve tried manually creating plex.conf. No dice!

Please help. Ultimate goal it to manage Lights when Play / Pause within Plex. Thanks

I’ve never seen this method of getting a Plex token; I’ve always used this:

and my Plex server has always worked fine with the token I got from using that method.

I saw that and tried it as well. A topic I’m confused about is this. I do not use the free Plex. I use PlexPass. So my question is this, when you used that method, are you signing into plex.tv or are you going directly to your local server 192.168.1.xxx:32400.

However in the “Tip” section of that Plex topic, I followed that method described here. Is this correct? or am I over thinking this?

A follow up question, is there a way to test the token outside of HA. It would be nice to know my Token is valid.

thanks

I use PlexPass (lifetime member). You should be getting the token provided by your server using the method I linked.

You are logging into Plex.TV, but anything you actually do after that is coming via an interaction with your server.

Ignore that and use the method in the link. I think that is for another thing entirely.

Not sure about testing your token beyond using it in HA.

OK. thx. so here’s what I have done…

  1. logon to Plex.tv
  2. selected a video
  3. selected the “…” button
  4. clicked “view XML” link in orange
  5. Open HA select the plex server that was discovered, click configure
  6. Paste my token from step 4.
  7. error

What I’ve hidden behind the red line is my token, correct?

Yep! You got it. Now that should work but if it doesn’t we’ll keep going.

Whitelisting the HA IP is a step that a lot of folks don’t do, but I do and I think it was a smart move.

OK, well not working. About white-listing… I guess sometimes I can be a bit anal with verbiage. for example if I have the right field in Plex > config > network it says…
“List of IP addresses and networks that are allowed without auth.
Comma separated list of IP addresses or IP/netmask entries for networks that are allowed to access Plex Media Server without logging in. When the server is signed out and this value is set, only localhost and addresses on this list will be allowed.”

I homed in on “allowed without auth” Are we really trying to allow HA to access Plex without Auth? Just making sure I’m doing it right.

Background topology…

  • Unraid server
  • Plex as plugin. So running as same IP as unraid, just unique port 32400
  • HA as a VM running on unraid.
  • HA OS us ubuntu server. manual install.
    NOTE: I am not able to stop/start any services from the HA UI. I have to do it from SSH as…
    “systemctl restart [email protected]

So I noticed that if the host name or protocol changes that I access Plex with I get a different token. for example a different token when host in chrome is…

Now I found a reference on reddit that said…
“Yes, each client/app should have it’s own token. A tiny bit of a security thing and it makes it easier to revoke certain clients/apps without revoking everything. Each token is associated with a unique ID for the client/app.”

So I guess the question is how do I generate/get a token that is for HA.

If I’m rambling just tell me to stop.

next idea?

thanks for the help.

That’s what I was referring to - exactly. And it’s okay to let HA go without auth, it’s not going to hurt anything and should help.

You’re not rambling; you are giving very useful info. I don’t have any Unraid experience beyond reading up about it a few times so I’m not sure if I can help you with this but I think you are onto something with the host name.

I’m hoping someone with some Unraid or VM experience can pitch in.

I’d like to suggest editing the title to attract the right resources:

“Problems with Plex tokens in an Unraid environment”

thx. I have a shield console. let me turn on the Plex server and see if that works.

Ok I am thoroughly confused. So I turned on the Shield and enabled the server and registered it with my plexpass account. Went back to my laptop, opened Chrome typed in https://plex.tv. Signed in, and selected Launch in the top right.

Now I’m in the plex web app. In the left column, drop down the servers menu and there is my Shield server. Configure the videos library. it scans the library, I see a couple videos. yeah.

No I do the sameas before, select a video, select the … menu and select Get info, then select, View XML. Now here’s the kicker… The token is exactly the same as before when viewing the XML from a video served by Plex on the unraid server.

So I think this is my Plex Pass token and not a token to access my local server. Is there a difference?

I think I need to start looking deeper into what HA needs and or is doing. Here’s why…
IP.102 = main plex server on unraid
IP:212 = Plex server on shield

http://192.168.1.102:32400/library/metadata/5?X-Plex-Token=tokenA
http://192.168.1.212:32400/library/metadata/5?X-Plex-Token=tokenA

The exact same token on both servers wrok, why. The only logic is plex cloud service is authenticating me. how and where can I did deeper into HA to troubleshoot. How do I enable debug logging?

thanks

I think I’m getting somewhere. Hoping someone can help. I enabled debug logging and tail the log file grep “media_player” and got this…

jtroberts@TRW-HASS:~/.homeassistant$ tail -f ./home-assistant.log | grep “media_player”
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/media_player/plex.py”, line 69, in config_from_file
2017-08-01 13:38:47 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform plex
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/media_player/plex.py”, line 81, in setup_platform
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/media_player/plex.py”, line 69, in config_from_file
2017-08-01 13:38:47 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform plex
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/media_player/plex.py”, line 81, in setup_platform
File “/usr/local/lib/python3.5/dist-packages/homeassistant/components/media_player/plex.py”, line 69, in config_from_file

anyone have an idea of where to start?

I don’t run PMS anymore because my media collection is so large that the metadata fills the Shield internal memory. I moved to Kodi on the Shield and just keep the PMS on the PC around for HA and test/support.

So I can’t check, but I am pretty sure that when I added my PMS on the Shield, I had to put in a different token.

I think we’ll need to see the full log where those errors occur for anyone to be able to see what’s going on though.

Well I wish I could tell everyone why but I can’t. I do have a good guess though. I decided to bite the bullet and buy a RPI3 and install HassIO. From there HA came up, discovered the Plex server. I used the simple method of viewing the XML. So I entered my token in the HA UI, SSL=false, verify=false.

Plex settings

  • secure Connections = preferred
  • list of IP allowed without auth = HA IP

So here’s my question? what should I see? I see several Plex clients, but not the server?

I was expecting to see a device “media_player.plex”

any advise? Thanks

Try playing something from the Plex server and while it’s playing, restart and see if you see the media player in the dev states panel.

A lot of my confusion is simply I don’t know what I should see. Should I see the status of the actual Plex server? or should I see the status of a plex client. Everyone everywhere simply says “plex” in the forums and documentation. If you could help clarify that would be great.

Here;s what I see after doing what you mentioned…

media_player.denon_avrx7200w off
media_player.paviliontheater off
media_player.plex_plex_player_shield idle
media_player.shield

In order…

  • Denon Receiver
  • Chrome Cast device
  • Plex client on Nvidia Shield. NOTE: NOT idle. I cast’d music to this device and in the card for this device on the home screen in HA shows the music I am playing. wierd!
  • ChromeCast embedded into the Nvidia Shield

Should I see the actual Plex server status. NOTE: Plex Server and not the client.

There are two components for Plex; one is a sensor, that shows info about the users connected to the server and what they are playing:

The other is a media player that shows detail info about what is being player and allows control of that media (play/pause, volume, etc.)

For the Shield, you should see at least TWO media player instances; one is the ChromeCast (in your case that should be media_player_shield) and the other is the Plex CLIENT (which I think is your media_player.plex_plex_player_shield. If you have enabled the PMS in the Shield (Plex Media Server) you should see a third media player.

Do you have PMS setup in your Shield? Have you updated it, started it and then pointed it at a media library? Is it actually running on the Shield (check because it’s notorious for closing without notice on the Shield)?

If you include include_non_clients: true you should also see a media player named media_player.plex_web_chrome if you sign into plex.tv and open a media file with the web player.

None of these show the actual server status (like version or uptime details), only what’s playing and only when something is actually playing.

You can also retrieve the X-Token this way too

2 Likes