That tells me you have a formatting error. The pipe symbol is collecting that key.
Play with the formatting there.
Perhaps loose the pipe and add a single quote there and to the end of the template might work.
I’m not the greatest template guru, but I saw that and thought it might be the problem.
As SG pointed out, there’s some indentation issues. The template should be indented more and target less. I wouldn’t bother with the metadata unless your media player requires it. You can also remove a lot of the repetitive file path info by placing it outside the expression delimiters:
service: media_player.play_media
data:
media_content_type: music
media_content_id: |
media-source://media_source/local/{{- [
"im-afraid-we-need-to-use",
"bad-to-the-bone",
"bill-nye-theme",
"maths",
"what the dog doing",
"rick-flair-wooo",
"silence_64kb" ] | random -}}.mp3
target:
entity_id: media_player.living_room_nest_audio
metadata: {}
Thank you. I was able to save the yaml successfully. Now doing a trace because im not getting any audio. Its error’ing out with unknown source directory. Still troubleshooting
Executed: July 25, 2025 at 11:52:31 AM
Error: Unknown source directory.
Result:
params:
domain: media_player
service: play_media
service_data:
media_content_type: music
media_content_id: media-source://media_source/local/maths.mp3
entity_id:
- media_player.living_room_nest_audio
target:
entity_id:
- media_player.living_room_nest_audio
running_script: false