First automation! :)

Hi guys, bought myself a PI this Christmas and will start to automate =P
I got a couple of questions, i will go z-wave with some lights etcs but as my first attempt is to try to just play a birds.mp3 file at 7am when we get up.
I have installed the pi, home-assistant, omxplayer and i got myself a mp3 file that I can play simply by just typing omxplayer birds.mp3 and the sound will come from the connected 3.5mm speaker.

now… where do I start, I have read a few topics here but since I only have configuration.yaml file here now and not any nofity or automation (as I have seen been refereed to before, how do I accomplish this rather easy task?)

in my configration.yaml i will specify all logic or shall I split them up into chunchs in different files and “call/include” them from the main configuration.yaml file?

and if I want to set the time to 7am for weekdays and 9am for weekends?

This is what I have done in configuration.yaml:

automation:
alias: sounds
trigger:
platform: time
after: ‘07:00:00’
action:
service: shell_command.play_sound

this is what I have done in shell_command.yaml
sounds:
play_sound: omxplayer /home/pi/media/birds.mp3

…have been copying & pasting code from the forums but does not seem to be working together…

Please advice!

Your configuration file has wrong indents. Try changing it like this:

automation:
  alias: sounds
trigger:
  platform: time
  after: '07:00:00'
action:
  service: shell_command.play_sound

Hi, t hanks for the reply, the space is correct in the file, was just bogus when I pasted it here… sorry for that confusion.

service: shell_command.play_sound how does that work?

it calls a service and will use a file shell_command.yaml (which one should include before this) and it will execute a play_sound feature?

Your action is wrong.

Check this thread - https://community.home-assistant.io/t/automation-to-play-a-sound-when-door-sensor-is-triggered/3266/11

1 Like

ok so I put the

shell_command:
  play_sound: omxplayer /home/pi/media/birds.mp3

just above my automation, and it works but if I would like to call another sound like a godnight sound.

can I have two play_sound: commands under the shell_command: statement? how does the “script” know which one to trigger?

Yes, you can have multiple.
Add new command under play_sound: omxplayer /home/pi/media/birds.mp3
Example:

shell_command:
  play_sound: omxplayer /home/pi/media/birds.mp3
  some_other_sound_name: omxplayer /home/pi/media/sound.mp3

some_other_sound_name is the name of the shell command you want to add, just pick some name.

Then add new automation and in the action use the new name:

action:
  service: shell_command.some_other_sound_name

PS: check the documentation - https://home-assistant.io/components/shell_command/

1 Like