it is nice to be able to set the volume from a mediaplayer or tts but if your raspberry is set to zero or maximum then still it can be annoying.
if you configure your sound outside HA (like i do with appdaemon) then it is even more annoying.
so i created an app to set the volume from the raspberry itself.
first i made a input_slider:
rpivolume:
name: Volume from Raspberry
initial: 70
min: 0
max: 100
step: 5
and then the app:
class sound(appapi.AppDaemon):
def initialize(self):
self.listen_state(self.setrpivolume,"input_slider.rpivolume")
def setrpivolume(self, entity, attribute, old, new, kwargs):
volume = new
self.log("volume: " + volume[:-2])
cmd = ['amixer','cset','numid=1',volume[:-2] + '%']
with tempfile.TemporaryFile() as f:
subprocess.call(cmd, stdout=f, stderr=f)
f.seek(0)
output = f.read()
and all you now have to do is put this app in the appdaemon config and you can control your RPI volume.