How to play a random Plex movie?

I am working on some Halloween automations, and would like to be able to trigger a random video to be played on my projector via the installed Plex app. Hard coding a specific video works perfectly:

plex_halloween_projector:
  sequence:
    - service: media_player.play_media
      data:
        entity_id: media_player.plex_plex_for_android_nebula_projector
        media_content_type: VIDEO
        media_content_id: '{ "library_name": "AtmosFearFX", "video_name": "Dancing Skeletons" }'

But I would like to be able to feed it a list of video names and have it pick one at random. I think it would be some variation of this, but this does not work:


plex_halloween_projector:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: media_player.plex_plex_for_android_nebula_projector
        media_content_type: VIDEO
        media_content_id: >
          '{ "library_name": "AtmosFearFX", "video_name": "{{ (['Beckoning Beauty','Wraiths','Dancing Skeletons']|random) }}" }'

I’m probably just doing something dumb. Please help!

You forgot the quotes :slightly_smiling_face:

 plex_halloween_projector:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: media_player.plex_plex_for_android_nebula_projector
        media_content_type: VIDEO
        media_content_id: >
          '{ "library_name": "AtmosFearFX", "video_name": "{{ ([''Beckoning Beauty'',''Wraiths'',''Dancing Skeletons'']|random) }}" }'

@KTibow If only it were that simple! I tried that, but HA does not like the double single quotes.

Well then it’s too many quotes?

 plex_halloween_projector:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: media_player.plex_plex_for_android_nebula_projector
        media_content_type: VIDEO
        media_content_id: >
          { "library_name": "AtmosFearFX", "video_name": "{{ ([''Beckoning Beauty'',''Wraiths'',''Dancing Skeletons'']|random) }}" }

It produces the exact same output in my developers tools templating section as the fixed option.

I copied and pasted your code and got this. HA is unhappy about something!

image

Looks like HA is auto-escaping for you. Can you go into File Editor instead?

I finally got it to work. I appreciate your help!

plex_halloween_projector:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: media_player.plex_plex_for_android_nebula_projector
        media_content_type: VIDEO
        media_content_id: >
          { "library_name": "AtmosFearFX", "video_name": "{{ (['Beckoning Beauty','Wraiths','Dancing Skeletons']|random) }}" }