Hi folks,
I’m creating an automation to keep birds away from the roof because they move the tiles and every year I have to call someone to fix them back. I downloaded the sounds of the birds of pray living in my area from the internet and I play them with a pair of outdoor speakers that I placed on the roof.
I’d like if Alexa could announce the name of the file each time the automation runs but I have no clue how to get the template of the last played file. Can anyone help me with that?
This is the automation: after the file is being reproduced I want to call alexa_media service announcing the file name.
alias: Casa - S22) - Dissuasore uccelli
description: Emette verso di rapaci diurni o notturni in base all'orario
trigger:
- platform: time_pattern
minutes: /15
seconds: "20"
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.giorno_numero
above: 90
below: 204
- condition: state
entity_id: sun.sun
state: above_horizon
sequence:
- service: media_player.play_media
target:
entity_id: media_player.XXX
data:
media_content_id: "{{ state_attr('sensor.rapaci_diurni', 'file_list')|random }}"
media_content_type: audio/mpeg
- conditions:
- condition: numeric_state
entity_id: sensor.giorno_numero
above: 90
below: 204
- condition: state
entity_id: sun.sun
state: below_horizon
sequence:
- service: media_player.play_media
target:
entity_id: media_player.XXX
data:
media_content_id: "{{ state_attr('sensor.rapaci_notturni', 'file_list')|random }}"
media_content_type: audio/mpeg
mode: single
If i check traces I do have the name of the used file but I have no clue how to let Alexa repeat that name:
Eseguito: 8 maggio 2024 alle ore 00:00:20
Risultato:
params:
domain: media_player
service: play_media
service_data:
media_content_id: /media/Suoni/Rapaci Notturni/**[u]Gufo comune femmina[/u]**.mp3
media_content_type: audio/mpeg
entity_id:
- media_player.web_microsoft_edge_windows
target:
entity_id:
- media_player.web_microsoft_edge_windows
running_script: false