❱ Plex Assistant

I seem have a fairly sizeable delay between when I request anything and when it actually starts playing. Anyone else have this issue?

  • Local or remote Plex server?
  • DialogFlow or IFTTT?
  • All cast devices or just certain ones?
  • Do you use a start script for the device in question?
  • What kind of hardware is HA running on?

There are a handful of things that can affect the speed from command to action. IFTTT/DialogFlow latency, remote servers will always be slower to respond, start script will wait for the device to report as ready before continuing, lag connecting to your HA instance, very large libraries can slow things down, and Plex Assistant will also rescan libraries if a new item has been added between your last command and current one and that can take a bit.

Issuing a Plex Assistant command on my system (local Plex Server, IFTTT, largish library) to a chromecast device takes around 2-4 seconds and occasionally 1-2 seconds longer for my Roku. Generally It’s always on the lower end of that scale and I never feel like I’m waiting.

Try issuing the command with the plex_assistant.command service in "Developer Tools" > "Services" to see if you still experience the delay.

-Local Plex server (well local in the sense that its on the same router although plex is running on windows and HA is running on a virtual linux machine on the same computer)
-IFTTT
-Seems to be all devices
-I do not have a start script, should I?
-HA is running on virtualbox in a linux instance.

I do have an extremely large library (probably something like 500tb, do you figure that would be the major bottleneck?
Sorry I’m very new to HA, what exact command would I give in the developer tools?

That large of a library could slow things down as searching for items will take a bit longer. Plex Assistant does multiple “searches” in order to figure out what exactly you’re asking for and if what you said is a media item or a cast device etc. as well as to find out which library holds the best match for your item.

If you go to your sidebar in HA and select “Developer Tools”, then select “Services” at the top. You can then start typing “plex” into the service box, select `plex_assistant.command", then at the bottom of the page hit “Fill Example Data” and modify what it fills in to fit a command that you would say and hit “Call Service”.

There are a few things I’ve been meaning to optimize that I’ll be adding in the next few versions as well and they will most likely help with large libraries like yours.

Hey @mayker, maybe a little help please - i’m struggling with the dialogflow integration. It works fine locally with the plex_assistant.command service, works alright from the dialogflow test console. Yet if I try to invoke it on any google assistant device via “hey google, tell Plex to {}” - I get “Sorry, I don’t know how to help with that”. Both my DF agent and the intent are called “Plex”.

Thanks for any pointers you might have!

P.S. Even though it is not in the revised 1.0 version documentation I had to add this to HA config in order to get it working:

Plex:
    speech:
      text: "Coming up"
    action:
      service: plex_assistant.command
      data_template:
        command: "{{ command }}"

Nobody has any pointers? :frowning:

@mayker, are you 100% sure that the google assistant integration is NOT needed to enable dialog flow on smart home devices? according to other turorials , to make use of dialogflow, the google assistant integrations needs to ne enabled on here :

EDIT : i enabled google assistant integration, enabled account linking , gave it a name, and then i was able to say “ask plex to” or “talk with plex” , now it works

ok, next issue, when i speak a command, i see this on my tv screen , no error in log, what could be the cause of that? i know i tested this “plex assistant” before in the beginning, and then it worked

Hi,

I am having difficulties to make startup script work.
It is stated as,
“Livingroom TV”:”script.start_googletv_plex"
and the script itself can successfully turn on the TV, and turn on
Chromecast with Google TV, and also launch the plex app on it.
At the time when I “tell plex to play … on the Livingroom TV”,
the state for TV and CGTV is “off”,
and plex app is “unavailable”, and I don’t see any of those turning on via
plex assistant.

“Livingroom TV” is a friendly name for,
media_player.plex_plex_for_android_tv_chromecast, and this
plex client is selected as default at the time of Plex Assistant setup at the beginning.

Next, I manually run the above script.start_googletv_plex to turn on everything,
and make a plex assistant command after it, it still doesn’t work.

What is weird is that, after running a script,

  alias: 'Plex: Play TV Playlist'
  mode: single
  sequence:
  - data:
      media_content_id: '{ "playlist_name" : "adfg", "shuffle": "1" }'
      media_content_type: playlist
    entity_id: media_player.plex_plex_for_android_tv_chromecast 
    service: media_player.play_media

to play a playlist on plex, and make a plex assistant command after it, now it works.

Am I setting up something wrong here?

Thank you for your help.

@dedepene Will look into it, but it looks like fabio may have some insight

@pergola.fabio Mind sharing the steps you took to make that work as they may help others, like @dedepene, and I’ll add them to the readme. Also, are you able to use the play_media service in HA to play plex media to the device or do you get the same error?

@rkjr Hard to say what’s going on without seeing the script you are using, Plex Assistant is just using that same play_media service that you’re calling with your other script there.

Hi mayker,

Thanks for your help always.

The playlist playback script is,

plex_playlist_pink_floyd:
  sequence:
  - data:
      entity_id: media_player.google_tv_livingroom
    service: media_player.turn_on  
  - service: media_player.select_source
    entity_id: media_player.google_tv_livingroom
    data:
      source: "Plex"
  - wait_template: "{{ is_state('media_player.google_tv_livingroom', 'On') }}"
    timeout: "00:00:10"
  - service: plex.scan_for_clients
  - wait_template: "{{ not is_state('media_player.plex_plex_for_android_tv_chromecast', 'unavailable') }}"
    timeout: "00:00:10"
    continue_on_timeout: false
  - data:
      media_content_id: '{ "playlist_name" : "Pink Floyd", "shuffle": "1" }'
      media_content_type: playlist
    entity_id: media_player.plex_plex_for_android_tv_chromecast 
    service: media_player.play_media

where the script I use for plex assistant’s startup script is nearly identical to the above as,

start_googletv_plex:
  sequence:
  - data:
      entity_id: media_player.tv_livingroom
    service: media_player.turn_on  
  - wait_template: "{{ is_state('media_player.tv_livingroom', 'On') }}"
    timeout: "00:00:10"
  - data:
      entity_id: media_player.google_tv_livingroom
    service: media_player.turn_on  
  - wait_template: "{{ is_state('media_player.google_tv_livingroom', 'On') }}"
    timeout: "00:00:10"
  - service: media_player.select_source
    entity_id: media_player.google_tv_livingroom
    data:
      source: "Plex"
  - service: plex.scan_for_clients
  - wait_template: "{{ not is_state('media_player.plex_plex_for_android_tv_chromecast', 'unavailable') }}"
    timeout: "00:00:10"

Give this a shot and let me know how it goes and if there are any errors in your logs:

start_googletv_plex:
  sequence:
    - choose:
        - conditions:
            - condition: template
              value_template: >-
                {{ state_attr('media_player.google_tv_livingroom','source') == 'Plex' }}
          sequence: []
      default:
      - service: media_player.turn_on
        data:
          entity_id: media_player.tv_livingroom
      - wait_template: "{{ is_state('media_player.tv_livingroom', 'On') }}"
        timeout: "00:00:10"
      - service: media_player.select_source
        entity_id: 'media_player.google_tv_livingroom'
        data:
          source: 'Plex'
      - repeat:
          while:
            - condition: template
              value_template: >-
                {{ (state_attr('media_player.tv_livingroom','source') != 'Plex' or
                   is_state('media_player.plex_plex_for_android_tv_chromecast', 'unavailable')) and
                   repeat.index <= 20 }}
          sequence:
            - service: plex.scan_for_clients
            - delay:
                seconds: 1
      #### This delay might not be needed
      - delay:
          seconds: 2

hey @mayker, sure this is what i did to make the “plex” app visible on Google Assistant with Dialogflow
btw, any idea whats going on with my samsung tv? some post above


Give the “test” app a decent name like “Plex”

and also enabled account linking, afterwards the “test plex app” was visible and usable on my smart devices

Actually I started with that script, referring to the roku example of yours
in the read me, modified to mine and didn’t work.
I will try that again to check the logs, thanks.

1 Like

Try to use the play_media service to play plex media to the device using the service in developer tools to see if the same error occurs.

1 Like

ok, will test later this weekend, thnx in advance

1 Like

ok, tested, yes the below script gives the same error, i know it worked before like 6-8 months ago, i was then also testing the plex integration… it was still in my test scripts


test_plex:
  alias: 1 TEST Plex
  sequence:
  - service: media_player.play_media
    data:
      entity_id: media_player.plex_plex_for_samsung_tv_ue32h5500
      media_content_type: VIDEO
      media_content_id: "{ \"library_name\": \"Kids\", \"video_name\": \"Cars\" }"

I tested it, and doesn’t work.

Both your script and my script will give the same log as,

Logger: homeassistant.components.plex.media_player
Source: components/plex/media_player.py:522
Integration: Plex Media Server (documentation, issues)
First occurred: 3:53:33 PM (3 occurrences)
Last logged: 11:41:08 PM
Timed out playing on Plex (Plex for Android (TV) - Chromecast)

Now this is strange because this friendly name,
“Plex (Plex for Android (TV) - Chromecast)”
is not setup anywhere for Plex Assistant.

I have 2 entities with this friendly name, which is generated by
Plex Media Server integration.

media_player.plex_plex_for_android_tv_chromecast, is “Plex (Plex for Android (TV) - Chromecast)” but the name changed to “Livingroom TV”
media_player.plex_plex_for_android_tv_chromecast_2 is “Plex (Plex for Android (TV) - Chromecast)”

What is different between the two I see is,
media_player.plex_plex_for_android_tv_chromecast’s player_source is PMS.
where
media_player.plex_plex_for_android_tv_chromecast_2’s is GDM.

We would like an Alexa Skill because the stock one does not work correctly and does not permit using a script to render a player available.

1 Like