I want to remove /config/www/ from the sting. Is there an easy way to do that?
I’m creating a automation that is going to play random sounds when people press the doorbell.
Because I’m using duckdns I have to have the sound in this format:
https://xxxx.duckdns.org:8123/config/halloween/1.mp3
# using replace()
{{ (state_attr('sensor.halloween', 'file_list')|random) | replace('/config/www/','') }}
#using string index slicing
{{ (state_attr('sensor.halloween', 'file_list')|random)[12:] }}
Thanks! That did the work.
media_content_id: >-
https://xxxxxxx.duckdns.org:8123/local/{{ (state_attr(‘sensor.halloween’, ‘file_list’)|random) | replace(‘/config/www/’,‘’) }}