Control your Linux media players from Home Assistant!

Hello, folks! Here is a HACS-installable integration that lets you control media players (VLC, Chrome, Totem, Amarok, Clementine, and more) in other computers around your dwelling, directly from Home Assistant. You can pause, play, and in some cases (depending on the app) scroll back and forward or jump to next / previous songs in your media player. More features are coming for certain in the future (start / exit apps, play remote media from your media servers).


This integration, of course, requires an agent running on the computer whose media players you’ll control. The agent is here: https://pypi.org/project/hassmpris-agent/

Complete documentation on how to set up the agent and then add your computer to Home Assistant is here: https://github.com/Rudd-O/home-assistant.io/blob/4b9081cbdfc196575b4174cae09710d2fda1ffbb/source/_integrations/hassmpris.markdown. Here is an abridged version:

  • Install the agent on your desktop computer. pip users can install with pip3 install --user -U hassmpris_agent. Also ensure your computer has GTK+ 4 and libnotify installed (your system’s package manager will help with that).
  • Enable the agent by running the settings app (hassmpris-settings) and toggling the agent on.
  • Ensure no firewall rules block port 40051 and 40052.
  • Install the integration via HACS on your Home Assistant instance.
  • Add the integration through the Settings → Devices and services → Add integration screen. If you have a regular LAN, you will probably see your agent autodiscovered onscreen, but you can also add the agent by IP address or host name.

Please file tickets if you discover bugs or have problems — and please ensure to include debug logs so I can fix issues. Remember to set the debug level of the component custom_components.hassmpris to debug in order to get good debugging info.

2 Likes

Update

A bug in the hassmpris_agent agent code was recently discovered. This bug involved “naughty” media players who advertise MPRIS compatibility but hang when the interface is used. The agent now detects that a player is not responding and simply skips over it.

All users should upgrade the agent to avoid this issue. If you installed the agent using pip, then pip install --user -U hassmpris_agent (followed by logging out then back in) should suffice. If you used RPM packages, upgrade them using your system’s package manager, then log out and back in again.

Update

Some users experienced a problem with Zeroconf autodiscovery, which were reflected in the IP address 127.0.0.1 appearing as the IP address to add (obviously wrong). This has been corrected.

Additionally, when the agent disconnected, players which were off before the disconnection reappear as unavailable (though mostly cosmetic, since players that were in any other state came back fine). This has been corrected.

  • If installed using pip: pip install --user -U hassmpris_agent upgrades to the latest agent; turning the agent off and on in the settings program hassmpris-settings makes your agent pick up the update.
  • If installed from RPMs: dnf update -y hassmpris_agent upgrades; turning the agent off and on in the settings program hassmpris-settings makes your agent pick up the update.

Hi there! To readers of this integration page, I would love your answers on the following very short polls:

  • I am using the MPRIS integration to control my media players
  • I am not yet using the MPRIS integration, but intend to eventually
  • I don’t plan on using the MPRIS integration

0 voters

Additionally, if you are using this integration:

  • I am happy with how the MPRIS integration does things
  • I have found better ways to achieve remote media player control

0 voters

Thank you so much!

General status update

The road to HA core inclusion for this work is closed.

As of roughly two hours ago, the pull request for inclusion of this functionality has been closed by private decision of HA core developers. I will also not be requesting this be included in HACS, since a prior PR of mine against HACS was summarily and rudely closed a long while ago.

With no road for inclusion, there is no good reason for me to keep investing effort into this project. Therefore, I have privately decided I will not be continuing to maintain this project anymore — with four minor exceptions:

  1. I will fix any security issues reported through the bug tracker (see below for repository link).
  2. I will fix bugs that interfere with my own user experience of the software as-is today. Please do not expect these fixes to be pushed in a timely manner.
  3. I might add features that I consider necessary, which so far I had refrained from doing so, due to HA reviewers insisting the codebase be kept as small as possible for review to pass (which it did not and never will). It’s unlikely I will do this.
  4. Third-party contributions that make sense within the scope of the project will be accepted.

Any few future code changes will be posted on the final repository for this project.

What this means is that you should consider this project largely unmaintained from this moment on.

Sorry, folks.

For posterity, the rejection message follows, and my closing message in the now-rejected PR follows that.


(HA)

We have discussed this PR in the core team and decided we don’t want to accept it at this time.

We think it’s too complicated without enough use to make it worth adding to core at the moment. It’s both complicated for users, since a specific computer application is required to be installed and setup, and complicated in the integration code with a certificate store. A custom integration is a better fit at this time.

We’re sorry that it took a long time to come to this conclusion. Hopefully the review feedback can at least come to good use in the custom integration.

Thank you for your willingness to contribute!


(Me)

It’s hard to put into words the magnitude of my disappointment.

Look, I completely get that HA devs get to decide what goes in core. I do not plan to reopen this PR or ask for reconsideration. Nonetheless, I’m surprised by the objections raised above (with the apparent sui generis standards for inclusion), given that:

  1. Many integrations in core require the user to install an app — not just referring to ones that need an app on the user’s phone, but also ones that need a control endpoint on target devices. For example, System Bridge needs an agent on a PC, and that’s accepted in core. Fully Kiosk is another one. Why is this integration special / singled out?
  2. Many integrations in core negotiate the equivalent of certificates, such as private key or API token material, and store these (just like this integration does). Proper storage of certificates was, in fact, one of the first review comments addressed in this PR, back over one year ago. It’s so mundane a task to store secrets, HA has built-in helpers for it.
  3. “Without enough use” seems like an impossible chicken-and-egg standard to fulfill, since there will be no use of the core integration until the integration is merged first. Maybe this refers to private statistics of the custom integration copy of this code? (The custom integration is not in HACS, given it was rejected, precisely due to it waiting for review and inclusion in core, right here in this PR.)

The fact that this was rejected also takes future features away from potential users. Once this was stabilized and included in core, I planned to contribute much more functionality, from machine sensors (to bring it up to par with System Bridge), to launching apps / locking screen / controlling attached display / many more features useful for Linux desktop and HTPC users. The current codebase was to serve as a foundation for these additional features. With this PR closed, no viable solution for these needs of Linux users is on the horizon. Perhaps someone will come around sometime in the future to build something ad-hoc over MQTT or similar protocols (limiting its usefulness to sysadmin-type power users), but nothing of the sort exists today.

Home Assistant is a great project. Possibly the most practically useful open source project out there right now (perhaps only to be eclipsed in the near future by open source AGI LLMs).

That said, not gonna lie, the over-a-year of coding, back-and-forth, and final decision, makes it feel to me like all of us involved have engaged in a colossal waste of time — not just my time, but the time of Home Assistant developers and contributors who reviewed this. My estimation is that roughly 400 man/hours went combined into coding this and (most importantly) the time invested by the reviewers into ensuring this code is high-quality, fit for purpose, and ready for more growth — all good honest effort with very positive outcomes. At a $100 / hr engineering rate, that’s a cool $40.000 dollars down the drain, with near zero benefit for anyone — except perhaps my own usage and the half dozen folks who (a) discovered the project in the forum (b) have a Linux computer (c) know what HACS is (d) went through the trouble of manually adding my Github repo to their HACS.

To have this die on the vine, right when it’s basically ready to go in, after 16 months of sitting most of the time without getting reviews — it feels like nothing short of a slap in the face. Had I suspected this would be the outcome, I would not have bothered to contribute anything at all — I would have written something much simpler, just for me, and kept it private.

This was a terrible experience for me as a contributor; I will not be contributing any further changes to the project. I respect your decision, and I ask that mine is respected in kind.

Have a good day.