Skip to content

DM911-AI/homebridge-homepod-mini-music-sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 homebridge-homepod-mini-music-sensor

Transform your HomePod mini into a smart music sensor for HomeKit

HomePod

npm version npm downloads GitHub stars

HomePod HomeKit Homebridge License

πŸ“¦ npm β€’ πŸ’» GitHub β€’ πŸ› Issues β€’ πŸ‘€ Author


🎯 Overview

This Homebridge plugin turns your HomePod mini (or HomePod) into a smart music sensor for HomeKit. It appears as a motion sensor that detects when music is playing, enabling powerful home automations based on your listening habits.

Why use this plugin?

  • 🎡 Create mood lighting that responds to music
  • 🏠 Build multi-room audio automations
  • πŸŒ™ Trigger scenes when music stops
  • πŸ“± No complicated setup - works out of the box
  • πŸŽ›οΈ Fully customizable detection settings

✨ Features

Core Features

  • 🎡 Smart Music Detection - Detects when music is actively playing
  • πŸ“± HomeKit Motion Sensor - Appears as a standard motion sensor in Home app
  • 🏠 Multi-HomePod Support - Create separate sensors for each HomePod
  • 🚫 No Authentication Required - Works with HomePod mini without pairing
  • ⚑ Fast Updates - Configurable update interval (1-60 seconds)

Advanced Features

  • πŸŽ›οΈ Configurable Detection - Choose what to detect: music, podcasts, movies, or all
  • 🎬 Smart Filtering - Automatically filters out movies and long-form content
  • ⏱️ Duration-Based Filtering - Set max duration for content detection
  • 🎀 Artist Field Detection - Filter content by presence of artist metadata
  • πŸ”„ Real-time Updates - Always knows what's playing, when it's playing

πŸš€ Installation

Prerequisites

Python 3 is required for this plugin to work:

# Install Python 3 (macOS)
brew install python3

# Verify installation
python3 --version

pyatv library is required to communicate with HomePods:

# Install pyatv
pip3 install pyatv

# Verify installation
python3 -m pyatv --version

Plugin Installation

Via Homebridge UI (Recommended)

  1. Open Homebridge UI
  2. Go to Plugins tab
  3. Search for "HomePod Mini Music Sensor"
  4. Click Install
  5. Wait for installation to complete
  6. Restart Homebridge

Via Terminal

npm install -g homebridge-homepod-mini-music-sensor

βš™οΈ Configuration

🎨 Visual Configuration Guide

This plugin is designed to be configured entirely through the Homebridge UI - no manual JSON editing required!

Step 1: Open Plugin Settings

After installing the plugin, click the βš™οΈ Settings button in the Homebridge UI.

Plugin Configuration Main Screen

You'll see:

  • 🎡 Hero Image - Beautiful HomePod visual at the top
  • πŸŽ›οΈ Detection Settings - Collapsible section for customizing what gets detected
  • 🏠 Your HomePods - Section to add your HomePod devices

Step 2: Configure Detection Settings (Optional)

Expand the πŸŽ›οΈ Detection Settings section to customize what triggers your sensors:

Detection Settings

Available Options:

  • βœ… 🎡 Detect Music (Default: ON) - Trigger when music plays
  • ☐ πŸŽ™οΈ Detect Podcasts (Default: OFF) - Trigger for podcasts/audiobooks
  • ☐ 🎬 Detect Movies/TV (Default: OFF) - Trigger for AirPlay video
  • ⏱️ Max Duration (Default: 600 seconds) - Filter by content length
  • βœ… 🎀 Require Artist Field (Default: ON) - Filter out content without artist metadata
  • πŸ”„ Update Interval (Default: 5 seconds) - How often to check status

πŸ’‘ Detection Tips:

  • Music Only: Keep defaults (Music: ON, Podcasts: OFF, Movies: OFF)
  • Music + Podcasts: Enable both + increase Max Duration to 3600 (60 min)
  • Everything: Enable all + disable 'Require Artist Field'

Step 3: Add Your HomePods

Expand the 🏠 Your HomePods section and click βž• Add HomePod:

Add HomePod Configuration

For each HomePod:

  1. Display Name - Enter a friendly name (e.g., "Bedroom", "Kitchen")
  2. Device ID - Enter the HomePod identifier (see instructions below)

πŸ“‹ How to Find HomePod IDs:

  1. Open Terminal
  2. Run: python3 -m pyatv.scripts.atvremote scan
  3. Find your HomePod in the list
  4. Copy the Identifier (remove colons/dashes)
  5. Example: A2:94:FB:11:E0:39 β†’ A294FB11E039

πŸ’‘ Tip: Each HomePod will appear as a separate Motion Sensor in HomeKit


Step 4: Save and Restart

  1. Click SAVE button (bottom right)
  2. Restart Homebridge
  3. Your HomePods will now appear as motion sensors in the Home app! πŸŽ‰

Manual Configuration (config.json)

Click to view manual configuration options

If you prefer to edit config.json manually:

{
  "platform": "HomePodMusicSensor",
  "name": "HomePod Music Sensor",
  "detectMusic": true,
  "detectPodcasts": false,
  "detectMovies": false,
  "maxDuration": 600,
  "requireArtist": true,
  "updateInterval": 5,
  "devices": [
    {
      "name": "Bedroom",
      "deviceId": "A294FB11E039"
    },
    {
      "name": "Living Room",
      "deviceId": "F2E8AA6E8D9C"
    }
  ]
}

🎯 HomeKit Automations

Once configured, each HomePod appears as a Motion Sensor in the Home app:

  • βœ… Motion Detected = Content is currently playing (based on your settings)
  • ❌ No Motion Detected = Nothing is playing or paused

Automation Ideas

πŸŒ… Morning Routine

When "Bedroom" detects motion (music starts)
β†’ Open bedroom blinds
β†’ Turn on coffee maker
β†’ Set living room lights to 100%

πŸ’‘ Mood Lighting

When "Living Room" detects motion
β†’ Dim living room lights to 30%
β†’ Set lights to warm white
β†’ Turn off TV

🎡 Multi-Room Audio Control

When "Kitchen" detects motion
β†’ Pause "Living Room" HomePod
β†’ Lower "Bedroom" HomePod volume to 20%

πŸŒ™ Sleep Mode

When "Bedroom" stops detecting motion (music stops)
β†’ Turn off all lights
β†’ Lock front door
β†’ Set thermostat to 68Β°F
β†’ Close blinds

πŸƒ Workout Detection

When "Gym Room" detects motion
β†’ Turn on fan
β†’ Set lights to energizing blue
β†’ Lock gym room door

🍳 Cooking Assistant

When "Kitchen" detects motion
β†’ Turn on under-cabinet lights
β†’ Display recipe on iPad
β†’ Pause other HomePods


🎭 Content Detection

What Gets Detected?

Content Type Default Behavior How It's Detected Configurable?
🎡 Music (Apple Music, Spotify) βœ… Detected Music type + has artist + short duration Yes - disable if needed
πŸŽ™οΈ Podcasts ❌ Not Detected Long duration (>10 min) Yes - enable in settings
πŸ“š Audiobooks ❌ Not Detected Long duration (>10 min) Yes - enable in settings
🎬 Movies/TV (AirPlay) ❌ Not Detected No artist field Yes - enable + disable "Require Artist"
πŸ—£οΈ Siri Responses ❌ Never Detected Not music type No

Detection Logic

The plugin uses smart filtering to determine if content should trigger the sensor:

  1. Is anything playing? β†’ Check playback state
  2. What type of content? β†’ Check media type (music, video, etc.)
  3. Does it match settings? β†’ Check if enabled (music/podcasts/movies)
  4. How long is it? β†’ Check against max duration
  5. Has artist info? β†’ Check artist field (if required)

Result: Sensor triggers only when ALL conditions match your settings.


πŸ”§ Troubleshooting

Common Issues

❌ HomePods not appearing in HomeKit

Solutions:

  • Verify IDs: python3 -m pyatv.scripts.atvremote scan
  • Check HomePods are on same network as Homebridge
  • Restart Homebridge
  • Check Homebridge logs for errors
❌ Sensor always shows "No Motion"

Solutions:

  • Ensure music is actually playing (not paused)
  • Test manually: python3 get_nowplaying.py YOUR_ID
  • Check detection settings (maybe podcasts/movies are disabled)
  • Review Homebridge logs
  • Verify pyatv is working: python3 -m pyatv.scripts.atvremote --id YOUR_ID playing
❌ Sensor triggers for movies/videos

Solutions:

  • Enable "Require Artist Field" in settings (default: ON)
  • Disable "Detect Movies/TV" in settings (default: OFF)
  • Lower "Max Duration" to filter longer content
❌ Python or pyatv errors

Solutions:

# Verify Python
python3 --version

# Reinstall pyatv
pip3 install --upgrade pyatv

# Test pyatv
python3 -m pyatv scan
❌ "Plugin alias could not be determined" error

Solutions:

  • This usually means the plugin wasn't installed correctly
  • Try reinstalling: npm uninstall -g homebridge-homepod-mini-music-sensor && npm install -g homebridge-homepod-mini-music-sensor
  • Clear npm cache: npm cache clean --force
  • Restart Homebridge

Getting More Help

If you're still experiencing issues:

  1. Check the logs

    • Homebridge UI β†’ Logs tab
    • Look for lines containing "HomePod" or "Music Sensor"
  2. Enable debug logging

    • Check Homebridge debug logs for more details
  3. Report an issue


πŸ“± Supported Devices

Fully Supported

  • βœ… HomePod mini (all colors)
  • βœ… HomePod (1st generation - discontinued)
  • βœ… HomePod (2nd generation - 2023)

Requirements

  • Network: HomePods must be on same local network as Homebridge
  • tvOS: Any version supported by pyatv
  • No authentication required - Works without pairing

Not Supported (Yet)

  • ❌ Apple TV - Requires authentication/pairing

πŸ—ΊοΈ Roadmap

Planned Features

  • Apple TV Support

    • Add authentication/pairing support
    • Enable same features for Apple TV
    • Expected: Version 2.0
  • Song Metadata Display

    • Show current song in Eve app
    • Display artist, album, artwork
    • Expected: Version 1.5
  • Stereo Pair Support (Added in v1.4)

    • Detect HomePod stereo pairs
    • Create single sensor for pair
  • Custom Webhooks

    • Trigger external services when music plays
    • IFTTT, Zapier integration
    • Expected: Version 1.7
  • Web Dashboard

    • View all HomePods at a glance
    • See what's playing everywhere
    • Expected: Version 2.0

Suggest a Feature

Have an idea? Open a feature request on GitHub!


🀝 Contributing

Contributions are welcome and appreciated!

How to Contribute

  1. Fork the repository
   git clone https://github.com/YOUR_USERNAME/homebridge-homepod-mini-music-sensor.git
  1. Create a feature branch
   git checkout -b feature/AmazingFeature
  1. Make your changes

    • Follow existing code style
    • Add comments for complex logic
    • Test thoroughly
  2. Commit your changes

   git commit -m 'Add some AmazingFeature'
  1. Push to your fork
   git push origin feature/AmazingFeature
  1. Open a Pull Request
    • Describe your changes
    • Link any related issues

Development Setup

# Clone the repo
git clone https://github.com/DM911-AI/homebridge-homepod-mini-music-sensor.git
cd homebridge-homepod-mini-music-sensor

# Install dependencies
npm install

# Link for local testing
npm link

# Make changes and test

πŸ“œ License

This project is licensed under the MIT License.

What this means:

  • βœ… Free to use
  • βœ… Free to modify
  • βœ… Free to distribute
  • βœ… Can use commercially

See the LICENSE file for full details.


πŸ‘ Credits & Acknowledgments

Built With

  • pyatv - Amazing Python library for controlling Apple TV and HomePod devices

Inspired By

  • The Homebridge community's need for better HomePod integration
  • Requests for music-based HomeKit automations

Special Thanks

  • Homebridge team - For creating the platform
  • Early testers - For feedback and bug reports
  • 600+ users - For downloading and using this plugin! πŸŽ‰

πŸ‘€ Author

Daniel Mazuz

GitHub npm


πŸ”— Quick Links

πŸ“¦ npm Package β€’ πŸ’» GitHub Repository β€’ πŸ› Report Bug β€’ πŸ’‘ Request Feature


⭐ Support This Project

If you find this plugin useful, please consider:

  • ⭐ Star this repository on GitHub
  • πŸ› Report bugs and issues
  • πŸ’‘ Suggest new features
  • πŸ“’ Share with friends and the community
  • β˜• Buy me a coffee (coming soon!)

GitHub stars


πŸ’™ Enjoying this plugin? Star it on GitHub and share with the community!