Adjust Speaker Volume

I’ve been googling, and searching these forums and so far not found a solution. I am trying to adjust the volume on the host based on automation. I am using a USB speaker (Jabra Speak).

From Node-Red I thought this would be simple enough, but it cannot as amixer is not installed (and I have not found a work around - but I’m not saying it doesn’t exist).

So my next idea was to see what Rhasspy could do. It is capable of adjusting volume from the terminal - but I haven’t found any documentation how to adjust it using GUI or better yet API. Does this exist? Is anyone else adjusting their volume and if so HOW?

I have tried from Node-Red, Home Assistant, and Rhasspy - and I can’t figure out how to do it. Currently I have it in a cron job based on Time of Day. BUT for waf I need to make it adjust based on a binary door sensor (aka quiet down when babies are asleep).

Any/all help is appreciated!

Thanks!
DeadEnd

Followup… if there is no easy way - would it be feasible to make a feature request to have the volume control as an API endpoint, or is that a dumb idea?

Second idea - would it be possible to write a script as a slot program and use that to change the volume? So you can just create a sentence that contains the slot and call it with the API to adjust the volume?

Can’t you just install amixer?

I didn’t implement a volume control but as I’m using PulseAudio I would use pactl set-sink-volume <sink> <volume> on my host. I’d write a small Python script which listens for a “set volume”-intent on the MQTT bus and then calls pactl. You can probably exchange pactl with an amixer call.

I am just using amixer from node-red with an execute node. This is the easiest way aslong as you do not have node-red installed in a docker container. I use node-red for all of my intent handling and i created an intent for volume control.

So you’re using Node-RED in a container which doesn’t come with an amixer binary?

No i do not have node-red installed in a docker container.

Whoops sorry, I confused you with OP :man_facepalming: :smile:

So I was thinking/wondering if I created it as a script and put it in a slot if the script would work… I don’t know how the slot stuff works outside of creating lists, so I might give that a try.

Does anyone happen to know if this would work?

I tried from inside the container of node-red but apt and apt-get both didn’t appear to work… Not sure how to install from inside that container.

Are you talking about slot programs? Those scripts are only called during training and the result is saved in the graph. So this won’t work for your use-case.

The image is based on Alpine. Try apk.