R_V
1
Can a Raspberry Pi running Hass.io also be a / its own media_player with a powered speaker attached to the Pi audio jack output?
or, could a Raspberry Pi running raspbain (or other os) be a media_player?
the goal is to run local mp3 files in automations.
masterov
(Alexei Masterov)
3
Yes, I do it with the following script (scripts.yaml):
play_a_sound:
alias: Play a sound from a file
sequence:
- data: {}
entity_id: script.1593462058745
service: script.turn_on
- delay: 00:00:02
- data_template:
filename: '{% if filename %} {{filename}} {% else %} Ship_Bell.mp3 {% endif
%}'
service: shell_command.play_sound
- data: {}
entity_id: script.1593462184816
service: script.turn_on
which relies on the following shell command (configuration.yaml):
shell_command:
play_sound: /usr/bin/omxplayer /home/homeassistant/sounds/{{filename}}
or, if your use case is simple, you can just specify the filename directly in the shell_command and don’t bother with the script.