Custom media player with command line

Hello everyone,

I’m new to HASS, but experienced developer (including python).

I have a custom hardware multi-room sound distribution system. I use a PI with a USB-serial cable to control it. It has 6 zones each with on/off, 6 sources, and volume. I was able to add command line switches to Lovelace front end to basically perform macro. For example, I do echo -e “*command 1” > /dev/ttyUSB0; echo -e “*command 2” > /dev/ttyUSB0 for one switch, another one to turn another set of zones on and switch sources to play the tv. Ideally I have a media card for each zone with its own on/off, source, and volume, and an all zones card. However, seems any media player has to be an actual integration. So is the way to accomplish what I want to create a custom media_player? Seems media_player already has placeholders for those commands, and I just need to hook up the command_line services to those placeholders. I guess I’m not seeing the full picture of how command_lines, services, integrations, media_player, and Lovelace UI all relate.

Thanks for help in advance!

Hey junying and welcome to Home-Assistant :partying_face:

You’re right, there’s currently no native way of doing that.
What you want is a template media player, and there is none in HA at the moment. However other community members had that same problem. You could try this repo: https://github.com/Sennevds/media_player.template
If that’s not working (I didn’t test it), you could install custom frontend customizations, I’m using the “tv-card” for example.
You can map every button to a script (Like play, pause, up, down, enter,…), there are also more generic ones available (like the Remote Control Card), where you can also map every button.

If you’re willing to invest the time, it may be worth to run some remote-controllable software on your media pi then. (VLC or MPD maybe?) This will make it a lot easier to integrate into Home Assistant :slight_smile:

Thank you so much for the quick response. I’ll check out the repo.

Unfortunately what I’m trying to control is not an actual media player, rather just a multiplex of amps and sources. So I’m only concerned with turning it on/off, switch source, and change volume (and mute). The actual music comes from a Chromecast Audio so that’s already controlled very well by HA.

Thanks again and I’ll share back what i find.

1 Like

Ah I see, I thought your pi would also handle the audio itself :slight_smile:
Hm, in that case I’d suggest using a picture glance or a glance card within lovelace. Have a look into that - each button can call a script as well, so you could map that to your serial communication.

For volume (if you send the actual level via serial) you can use https://github.com/thomasloven/lovelace-slider-entity-row
If you just send vol+/vol- to your pi you could just use a button on your glance :slight_smile:

Very cool! Will test out and let everyone know.