impossible execution code LUA

Moderator: leecollings

Post Reply
figaro
Posts: 2
Joined: Wednesday 21 February 2018 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

impossible execution code LUA

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

Re: impossible execution code LUA

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
figaro
Posts: 2
Joined: Wednesday 21 February 2018 22:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: impossible execution code LUA

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest