Media Player as MQTT

Hello!

I would like to use MQTT for a media player.

I am using shairport to airplay music in a whole-home audio solution. Shairport supports MQTT, and I am able to get shairport to publish topics for status. I am also able to control Shairport via MQTT.

I found the “Universal Media Player” Configuration in the documentation (https://www.home-assistant.io/integrations/universal/) that might do what I’m looking for.

If I were to use Universal media player, I imagine it would look something like:

media_player:
  - platform: universal
    name: Shairport
    commands:
      volume_down:
        service: mqtt.publish
        data: 
          topic: shairport-sync/snapcast/remote
          payload: "volumedown"
          qos: 2
          retain: false
...

Would that be possible or am I totally off on how to implement this?

I don’t believe there is anyway to use MQTT as a media player it’s been asked many times.

1 Like

Yeah it looks like you are right. I just found the feature request: MQTT Media Player

Thanks for the response!

For shairpoint integration see Simple multiroom with Home Assistant

Hi,

Not sure if you found a solution already, but I made a custom component for this since I’m also using a MQTT enabled media player and I couldn’t really find any alternative.

If you’d like to try it out (and hopefully tell me if it works for you) that would be great!

Heres the link: https://github.com/TroyFernandes/hass-mqtt-mediaplayer

Sweet thanks! I’ll give it a try!

I am intrigued at what sort of media device you have that has an mqtt interface?

It’s not so much the media player itself. The media player’s called Musicbee and it supports plugins. So I made a MQTT Remote plugin. Basically just publishes current song info and listens for commands through MQTT.

Looks quite cool. If I wasn’t wedded to Squeezebox I would look further.

Great that their system is open enough for that.

Not sure if you tried it already, but I finally understood what you meant by the example in your original post and it made sense for me to implement the volume_up and volume_down independently of the volume_set.

Anyways with your example, I think the configuration.yaml would look something like this

media_player:  
  - platform: mqtt-mediaplayer
    name: "Shairport"
    vol_down:
      service: mqtt.publish
      data:
        topic: "shairport-sync/snapcast/remote"
        payload: "volumedown"
    vol_up:
      service: mqtt.publish
      data:
        topic: "shairport-sync/snapcast/remote"
        payload: "volumeup"

I pushed the changes to the repo. Also, if vol_up and/or vol_down are used, the volume slider (aka. the volume_set service) becomes disabled. Just something to note