_Mike
(Mike)
August 3, 2020, 1:22am
1
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!
KTibow
(Kendell R)
August 3, 2020, 2:15am
2
You forgot the 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) }}" }'
_Mike
(Mike)
August 3, 2020, 12:47pm
3
@KTibow If only it were that simple! I tried that, but HA does not like the double single quotes.
KTibow
(Kendell R)
August 3, 2020, 1:48pm
4
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.
_Mike
(Mike)
August 3, 2020, 2:08pm
5
I copied and pasted your code and got this. HA is unhappy about something!
KTibow
(Kendell R)
August 3, 2020, 2:11pm
6
Looks like HA is auto-escaping for you. Can you go into File Editor instead?
_Mike
(Mike)
August 3, 2020, 2:54pm
7
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) }}" }