Start Plex video

Dear All,

I may the helicopter here, but I can’t start any of my Plex videos on any media platform. :frowning: Please help, what do I do wrong.

So infrastucture:

  • Plex Media server on my local network 192.168.1.101:32400, reachable, castable, DNLA on.
  • LG webOS tc, with DNLA possibility, Plex app installed, reach local network
  • Chromecast Ultra on the local network

I can start the videos on any of the said infrastucture elements (DLNA, Plex App, Cast), but not with Home Assistant :frowning:

My HA config:

  • Plex Media Server integration configured and working, I can see if anyone start a video.
  • Cast config working… at least I can see if somebody start a video on that.
  • DLNA not showing up in the integrations, so it’s not configured
  • Home Assistant Media browser is empty.

I tried the following automation:

alias: Play Plex
description: ''
trigger:
  - platform: tag
    tag_id: 2c502546-eb2d-4f96-9cbf-c8cd41d61d61
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_type: video
      media_content_id: '"{"library_name": "Movies", "title": "Soul"}"'
    target:
      entity_id:
        - media_player.lg_tv
        - media_player.chromecast8176
mode: single

Nothing at all. I tried direct call with other content_id-s but none of them work.

Please-please help me, what I’m doing wrong? Best would be DLNA, but right now I even don’t care if I stream the movie all across the globe to get back to my TV :smiley:

Thank you for your help!
Best: Peter

1 Like

If you still want to use automation / script, check out documentation.

In your example:

media_content_type needs to be movie
media_content_id has incorrect format, you need to prefix it with plex://

Also make sure that:

  • You add only one entity, for start to minimize debugging scope
  • Your entity is chromecast device

Example:

'cast_plex_to_chromecast':
  alias: "Cast Plex to Chromecast"
  sequence:
  - service: media_player.play_media
    target:
      entity_id: media_player.chromecast
    data:
      media_content_type: movie
      media_content_id: 'plex://{"library_name": "Movies", "title": "Groundhog Day"}'

Plex Media Server - Home Assistant seems to have incorrect examples without the plex:// protocol :thinking:

2 Likes

Thanks, I’ll review into that. Also, I need it in automation (a child will get RFID cards to set their videos), so main function I’ll search for that it should able to start the video :slight_smile:

Thanks anyway, its a very good feature for the non-child members of the family :slight_smile:

Hi JurajNyiri!
I’ve tried the plex protocol. Some documentation mentioned video, some movie, but none of them worked. Anyway, let’s try it to debug:

So new code:

alias: Play Plex
description: ''
trigger:
  - platform: tag
    tag_id: 2c502546-eb2d-4f96-9cbf-c8cd41d61d61
condition: []
action:
  - service: media_player.play_media
    data:
      media_content_type: movie
      media_content_id: 'plex://{"library_name": "Movies", "title": "Soul"}'
    target:
      entity_id:
        - media_player.chromecast8176
mode: single

Result: nothing, even Cast not called. In the trace I found:

Call service media_player.play_media on entities media_player.chromecast8176
Stopped because an error was encountered at 14 October 2021, 16:12:53 (runtime: 0.20 seconds)
Plex media not found using payload: ‘{“library_name”: “Filmek”, “title”: “Soul”}’

Thank you!

Best: Peter

Looks like it didn’t find the title “Soul” in “Filmek” library in Plex.

1.) I would recommend double checking all the names and titles (also look for spaces at the end! Your library might actually be "Filmek " by accident) but you have probably already done that.

2.) As a next step, make sure that plex integration is using the expected Plex server which includes that library and that movie.

Finally, as the last debugging step for syntax (and/or names) I would recommend to setup the plex card that was recommended by @reotto above. Its super easy and fast to setup via UI and will narrow down the issue further if still not known at this point. If it launches the movie correctly, your syntax is wrong. If it fails to launch the movie, something else is wrong.
Edit: Card has a failover mode, when when it fails to launch the movie through plex, it casts the physical file instead. You can differentiate which method it used by how the cast looks. If there is plex logo, metadata (like title, picture) etc it used plex cast. Please note this down if it did indeed launch the movie, that will narrow down the debugging a lot.

Hello,

Thanks for helping further :slight_smile:
Yeah, I double checked the library, also I copied even the UID of the film :slight_smile: It seems as if the integration is broken, but also it’s working in other parts of HomeAssistant

I’ll try @reotto solution as soon as possible and come back with the results. :slight_smile: Thank you!

I posted the solution above, but here is my use case for reference for everyone.

I setup a panel/view in HA for every bedroom in my house. The only real difference in each panel is it is set to that specific bedroom and the TV in that bedroom. I use the visible function, and only allow them to see in HA the view for that room which corresponds to the TV in that bedroom.

I have a tablet setup in each bedroom. They can walk up to the tablet and see all the movie art on that view, and when they click play on one of them it will turn on the TV and start playing that movie. I have grand kids, and they absolutely love it. Make it super simple for them to watch their movies-my wife doesn’t have to figure out the remote, navigate to Plex, find the movie, and then play it. They choose and it plays.

2 Likes

Hello!

So I’ve set up the plex-meets-homeassistant component, and it absolutely worked fine. I’ve selected a cast device as the destination, and it read all the videos from the library, and started the video.

now, just one question: how to automatize it :smiley: due it still doesn’t workm but it seems the plex integration is fine.
Best: Peter

Did it have all the metadata like picture, name, plex logo etc when it casted? Or did it just look like a usual video cast without any metadata? To be 100% sure, you can disable plex integration, restart hass and then cast through card, see if it looks different or same (this will force it to failover to video cast instead of plex cast).

See my comment above, without this info we do not know where is the error.

Hello there :slight_smile:

So all metadata (picture, name, logo, descirption) were all there.
I’ve disabled Plex integration and rebooted the whole host (once a mont :smiley: ) ), all of the data stays there. Isn’t this addon gets another channel to Plex instead of the built in integration?
It also started the movie but I didn’t saw it in the Plex integration of Chromecast.

Best: Peter

If played file had all the metadata like picture plex logo etc, it looks like your syntax in automation is wrong. It will probably be something with the name, title etc.

It uses the same service call as you are trying to use.

  1. Go to /www/community/PlexMeetsHomeAssistant
  2. Delete .gz and .map files
  3. Open .js file
  4. Look for this.playViaCastPlex = (entityName, contentType, mediaLink) => {
  5. Replace
       this.playViaCastPlex = (entityName, contentType, mediaLink) => {
            return this.hass.callService('media_player', 'play_media', {
                // eslint-disable-next-line @typescript-eslint/camelcase
                entity_id: entityName,
                // eslint-disable-next-line @typescript-eslint/camelcase
                media_content_type: contentType,
                // eslint-disable-next-line @typescript-eslint/camelcase
                media_content_id: mediaLink
            });
        };

with:

        this.playViaCastPlex = (entityName, contentType, mediaLink) => {
              console.log({
                // eslint-disable-next-line @typescript-eslint/camelcase
                entity_id: entityName,
                // eslint-disable-next-line @typescript-eslint/camelcase
                media_content_type: contentType,
                // eslint-disable-next-line @typescript-eslint/camelcase
                media_content_id: mediaLink
            })
            return this.hass.callService('media_player', 'play_media', {
                // eslint-disable-next-line @typescript-eslint/camelcase
                entity_id: entityName,
                // eslint-disable-next-line @typescript-eslint/camelcase
                media_content_type: contentType,
                // eslint-disable-next-line @typescript-eslint/camelcase
                media_content_id: mediaLink
            });
        };
  1. Upload this file back to home assistant (if not edited directly there)
  2. Delete browser cache
  3. Open home assistant page
  4. Right click, Inspect (or developer tools etc, depends on browser)
  5. Go to console
  6. Go to the card, play some movie
  7. You will see an object in console.log, this object contains parameters for your automation that will work, you will know it when you see it
  8. Copy&paste stuff to your automation and it will work

If you do not see console.log:

  1. Make sure you have cleared cache
  2. Use incognito mode
  3. Use another browser
  4. If you see error instead that is coming from the card, it is not using plex integration and casting the file directly, make sure to configure your plex integration properly, restart, reload browser and try again from 7 above.
1 Like

OMG, this will take me time to do, but THANK YOU VERY MUCH! :slight_smile:

Hello @JurajNyiri ,

So now have some time to do this :slight_smile:
I tried to do what you wrote, but step4 caused me some problem due may your code changed :slight_smile: But do the relevant changes and changed some parameter, so I got on the console what I needed, so thaaaank youuu!!!
It seems the translation of library is needed and I changed it wrong. My library was wrong with this.

So: with your help I got the exact media content ID I needed. THANK YOU FOR THAT!!!