Make play_on_device_media_file/media_file templatable #3626
Replies: 2 comments
-
|
🏷️ I've automatically added the |
Beta Was this translation helpful? Give feedback.
-
|
FYI, I was able to make
I commented out line 515 where it assigns
I don't know if this is the right way to do it, but it allowed me to template it and my code seems to work, so good enough for me for now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Component name
media_player
Link to component documentation on our website
https://esphome.io/components/media_player/speaker/
Describe the enhancement
Currently,
media_player.speaker.play_on_device_media_filedoesn't support templating the id of the audio file formedia_file. This makes the function very limiting, as you can't have any logic in the call to determine what file to play. Ifmedia_fileallowed templating, then you would be able to have a lambda determine which file to play.Use cases
In my project example, I have numerous different audio alert sounds, and a select that allows users to pick one. When it comes to playing the selected audio file, I cannot use
media_player.speaker.play_on_device_media_filebecause I can't use any lambda code.Anything else?
I'd also like to point out that it does not seem possible to provide the
idof the media player you want to use when callingmedia_player.speaker.play_on_device_media_file.In regards to having the ability to define audio files on both
speakeras well asspeaker_source(by creating a media source) platforms, I would suggest that bothspeakerandspeaker_sourcemerge their feature set into justspeaker. Being able to useaudio-file://along with a media source makes working with both local and streaming audio resources significantly easier (and working with them using lambdas is also much easier too).Beta Was this translation helpful? Give feedback.
All reactions