Add Shutdown to REST API commands

I control Volumio playback, volume etc using the REST API functionality. Is it achievable to add another command that would initiate shutdown?

volumio.local/api/v1/commands/?cmd=shutdown

By shutdown I mean what in the Web UI is termed “Power Off”

Is there any news on this?
I would love to see this as well!

Please feel free to open up a PR over at GitHub - volumio/Volumio2: Volumio 2 - Audiophile Music Player
You probably want to take a look at system.js and add a call to commandRouter.shutdown()

That being said I am not super happy about having a shutdown call that can be called without any auth, but it’s a call that the core devs need to take :slight_smile:

Hi Gforce,

May i ask what is the use case for this necessity ?

br
Josef

Hi Josh,

I made a simple app as controller for volumio based on the REST api.
It’s just a shame that I still have to open the web page to shutdown

Can’t you use websocket API for the shutdown?

nope … no reboot, shutdown on cmd

You can – either via socket.io or just a normal web-socket with some wackiness…

The web socket has both shutdown and reboot – what do you mean?

gonna test is again … please hold… reboot, shutdown doesn’t do any of them with the api
it only paused my song nothing else…

No one is saying it is, which is why @Joni_Salminen asked if a web-socket wasn’t an option…

If you really want a command line option, check out the following.

But as Volumio uses socket.io, you will need to set a few more parameters to get it working through raw websockets…
But at that point, its easier to write few lines of python instead…

Of course, there is no shutdown or reboot endpoint in the REST api. But it is exposed in the websocket API, which is what me and Joni have been saying :wink:

REST API isn’t the same as the websocket API.

1 Like

I don’t really have much experience with these things
But how do you use volumio with normal websocket?

edit: At least, if I understand correctly that you could shutdown with that?

Yes you can.

Are you developing for what and in which language? Perhaps someone can assist more if we know some details.

It’s maybe less well-known, I am using Godot Engine and then exporting to Android and iOS

Isnt that game engine of some sort? perhaps this could help with your task

Does Volumio work with just websocket or only with socket.io?

You would have to look it up, it’s rather straightforward, given the limited use that is made of the socket in Volumio.

Hi Ash, I started searching around a bit, but to be honest, I don’t know what I’m looking for, where to start.
Could you perhaps point me in the right direction by explaining what you mean by parameters?
Which parameters, parameters of what, where are they defined/used?

This is the full description of the protocol - but since Volumio is just using simple JSON, it is just a few things that require implementation.

Essentially, connect to this endpoint and you should get a better idea :slight_smile:
This is a snippet of Rust for a simple get<> endpoint with no parameters.

   let (mut socket, response) = connect(
        Url::parse(format!("ws://{}:3000/socket.io/?EIO=3&transport=websocket", host).as_str())
            .unwrap(),
    )
    .expect("Can't connect");
   socket
        .write_message(Message::Text("42[\"getState\"]".into()))
        .unwrap();
   loop {
        let msg = socket.read_message().expect("Error reading message");
        println!("Received: {}", msg);
    }

Thank you very much!!!
With the help of your example I got it working now!

@GForce maybe for the others a how to and with what you did it?