[Plugin Dev Question] Intercept Volume change?

Hi Folks,

is there any possibility to intercept a volume change via plugin?
I would like to trigger an event in a plugin everytime the volume changed.

Thanks a lot & best regards!

I expect this question comes from turning off you DAC and not your rPi?

You can experiment using Volumio CLi commands or using the Socket.io .
Using the socket.io, you can trigger this only when playing.

volumio status

and monitor the tags:

"volume": 100,
"disableVolumeControl": true,

Set some guards on them like:

if volume > 20 then
volumio stop 

But then you run into other issues if you want to increase the volume by hand.

Hi Wheaten,

the problem with turning off the DAC has been solved with a little plugin.
My next goal is to find a solution to control the volume of the DAC via Volumio.
As the ADI-2 DAC cannot be controlled via USB, one possible way could be to control its volume via IR. But to accomplish that, I need a possibility to trigger some actions with a volume change in Volumio…

Thanks a lot!

I could check the volume every X seconds via socket.io, but that may not be very performant.
Thats why I am looking for a kind of trigger or event.
As I am very new to Volumio Plugins, I am not aware if this is possible.

To my understanding you’re only interested in this when Volumio is playing.
So monitoring Volumio via status change, limits the amount of processing time, as Volumio calls instead of polling. See:

1 Like

In FusionDsp, Loudness is adjusted when volume changes. It uses socket.io for this.
Check the code…

1 Like

If you just want volume control, via IR, there is already a plugin for that.
Which can be controlled by almost every IR you have.
(If it’s not in the list yet you need to create your own lircd.conf and lircrc.)

prog = irexec
button = Volume-Up
config = /usr/local/bin/volumio volume plus

prog = irexec
button = Volume-Down
config = /usr/local/bin/volumio volume minus

Well, I would want it the other way round.
So if a volume change on Volumio happens → send an IR-Command out to the DAC. So it may be possible to remote-control the volume of the DAC an keep Volumio and DAC volume in sync.
So basically, I need an IR-Sender to be controlled via Plugin.

That can also be done via lirc, but that need to be programmed.
Not fully understand the “why?” to control the volume on 2 places.
I would simply let Volumio control the volume and leave the DAC full open.

What your saying is I set Volumio to 10, set the dac to 10 leaving the final signal to 1?
( (Device A * Device B) / 100)

My DAC does not support hardware volume control and I am trying to find a solution to use the possibility of the hardware mixer (which is supported by the RME ADI-2 DAC) without losing the possibility to control the volume via Volumio…

When I set volume control to “Hardware” in Volumio, I still can adjust the volume, but is has no effect. So my goal is to send IR-Commands to the DAC to control the volume when the volume in Volumio has changed.

Just a stupid idea, but maybe it could work…

Aha, I get it.
Missed the part that Volumio lowers the volume, but the DAC is not responding.
So the volume output of Volumio is steady at 100 received by the DAC.

Then this “stupid” idea, might do the trick.

1 Like

Have a look at my repo: https://github.com/charliesjc/denonavrvolume

I began working on something to update the volume on my Denon Receiver a while back. It does work but it’s a bit messy and I haven’t looked at it again. You may find what you need in there.

1 Like

It worked :wink:
But despite my first thoughts, I used a little Arduino Nano to control the IR-Signals, so I do not have to mess around with LIRC and it helps to keep the overhead in Volumio as small as possible.
So now, the Nano is connected to the Pi via USB and my Plugin tells the Nano to send IR-Signals to control the volume of the RME Adi DAC-2 everytime a change in Volume is pushed out. Would say, it is a quite “dirty” solution, but it works.
This should also work for all kind of DACs which support IR-Control.

1 Like

Hi @MichaelE

Thanks for giving the feedback.
Good to hear you have a working solution for your issue!