wget html file works in "Test Luup code" and in scene but NOT in Startup.lua

I am trying to assemble a table with device en variable parameters. The difficult ones are “actions”. As I find them easily using “info viewer”, “info viewer page”, “Vera Invoke” displaying: " http://veraId/port_3480/data_request?id=lu_invoke&DeviceNum=44", I intended to read that data with following code:

vid = 44 local vURL ="http://veraip/port_3480/data_request?id=lu_invoke&DeviceNum=".. vid local vCode, vData = luup.inet.wget(vURL,5) luup.log("Return code: " .. vCode .. " Datatype: " .. type(vData))

If I use that code in “Test luup code” or in a scene it shows as inteded:
luup_log:0: Return code: 0 Datatype: string

Using the same function in startup.lua, I get:
luup_log:0: Return code: -1 Datatype: nil.
How can I get it to work also in startup? What could be happening?

The working version on a scene displays the first line of the document as:

How can I get the entire document in a string?

Thanks in advance!!

The startup code is run before any device startup code, so the device you’re trying to access cannot service its action call. Several ways around this, but one is to use luup.call_delay() to defer this call until after the dave startup is complete.

Thanks a lot akbooer, that got me continuing.

As I want this wget done before continuing the script, here is wath I did: simple!

repeat vCode, vData = luup.inet.wget(vURL) until vCode == 0

I’m actually quite surprised that what you have there worked, in that it is a rather tight loop, and could well delay a lot of the other startup activities. However, if it works for you, fine.