#Is there a way to list X number of source files in yaml and have HA randomly pick one from list?
5 messages · Page 1 of 1 (latest)
To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.
You can do it with a template fairly easily and the | random function.
Thanks, do you have any examples of a tempate doing this? I have not worked with templates yet.
If they are in your /www directory, you could do something like
{% set files = [‘file1.mp3’, ‘file2.mp3’, ‘file3.mp3’] %}
{{ ‘http://<ha address>:8123/www/‘ ~ files | random }}