Page 1 of 1

CURL to LUA

Posted: Saturday 09 January 2016 12:50
by tms5d
Hi

I have several really simple CURL scripts, and have to translate them to LUA to run them from my RasPi. To be honest, I just can't figure out how to do that.

For example, I'm using this CURL-script to reboot my IP cam(s):

Code: Select all

curl -X PUT --user user:password http://192.168.0.18/system/reboot
I'd really appreciate some help translating this piece of code to LUA. This will help me to translate the other scripts myself.

Thanks!!

Re: CURL to LUA

Posted: Saturday 09 January 2016 13:25
by jvdz
I haven't tried it but guess it should be something like this:

Code: Select all

	commandArray['OpenURL']='http://user:[email protected]/system/reboot' 
Jos

Re: CURL to LUA

Posted: Saturday 09 January 2016 14:53
by tms5d
Thanks, trying to figure this one out:

I created the script:
Image

And attached the script to a virtual switch like this:
Image

and lo and behold ... nothing happens :) So I'm doing something wrong I guess?

Any kind of help would be greatly appreciated.

Re: CURL to LUA

Posted: Saturday 09 January 2016 15:36
by jvdz
Don't put the LUA script in the "On Action" but name it correctly as defined here: https://www.domoticz.com/wiki/Events
So rename the file to script_device_xxxxx.lua. All script_device_???.lua scripts are fired each time a device changes.

Jos

Re: CURL to LUA

Posted: Saturday 09 January 2016 17:32
by tms5d
thanks, works! just curious, why can I not use "on action" to activate a script?

Re: CURL to LUA

Posted: Saturday 09 January 2016 17:55
by jvdz
You can activate it like that, but as far as I know, the script will have to perform all tasks stand-alone with JSON call as no Arrays are passed not will returned commandArray() be processed by the Domoticz event system.

Jos