#Automation for playing MP3 file with dynamic location

15 messages · Page 1 of 1 (latest)

carmine moon
#

Please help me to make automation for playing daily updated MP3 file on my home assistant. I know all the functionality for playing it with media_extractor. the file storage location is straight forward based on date. i need script to just make new link each day with new date & month variable. the working example MP3 file is as below link
https://new.sgpc.net/katha/2024/October/katha041024.mp3

#

or just help me make bash script which i will run daily & system download/overwrite the existing/yesterday's mp3 file & i will play that new file on later stage with same name. thanks

muted ridge
#

To make that link - it's just a template, right?

#

https://new.sgpc.net/katha/{YYYY}/{MONTH}/katha{DDMMYY}.mp3 like that?

carmine moon
#

thanks Sir, I will put this link & surely reply you the result.

#

i put that template in my automation but my google mini not playing that file. in past it was working when there file format location was static. with this dynamic location this file is not playing.

muted ridge
#

Wait, it's not the template itself. I just asked if that's correct variables

carmine moon
#

yes, the variable are same based on time like year, month & day. there cloud system daily generate new file & save on cloud with same format. you can see all files on there system in file explorer way.

#

https://new.sgpc.net/katha/

muted ridge
#

Ok gimme sec, i'll do the template for you

carmine moon
#

thanks for helping. I just want to play only latest (mean's only today's when automation trigger) file. i do not want any functionality for older files.

muted ridge
#
{% set now = now() %}
https://new.sgpc.net/katha/{{ now.strftime("%Y") }}/{{ now.strftime("%B") }}/katha{{ now.strftime("%d%m%y") }}.mp3
carmine moon
#

Thanks, this url works.

carmine moon
#

full working script is - service: media_extractor.play_media data: media_content_type: MUSIC media_content_id: '{% set now = now() %} https://new.sgpc.net/katha/{{ now.strftime("%Y") }}/{{ now.strftime("%B") }}/katha{{ now.strftime("%d%m%y") }}.mp3' target: entity_id: media_player.googlehome8150 and it is playing the latest file on server as intended, thanks

muted ridge
#

Great! Glad it works as you want 🙂 If tomorrow it doesn't work - come by.