Accessing Network Storage (of type Share) from a Script / Automation

Hi,

My ultimate aim is to have a script be able to automatically list the audio files inside it, and then use that to select a random file.

In order to achieve this, I’ve been trying to add a network share which has all my files in. I’ve successfully added a network share using the “Network storage” feature, and I can navigate to it from the Terminal and Studio Code Server addons, so I know it is accessible to Home Assistant.

The issue is that when I try to access that /share/SHARENAME/Folder1/Folder2/file.mp3 location in any script, it just doesn’t do anything. I’m trying just a standalone action using “Media Player: Play media”, and if I put any of the following in the Content ID section of the action, no action is carried out, implying the file can not be found:

file:////share/SHARENAME/Folder1/Folder2/file.mp3
“file:////share/SHARENAME/Folder1/Folder2/file.mp3”
/share/SHARENAME/Folder1/Folder2/file.mp3
“/share/SHARENAME/Folder1/Folder2/file.mp3”

I also tried adding a Media Share, which works, I can play files, but the “expand” function in YAML isnt’ working on folders inside that Media Share location, so that’s why I turned to the Network Share idea.

I’m open to anything, but would love to understand what I’mn doing wrong here, and why accessing the share with a script is so difficult?

Thank you for any and all help!