This is my automation that plays a mp3 file via a google nest speaker. I have 3 files (enzobark1, enzobark2, enzobark3) that I want to play in sort of random order every time the automation kicks in.
I was thinking of two approaches to substitute the number in the file name.
- To use random function with min=1 and max=3 and generate filename based on that.
- Do an if condition check say if current time seconds <20 choose file1, if seconds <40 choose file2 and if seconds <60 choose file3.
Problem is that I dont know how to use make such a substitution in the automation. Anyone who can help out?
alias: Frigate Notification
description: ""
trigger:
- platform: mqtt
topic: frigate/events
payload: new
value_template: "{{ value_json.type }}"
action:
- service: media_player.play_media
data:
media_content_id: /local/enzobark1.mp3
media_content_type: audio/mp3
target:
device_id: f9ada08ba91258ac7edee0383abec80f