Stopping music in my office automatically when I get a phone call or join an audio/video call
I have an Intel NUC in my office, using mpd
, to play music on some speakers.
I control this via either mpc
or ncmpcpp
, depending on what I want to do.
Since I worked out how to add Internet radio streams to mpd
, I’m rather enjoying that.
But if I get a phone call, or go on an audio/video call on my computer, I want the music to pause automatically.
It just needed me to integrate mpd
with Home Assistant, and then to have it pause the music when an automation is triggered.
Simple.
(And if I didn’t have Home Assistant, or didn’t want to use a system like that, I could just trigger a script which uses mpc
to pause the player. That work cover calls from my laptop easily, but would’t be so straightforward for phone calls.)
Adding mpd
to Home Assistant
There is no GUI integration for adding mpd
to Home Assistant; it is some yaml in the configuration file:
# Example configuration.yaml entry
media_player:
- platform: mpd
host: IP_ADDRESS
name: officenuc
To get this to work, I had to allow the box running Home Assistant to be able to talk to the box running mpd
.
This is sub-optimal, as they are on separate VLANs, so I wonder if I need to think about moving boxes around the VLANs, to keep things isolated. But, for now, it works.
Once I’d done that, and restarted Home Assistant, there is a controller in the Home Assistant GUI, letting me pause, and change volume (and not much more).
Pausing mpd
when I get a phone call / join an audio/video call
I extended the automations that I had already in place in Home Assistant for handling when I get a phone call / go onto a video call.
To do that, I added a new Action of “Call a service”.
The service is media_player:media_pause
.
Under “Choose entity”, I selected the mpd option for my server.
And that was it.
Now, if you ring me, or if I join a video/audio call from my computer, my music stops automatically.
You may also like:
- Adding an Internet radio stream (such as RadioFreeFedi) to mpd
- Triggering a remote lamp automatically when I am on a call
- Getting the Sierra Wireless EM7455 LTE modem working in a ThinkPad with Debian 12 Linux (with GPS)
- Fixing dropbear-initramfs '/scripts/init-premount/dropbear: cat: not found' error
- Keeping bash history in sync using atuin and a self-hosted sync server
- Keyboard shortcut for adding random albums to the playlist in ncmpcpp
- This is a test post
- Fixing Mastodon 'Error processing thumbnail for uploaded media' video uploading
- Upgrading the glitch-soc fork of Mastodon
- Very, very initial thoughts of the Xreal Air 2 Pro glasses and Debian 12
- Using Bitwarden as an AppImage on Debian with GNOME
- A web UI for label creation and printing on a Brother QL-710W on Linux
- Getting a Brother QL-710W label printer working via CUPS on Debian
- Desktop Linux: the software I'm currently using
- Fixing apt yarn key deprecation warning in Debian 12