unmute issue

Hi there !

I am quite new with Volumio fiddling and I am in trouble with the mute / unmute method via the API.
I am using a combination of raspi-gpio (for the pull up/down conffig) and OnOff (for the interrupt convenience) libraries and I’d like my momentary push button to be able to mute / unmute Volumio. So far the mute call works, but the unmute doesn’t. I am not using any peculiar sound hat board on my Pi, but rather the audio jack output. Here is my code, called when the button is depressed :

new gpio.DigitalInput({ pin: 'GPIO' + GPIOS_RE_S1, pullResistor: gpio.PULL_UP });
var s1OnOff = new Gpio(GPIOS_RE_S1, 'in', 'rising', { debounceTimeout: 100 });
s1OnOff.setActiveLow(true);
s1OnOff.watch(function (err, value) {
    if(!muted) // muted is a local boolean var
    {
      console.log("mute");
      socket.emit('mute', '');
      muted = true;
    }
    else
    {
      console.log("unmute");
      socket.emit('unmute', '');
      muted = false;
    }
});

I checked the condition and it works well.
Any guess on this one ? Thanks !

Ok so the classic answer to myself.
I found out that it works but for some reason I have to wait about two seconds after the mute command is fired for the unmute one to works properly and vice versa. Not a big deal, but this is weird since it doesn’t happen with the web interface :open_mouth: