Hi everyone, is there anyone can help or give some hints on this?
I have a text file locate in www folder. The content was mp3 file name
eg.
1.mp3
2.mp3
I want to read them and automaticaly add to input select. So that it can helps me to get the mp3 url.
Maybe I need a sensor to read the text file then use a script to expand the state of the sensor and set vaile to input select.
But I’m not sure how to read the text file and if there is any other solution.
There is a MUCH easier way to do this if you just need a list of the file names and the files reside in a folder on your Home Assistant server. The problem I had with the solution @123 suggested is that I need to match a URL with a name in a CVS file.
In this case, to just get a list of file names you can use the folder sensor. The folder contents are listed in the attributes (you can set filters on the sensor if necessary).
Then use an automation to populate the input select with the file names. Note the folder path must be listed in allowlist_external_dirs if it doesn’t reside in /www (which is included automatically)
The input select will populate on a restart and then anytime the folder contents change (eg adding a file). Note it takes a moment or two for the file sensor to update.
I followed the guide above to fill the dropdown with .m3u playlists I have in my /media folder. Now if I try to play it via nest mini by using media_play service. The Playlist is not played.
If I play the Playlist using vlc it plays just fine.