Control Plugins via command line

Hello everyone,

I wonder if it is possible to start or stop a plugin via command line. I found a old post, but nobody answered there.

Any help would be appreciated.

I doubt that it is possible, as js runs server side.
In order to stop it you need to call onStop() or onStart() outside of it’s context, which will result in a “UnhandledPromiseRejectionWarning”

There is some information on internet

I know it’s not what you asked, but you can restart the whole service with ‘volumio vrestart’.
I use that when a beta plugin misbehaves and I don’t want to reboot.

I did have a thought about this but never followed it up. I’ll have a play this weekend. Thanks for reminding me!

I’ve had a look at this over the weekend, with some - but not much, success.

My thoughts were along the lines of…

In my plugin there is a function called ‘randomTracks’.
It is called when the ‘Random Tracks’ button is clicked in the plugin UI page.

It can also be called with the following script.
(Saved as ‘randomTracks’ and called with ‘node randomTracks’).

*// randomTracks*

*const io = require('/volumio/node_modules/socket.io-client');*

*const socket = io.connect('http://localhost:3000');*

*// Call the endpoint*

*const endPoint = { 'type':'plugin', 'endpoint': 'user_interface/randomizer', 'method': 'randomTracks' };*

*socket.emit('callMethod', endPoint);*

*// Sleep and exit.*

*setTimeout(() => process.exit(0), 400);*

My thinking was, that if it’s possible to call a plugin function from outside the plugin - can I do the same with the Volumio Plugin Manager?

The Plugin Manager file that I found (/volumio/app/pluginmanager) has three functions of interest;
startPlugin( category, name)
stopPlugin( category, name)
modifyPluginStatus( category, name, status)

I have tried calling these functions with a script similar to the above but with no success.

What would be really helpful is for someone with considerably more knowledge than me to;

a) Tell me that it’s impossible and save me struggling on.

b) Guide me to the UIConfig file for the plugin manager where I hope to find out just what goes on when the Plugin ‘On/Off’ button is clicked.

or
c) Give me the 'const endPoint = {'type… line that’s needed.

Many thanks in advance for any pointers.

There is some basic knowledge missing.

When your plugin “Randomizer” is started by Volumio, it will create a new object “Randomizer”. As long as you stay within this object you can control it. You’re now trying to control this object by creating a new object, outside this object. (yeah I know it’s getting a bit technical)

In plain, more common language.
Your neighbor has a specific car, like a Pagani Zonda (object).
Now imagine you have exactly the same car (object),
How likely will your neighbors car turn left, if you turn the wheel in your car?

Many thanks. Much time saved stumbling in the dark.

One last question…
I’ve just installed the Systeminfo plugin.
From the command line I can simulate the pressing of the plugin ‘Probe the System’ button and make the plugin run.
From the command line I can similarly make my plugin run.

Does this not mean that I have direct control of all my neighbour’s steering wheels?

Please don’t think that I’m trying to be clever, (not possible!) I’m just trying to get things straight in my head (not easy!) :smiley:

Then I am very curious what your call is?

[quote=“Old_Duffer, post:5, topic:58276”]

The same script as above but with;

`const endPoint = { ‘type’:‘plugin’, ‘endpoint’: ‘user_interface/Systeminfo’, ‘method’: 'getsysteminfo ’ };

yes, that’s why I was asking.

In the above case, you create a new object for “SystemInfo”.
Since SystemInfo only execute some bash commands (read has interaction with Volumio) it will return
results.
Your plugin (“randomise”) is interacting with the volumio environment and depends on Volumio’s response.
I hope this make sense.

ps: but please keep digging, it would be great for Peppy_Meter, to have a mechanical on/of button :crazy_face: