HTTP Request to power down Raspberry PI

Raspberry Pi related support

HTTP Request to power down Raspberry PI

Postby ctownj30 » 05 Aug 2016, 13:10

Is there an HTTP request I can make that will turn of the RPi using the "Power Down" feature in the Rune UI?

I want to trigger a power down using my home automation system (which will wait a minute, then remove power from the PI). My automation system can make HTTP requests so this seems like an easy way to do it.

Dug around the UI HTML but could not find it.

(before anyone says "why would you want to shut the PI down": the system is in a rarely used vacation home that is prone to power outages - I keep losing high quality SD cards and hoping this helps).

thanks - djm
ctownj30
 
Posts: 2
Joined: 07 Nov 2015, 14:49

Re: HTTP Request to power down Raspberry PI

Postby deenski » 06 Aug 2016, 16:30

Try following the directions here: http://raspberrywebserver.com/cgiscript ... ython.html

And instead of a hello world program, use this:

Code: Select all
#!/usr/bin/env python2
import subprocess
print "Content-type: text/html\n\n"
print "<h1>Shutting Down</h1>"
subprocess.call(['shutdown -h now'])


save it as /usr/lib/cgi-bin/shutdown.py

then:
Code: Select all
sudo chmod +x /usr/lib/cgi-bin/shutdown.py


I can't be 100% sure this would work, but after a reboot you should be able to navigate to:

Code: Select all
http://runeaudio/cgi-bin/shutdown.py


and when you do, it should shutdown... I think... or break a bunch of stuff... IDK... Good luck, and let me know if it works!
deenski
 
Posts: 10
Joined: 23 Jul 2016, 16:47

Re: HTTP Request to power down Raspberry PI

Postby hondagx35 » 06 Aug 2016, 17:50

Hi ctownj30,

Is there an HTTP request I can make that will turn of the RPi using the "Power Down" feature in the Rune UI?

Yes, the UI sends a post request to "http://your-ip/settings with
name = syscmd and value = poweroff to shutdown
or
name = syscmd and value = poweroff to reboot to reboot your device

http-post.png
http-post.png (55.24 KiB) Viewed 2277 times


Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: HTTP Request to power down Raspberry PI

Postby PetitMalin » 30 Jun 2020, 14:07

hondagx35 wrote:Hi ctownj30,

Is there an HTTP request I can make that will turn of the RPi using the "Power Down" feature in the Rune UI?

Yes, the UI sends a post request to "http://your-ip/settings with
name = syscmd and value = poweroff to shutdown
or
name = syscmd and value = poweroff to reboot to reboot your device

http-post.png


Frank


Hi Frank,

Does it still work, with a version 0.5 ?

Because i try to send :
Code: Select all
http://IP/syscmd-poweroff

or
Code: Select all
http://runeaudio/syscmd-poweroff


I have an error "Bad request"

Thank's in advance
Nop
PetitMalin
 
Posts: 2
Joined: 30 Jun 2020, 13:53
Location: Alsace

Re: HTTP Request to power down Raspberry PI

Postby hondagx35 » 30 Jun 2020, 22:24

Hi,

an HTTP POST request cannot be sent by using just an URL. (Except for the special case that there are no form fields and that the server doesn't care about the Content-type header.)

What is your intention?

Frank
User avatar
hondagx35
 
Posts: 3042
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: HTTP Request to power down Raspberry PI

Postby PetitMalin » 01 Jul 2020, 08:52

Hi Frank,

Just to integrate it into my home automation.

Before I used on my Synology LMS as a server and PiCorePlayer for my 5 Raspeberrys.
Now on my Syno Audio Station and Rune Audio (Audio Station because GoogleMusic will disappear)

The concept:
For the ignition of a Rasp: A wireless switch (Zigbee protocol) sends a signal to the Jeedom server which, through a script, switches "On" a SonOff switch (modified in ESP8266)for power "On" which starts the Rasp Player. (This part works, autoplay activated in Rune Audio)
In Jeedom a virtual state to toggle "On" (To know if the Rasp in On or OFF in the script)

In Jeedom possibility to do Play, Stop, Next, Previous, Shuffle, Volume UP and Volume Down in virtual command

Image

For the extinction the same button (wireless switch)
The script check if the Rasp is On or Off
And here i need to post a shutdown command (Hence my question)
A ping request verifies the extinction of the Rasp
Toggle the virtual state to "Off"
After that the script turns off SonOff to cut the power

Thank's for your interest, If you have any question...
Nop
PetitMalin
 
Posts: 2
Joined: 30 Jun 2020, 13:53
Location: Alsace

support RuneAudio Donate with PayPal


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 15 guests