plugin development questions

I just bougth a Raspdac Kit (AUDIOPHONICS I-Sabre V3 DAC ES9023 TCXO + Raspberry 3).
This kit have a power button using GPIO and an OLED device, so I’m trying to write a plugin to drive OLED and button correctly.

Question :

  • I need to add a callback when soft poweroff and soft reset are called ( because i need to write on GPIO pin). I actually did it using logger filter
      self.softShutdown = new Gpio(4, 'in');
      // Use loggin filters for soft reboot watcher
      self.logger.filters.push(function(level, msg, meta) {
            if (msg == 'Rebooting' || msg === 'Shutting Down') {
            return msg;

Is there a better solution to do it ? If not, do you plan to emit an event for potential listeners during reboot and shuting down function ?

I must say this is a really clever “hack”. Unfortunately we don’t have any event to signal shutdown or reboot.
But we can come up with one, maybe via websocket. What do you think?

Why not using a EventEmitter on CoreCommandRouter ?

Another newbie question (i’m a software programmer, but never code for node before)…
My plugin will use ‘onoff’ module.
Do I need to release this module (and its dependencies) on my plugin archive ?

Yes you need to include every node module in the zip file

Unfortunally, the hack is not working because my plugin have to do some things before the real reboot/shutdown …
What do you think about this :
During the shutdown (reboot), call a onVolumioShutdown (onVolumioReboot) method (synchronous) on every enabled plugin just before doing the shutdown (reboot)

CoreCommandRouter.prototype.shutdown   = function () {
       var self = this;

       // For all enabled plugin we try to call onVolumioShutdown function
       var catNames = self.pluginManager.getPluginCategories();
       for (var i = 0; i < catNames.length; i++) {
            var pluginCategory = catNames[i];
            var plugNames = self.getAllPlugNames(pluginCategory);
            for (var j = 0; j < plugNames.length; j++) {
                  var pluginName = plugNames[j];
                  if (self.pluginManager.isEnabled(pluginCategory, pluginName)) {
                        var thisInterface =, pluginCategory, pluginName);
                        if( typeof thisInterface.onVolumioShutdown === "function") {

       this.platformspecific.shutdown ();

Are you just willing to turn-off Volumio using your kit’s button?
I guess you can use GPIO Buttons plugin and set the shutdown action to the GPIO pin (4?) corresponding to your device button, no?

It has been merged :wink:

Yes noticed it a few days back.
Indeed theses new events are interesting for many scenario: great addition.
Was just curious about specific initial use-case, as turning-off by a button would not require this.
However publishing a “bail-out” message on a screen would definitely leverage such new events.

Yes, or for example when the device needs a specific GPIO to be set to 1 or 0 to phisically turn off the device…
There are many use cases… Not bad indeed!

BTW for this specific bit, there is a standard overlay just made for that: gpio-poweroff.
Nothing to program: just to be set accordingly in /boot/config.txt (see discussion here)

[code]Name: gpio-poweroff
Info: Drives a GPIO high or low on poweroff (including halt)
Load: dtoverlay=gpio-poweroff,=
Params: gpiopin GPIO for signalling (default 26)

    active_low              Set if the power control device requires a
                            high->low transition to trigger a power-down.
                            Note that this will require the support of a
                            custom dt-blob.bin to prevent a power-down
                            during the boot process, and that a reboot
                            will also cause the pin to go low.


Not exactly… but I need to set action on GPIO when user ask for a reboot or shutdown directly from Volumio.