🐦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 the living_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.

As an Amazon Associate I earn from qualifying purchases.

If you have found this post useful, please consider donating.