Page 1 of 1

impossible execution code LUA

Posted: Wednesday 21 February 2018 22:19
by figaro
Hello everyone
I start in the LUA coding, I have a contact to which I try a code it is to display a text in a virtual device, I simply copied the following code:

- Lighting Entry Light.
commandArray = {}
if (devicechanged ['tank']) then
commandArray [ 'tank'] = 'On'
print ('Ignition')
http: //192.168.X.XX: 8080 / json.htm type = command & param = udevice & idx = 4 & sValue ignition =
end
return commandArray

what is incredible is when I remove the line "http ........." I have the text "ignition" which displays in the domoticz log and when I place the line "http .. ......... "in the program I have the error:

2018-02-21 19: 53: 02.118 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_on.lua: /home/pi/domoticz/scripts/lua/script_device_on.lua:4: expected near ' / '

and I no longer have "ignition" in the Log


I have no null password, for the virtual sensor I chose as sensor type "TEXT"

if a charitable soul can help me, or if someone has already had this problem because I will crack
Thanks for your help

Re: impossible execution code LUA

Posted: Thursday 22 February 2018 8:56
by jvdz
figaro wrote: Wednesday 21 February 2018 22:19 http: //192.168.X.XX: 8080 / json.htm type = command & param = udevice & idx = 4 & sValue ignition =

n /home/pi/domoticz/scripts/lua/script_device_on.lua: /home/pi/domoticz/scripts/lua/script_device_on.lua:4: expected near ' / '
Is that first line the actual code? if so then it makes perfect sense you get an error as that is invalid syntax.
Look at UrlOpen in the EventSystem wiki page for the proper syntax. The end of the url also looks wrong by the way:
Something like this should be close:

Code: Select all

commandArray['OpenURL']='http://192.168.X.XX:8080/json.htm?type=command&param=udevice&idx=4&sValue=ignition'
The other thing to be careful with is creating an endless loop as your action acts on changes for device 'tank' which you then change yourself as well.

Jos

Re: impossible execution code LUA

Posted: Thursday 22 February 2018 12:16
by figaro
Hello
I thank you for this answer I will try, I think your explanation will be enough for it to work
Thank you again for your help