UI7 Can't Launch / Ping / wget / post URL

Hello,

I am trying to create a custom LUUP code to trigger a URL which communicates with a program I built. The URL is “http://192.168.1.217:8080/?command=1”. Basically need Vera to ping that URL but it doesn’t seem to be working properly. If I manually input that URL into a web browser it works, but when testing in Vera it doesn’t. It says command sent, but nothing is happening.

It would be great to be able to create a virtual device and have 4 different switches each with different luup codes, but I would be thrilled if someone can help with either. I have tried basically everything I have found, including in the wiki. Some examples are

[code]local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local path = “http://192.168.1.217:8080/?command=1
local payload = [[ {“t_mode”:1,“t_heat”:61} ]]

local response_body = { }
local res, code, response_headers, status = http.request
{
url = path,
method = “POST”,
headers =
{
[“Content-Type”] = “application/json”,
[“Content-Length”] = payload:len()
},
source = ltn12.source.string(payload),
sink = ltn12.sink.table(response_body)
}[/code]

Also

[code] local http = require(“socket.http”)

– 5 Second timeout
http.TIMEOUT = 5

– The return parameters are in a different order from luup.inet.wget(…)
result, status = http.request(“http://192.168.1.217:8080/?command=1”, “run=run”)[/code]

And a lot of others.

What am I doing wrong? Can someone help, please?

Thanks!

You probably want a GET:

local status, result = luup.inet.wget('http://192.168.1.217:8080/?command=1',5)

The timeout is set to 5 in the above example - is that sufficient for your application? And do you need any authentication? The browser may do that for you automatically, but you’ll need to do explicitly here. You can log the status and result to see if anything unusual is happening.

[quote=“jswim788, post:2, topic:199196”]You probably want a GET:

local status, result = luup.inet.wget('http://192.168.1.217:8080/?command=1',5)

The timeout is set to 5 in the above example - is that sufficient for your application? And do you need any authentication? The browser may do that for you automatically, but you’ll need to do explicitly here. You can log the status and result to see if anything unusual is happening.[/quote]

Thank you. I have also tried this but it doesn’t work. There is no authentication required.

Try adding some logging to see what it is doing:

local status, result = luup.inet.wget('http://192.168.1.217:8080/?command=1',5) luup.log("status returned: " .. status .. ", result returned: " .. result)
(View the logs with this: http://vera_ip/cgi-bin/cmh/log.sh?Device=LuaUPnP where vera_ip is replaced appropriately. Note that AltUI has a very nice test code window where you can debug code and use print() statements.)

Can you tell if your application ever gets a connection?

Go into your vera web interface and go to:

User & Account Info → Security

In the latest UI7 they disabled things like wget by default.

[quote=“jswim788, post:4, topic:199196”]Try adding some logging to see what it is doing:

local status, result = luup.inet.wget('http://192.168.1.217:8080/?command=1',5) luup.log("status returned: " .. status .. ", result returned: " .. result)
(View the logs with this: http://vera_ip/cgi-bin/cmh/log.sh?Device=LuaUPnP where vera_ip is replaced appropriately. Note that AltUI has a very nice test code window where you can debug code and use print() statements.)

Can you tell if your application ever gets a connection?[/quote]

A ha! Permission error.

[code]1 05/24/18 12:15:36.656 FileUtils::ReadURL 0/resp:403 user: pass: size 301 http://192.168.1.217:8080/?command=1 response:

403 Forbidden

Forbidden

You don't have permission to access / on this server.


Apache/2.4.33 (Win32) PHP/5.6.35 Server at 192.168.1.217 Port 8080 <0x71673520>[/code]

Using WAMP on Windows.

Thank you SO much!

Configuring WAMP to accept all connections did the trick. Thanks again for your help!