PDA

View Full Version : network.get



Yoggi
September 3rd, 2016, 06:22 PM
Hi,

I am trying to use network.get from a file (located /opt/girder/lua/examples) and I get an error message but it runs fine from within a script in Girders “gui”. Am I missing to load a module? If so what is the name of the module?

Error:
Scripting / /opt/girder/lua/examples/fhem.lua:25: attempt to index global 'network' (a nil value)
stack traceback:

Script that I am trying to run:
network.get( "http://192.168.137.51:8083/fhem?cmd=set%20EnO_FEFE9698%20BI&XHR=1", function ( success, status, body )
if not success then
print("Sorry could not connect with server")
return
end
if status ~= 200 then
print("Sorry server returned", status)
return
end
print(body)
end, 3000)

Regards,

Joachim

Ron
September 3rd, 2016, 08:09 PM
at top of script add

local network = require('network')

Yoggi
September 4th, 2016, 04:28 AM
Hi Ron,

Thanks it worked!

I actually tried adding network to my script but I must have made some spelling error, I guess I must have been blind (spent a lot of time on this on). Thanks again!

Joachim