Code to start with for cURL (Netgear Readynas)

Hi,

I own a netgear readynas NAS, and I would like to make a device to power it off, since power on is supported thought WOL.

the curl code is pretty simple:
curl -u admin:password -k “h**ps://nas_ip_address_or_name/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set”

Can you tell me a working device with open code, so I could use it as template to start with?

Thank you in advance.

Alejandro

P.S. it is http, but since I don’t have enough posts, Nofollow was done by the forum.

The Popcorn hour plugin I made basically does nothing else then sending such http calls. Basically you’d probably only need to change the url’s and remove some buttons and code. The plugin does also read out some information like that, so you could probably also get the current states of the NAS.

In addition to that you could use some code from the wol plugin, then you could switch it on and off from one vera device.

http://forum.micasaverde.com/index.php/topic,9518.0.html

But some other more advanced users might have easier approaches, maybe waiting for their replies is worthwhile. I am for sure not the most advanced programmer in this forum.

@alx2k, what else are you thinking about doing with the readynas?

One option would be to monitor free disk space, another would be having the readynas scan for new media. I have one too (readynas nv+) and although mine never gets turned off I’m quite happy to help with code and/or testing.

I’'m not familiar with Lua, so first, I would like to do something that works, not very fanzy but usable.

I wasn’t thinking to make the plugin a monitor of the device really, but I guess that with time and some “google-ing” it could be done.

What I want at first is to poweroff the nas when there is no need for it to be powered on, mainly when leaving the house, and probably via some schedules during a 1am-6am period during week days. That way I could save 35w/hr according to readynas.com comparison chart, and since I am around 17 hours a day either out of home or asleep, that could save ±0,6kw/day.

In your case, readynas nv+ uses 55w/hr with 2 HDs connected.

I think you could just use this basic luup code in a scene:

luup.inet.wget(https://nas_ip_address_or_name/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set)

Then you could just run this scene to shutdown the nas. on of course you could also use triggers, schedules and so on…

somehow the user and password has to be included. maybe if you don use a sesure connection “http” instead of “https”. I’ll quickle google that, maybe I find something…

EDIT: Not googled but I think it should work like that:

luup.inet.wget(https://admin:password@nas_ip_address_or_name/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set)

Thanks for giving me a head start.

I’ll try to start with a luup code in a scene and then try modify it to be a device.

Also thanks for your code, It didn’t work, but I searched the wiki/forum and I saw this code

local IP_address = '' local username = '' local password = '' local timeout = 5

function move_up()
luup.inet.wget(‘http://’ … IP_address … ‘/decoder_control.cgi?command=0’, timeout, username, password)
end

– center the camera; takes some time, so we have to wait 2 minutes for the command to complete

luup.inet.wget(‘http://’ … IP_address … ‘/decoder_control.cgi?command=25’, timeout, username, password)

luup.call_delay(‘move_up’, 120)

So username and password have to be at the end of the line and not as user:pass@ipaddress, but it was a really clever approach!

Again, thanks for your help.

Alejandro

EDIT:

Working luup code for scene shutdown would be:

luup.inet.wget('https://NAS_IP/get_handler?PAGE=System&OUTER_TAB=tab_shutdown&INNER_TAB=NONE&shutdown_option1=1&command=poweroff&OPERATION=set', 5, 'user', 'password')

glad it worked! thanks for posting the final working solution.

okay - just found this and am super interested in gettiing it to work with my vera secure and readynas RN628X.
Anybody actually get it working?
I plugged user alx2k’s code (using my IP and frontview login) into Vera’s UI for Testing Luup code (Lua) window and it says it’s sending the code but it’s not powering down the NAS