Updated Jan 14, 2026
If your Home Assistant uses the MQTT Integration,
this is a program
to make a discover-able MQTT remote control of
Alsa volume on a Raspberry Pi.
n the Raspberry Pi, the Python
program runs at boot.
It is initiated by systemd and runs as the desktop
user so it has access to the Alsa Mixer.
The MQTT discovery packet
creates an instance of a “light” entity with a brightness
of 0 to 100. Home Assistant
Create a folder where you want the program to reside.
Copy the three files ( rpi_vol_control.py,
rpi-volume.service.template and setup.py)
Make that your current
directory and run the python setup.py.
Setup will prompt you for a
username, a unique entity name for Home Assistant,
the IP address
or your MQTT broker and the location of the files. (filled in)
The
app must run as the desktop user so it can see the ALSA
controls..
Setup creates a service file in /etc/systemd/system.
It
executes, “sudo systemctl daemon-reload” to refresy
systemctl
It executes, “sudo systemctl enable
rpi-volume.service” enabling the service
Finally it
executes, “sudo systemctl start rpi-volume.service” to
start the service
Bring up the homeassistant settings and look for the
unique name you used.
The MQTT discovery in homeassistant should have found
and created the entity.
Suggestions branches or anything to improve this is welcome.