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} ]]
– 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]
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.
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=“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]