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) 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!