Plex updates via web socket

I was hoping that someone can implement the following feature of plexAPI. I know that the package can use a websocket connection (https://github.com/pkkid/python-plexapi/blob/master/plexapi/alert.py)

On the websockets you will receive notifications on player states instantly. I for one have an automation to dim and undim the lights based on plex media player state. Now it takes a while to trigger, so it would be awesome if we have these states pushed instead of polled

Thanks in advance for the one willing to pick this up :slight_smile:

I too would like this, in the meantime I am using tautulli notifications and mqtt to achieve the same thing, triggers pretty much instantly.

Oh thanks! I will look into that as well.

Any update on this? Are we using Webhooks to commuicate with Plex yet? :slight_smile:

Expect this in 0.101. :slight_smile:

Awesome! Do we have to do anything to switch to it? Does this make Plex instant?

Yep, updates should now reflect instantly. Nothing to configure, it triggers all updates by a websocket connection in 0.101.

Hi,

Great work on the plex websockets! Initial impressions of the new connection are that it is very good and pretty much instant for automations, however i have since noticed that the plex integration sometimes breaks for media player when i restart homeassistant. the only error is…

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 399, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: media_player.plex_shield. Platform plex does not generate unique IDs

sometimes on restart the media_player.plex_shield exists and sometimes it doesn’t

For info i have successfully set up two plex servers (one on nvidia shield and another on synology docker) and sometimes the media player shows under one integration, sometimes under the other, and sometimes under neither of them

Cheers
James

Huh. In my testing the same client would report a different unique identifier on different servers. I guess that’s not guaranteed. I’ll have to make a fix in a future release. Thanks for letting me know!

1 Like

@jimbob1001, I just submitted a fix that should (hopefully) make 0.101.2.

looks like that’s fixed it - will keep an eye on it to check how it gets on - thanks!

1 Like