Background:
I’m using the excellent forked-daapd server for my multi-room audio setup. It has an mpd interface which makes it possible to control via the mpd component.
I want to have individual sliders for the volume in the different rooms and with the https://github.com/chme/python-mpd2/tree/outputvolume mpd library for python I’m able to control the volume and also get the volume of individual speakers like so
setvolume.py speaker-id volume
import sys
from mpd import MPDClient
client = MPDClient()
client.connect('localhost', 6600)
client.outputvolume(int(sys.argv[1]), int(sys.argv[2]))
client.disconnect()
and get the volume like so:
getvolume.py speaker-id
from mpd import MPDClient
import sys
client = MPDClient()
client.connect('localhost', 6600)
for output in client.outputs():
if output['outputid'] == sys.argv[1]:
print (output['outputvolume'])
client.disconnect()
I can of course call these python scripts from home-assistant and set and read the volume and convert it into a slider.
However there must be a more elegant way to achieve this. The worst is in this context that there is no command_line slider or something similar. So every update of the volume and the slider has to be done by automations right now…