CURL to LUA

Moderator: leecollings

Post Reply
tms5d
Posts: 5
Joined: Saturday 09 January 2016 12:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

CURL to LUA

Post 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!!
User avatar
jvdz
Posts: 2333
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: CURL to LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
tms5d
Posts: 5
Joined: Saturday 09 January 2016 12:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: CURL to LUA

Post 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.
User avatar
jvdz
Posts: 2333
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: CURL to LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
tms5d
Posts: 5
Joined: Saturday 09 January 2016 12:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: CURL to LUA

Post by tms5d »

thanks, works! just curious, why can I not use "on action" to activate a script?
User avatar
jvdz
Posts: 2333
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: CURL to LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest