Exposing media_player power / volume / source to MQTT and make it controllable via MQTT

Hi.

I want to expose the power / volume and source of my media_player via MQTT and allow that state to be changed via MQTT as well.

Is there a neat way to do this?

My initial though was create mqtt entities (e.g. mqtt switch for the power) this can then be consumed / changed by the external service and then in Home Assistant I’d need an automation to keep the power of the media_player in line with the mqtt switch so when either changes the state is replicated to the other one.

However this feels really clunky are there any better suggestions?

Dunno if this helps GitHub - TroyFernandes/hass-mqtt-mediaplayer: Fill out your Media Player Entity with MQTT Topics