š¦Home Assistant - It's for the birds! [Part 2]
After setting up Music Assistant, the next logical step is using automation to control playback intelligently. In todayās post, weāre showcasing a real-world YAML automation that does something unique: it plays music only for your pet birds when nobody is home!
šÆ Automation Goal
This YAML automationācleverly named BirdMusicādoes the following:
- Starts bird-friendly radio at 9:00 AM
- Stops playback at 8:30 PM
- Only runs if:
- The house is unoccupied
- The birds are present
Perfect for homes with feathered companions who enjoy a bit of ambiance!
š The YAML Automation
Hereās the full automation:
alias: BirdMusic
description: "Starts the music at 9am, turns it off at 8.30pm but only if no one is home and the birds are present."
triggers:
- trigger: time
at: "09:00:00"
id: StartTime
- trigger: time
at: "20:30:00"
id: StopTime
conditions:
- condition: state
entity_id: input_boolean.birdspresent
state: "on"
- condition: state
entity_id: input_boolean.occupied
state: "off"
actions:
- if:
- condition: trigger
id:
- StartTime
then:
- action: music_assistant.play_media
metadata: {}
data:
media_id: tunein://radio/s45579--aac
target:
entity_id: media_player.living_room_display_2
else:
- action: media_player.media_stop
metadata: {}
data: {}
target:
device_id: 826abec0b9611ec85eb4490c33782d31
mode: single
š How It Works
Letās break it down:
ā° Triggers
- 9:00 AM ā Starts music
- 8:30 PM ā Stops music
ā Conditions
input_boolean.birdspresent
must be on ā The birds are home.input_boolean.occupied
must be off ā No humans are home.
š§ Actions
- If itās the start time, it uses
music_assistant.play_media
to play a TuneIn stream (station ID:s45579--aac - Kerrang Radio
) on theliving_room_display_2
. - If itās stop time, it calls
media_player.media_stop
on a specific device ID, ensuring playback ends cleanly.
š ļø Tips for Customization
Want to try something similar? Hereās how to adapt this automation:
- Change the media stream: Replace the TuneIn ID with another stream or playlist.
- Adjust the time triggers: Add more triggers for lunch breaks or nap time.
- Make presence detection smarter: Use device trackers or motion sensors instead of input booleans.
š¦ Why This Is Awesome
This automation doesnāt just play musicāit responds to environmental context. It's a great example of:
- Using Music Assistant for real-life, non-human use cases
- Enhancing animal enrichment via automation
- Practicing smart energy and noise management (no sound when people are home)
š¬ Final Thoughts
Smart homes arenāt just for humans. Automations like BirdMusic show how flexible Home Assistant and Music Assistant can be when you pair them with a little creativityāand YAML.