A little coding help please

not a coder but just hacker… Trying to use presets with my veracams by utilizing manual scenes. I set the presets in the native controls going to the ip of the camera and they work in the native controls. I did research and came up with the following Luna code but can’t seem to make it work. Any assistance would be greatly appreciated.

local IP_address = “X.X.X.X”
local username = “admin”
local password = “XXXXXXXXX”
local timeout = “5”

luup.inet.wget(http://ip_address/decoder_control.cgi?command=33,username,password)

I cleaned up what you posted, hope this helps…

local http        	= require("socket.http")
local ip_address 	= "127.0.0.1"
local username 		= "admin"
local password 		= "password"

http.request("http://"..ip_address.."/decoder_control.cgi?command=33,"..username..","..password)

So this is where I am at still with no results. in UI7 can I use a scenes with a mannual trigger and just a Luup script? As I still can seem to get it to work.

local IP_address = “192.168.1.142”
local username = “admin”
local password = “Password”
local timeout = “5”

http.request(“http:80//”…ip_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

Couple of issues here. Here is what you’re using which deviates from what I provided. I’ll underline the issues.
http.request(“http:80//”…ip_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

[1] Case sensitivity … The two variables must match, otherwise I wouldn’t expect it to work. I’ll use what you posted.
local IP_address = “192.168.1.142”
http.request(“http:80//”…IP_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

[2] You might want to re-think that port location or in other words, simply drop it as it’s port 80 (default)…
http.request(“http://”…IP_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

[quote=“Dsitver, post:3, topic:182428”]So this is where I am at still with no results. in UI7 can I use a scenes with a mannual trigger and just a Luup script? As I still can seem to get it to work.

local IP_address = “192.168.1.142”
local username = “admin”
local password = “Password”
local timeout = “5”

http.request(“http:80//”…ip_address…“/decoder_control.cgi?command=33,”…username…“,”…password)[/quote]

I’m Looking at code trying to understand, My first question is Comand 33 the pre-set location. If so which location
If I have 5 pre-sets are they 33,34,35,36,37, I copied the code and made A scene if i run the scene is say sucess but camera is not moving. thanks for any help here,

Using your original code ‘http://ip_address/decoder_control.cgi?command=33,username,password’. If you put in the correct values for the IP-address, user name and password and paste it in a browser window and then hit the enter key. Does the camera move? Do your get an OK or similar or do you get an error message?

If the camera moves, then your URL code is correct and I’m at a loss why the Vera LUA code doesn’t work.

If the camera doesn’t move and you get an error, it means your http request/code is incorrect and you’ll have to experiment in a browser until you can get it to move the camera as desired and then convert it to the type of code (watch the case semsitivity!) CudaNet created for you.

I was able to copy statement to web browser and camera moves this is a great help. At least I have a test point now I just need to figure out what I don’t know about the code.

The top 4 line I’m telling ip address = my camera’s ip login = name (insert name) and so on.

the bottom code is unchanged

http.request(“http:80//”…ip_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

the process inserts the info from the top for lines.

Again Thanks for your help.

The URL that worked for you: did that include the port address 80? Looks like you have the port address in your code in the incorrect order.

Just drop the :80 … it’s the default port for HTTP anyway.

''http://"..ip_addres..

Sorry I have been away so long working for Fedex. Holiday are so busy.
I can move camera in browser no problem. When Scene runs no errors get success under scene but camera not moving.

this is my code

local http = require(“socket.http”)
local ip_address = “192.168.0.000”
local username = “admin”
local password = “xxxxxx”
local timeout = “5”

http.request (“http://”…ip_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

A couple of suggestions:

Presumably you are setting your actual IP address in the variable ip_address? You don’t need to keep it a secret.

You should set the timeout for the http request otherwise it could crash your Vera if the target does not respond.

Send the response from the http request to the log so you can see if there are any errors returned.

[code]local http = require(“socket.http”)
local ip_address = “192.168.0.000”
local username = “admin”
local password = “xxxxxx”
local timeout = “5” – This does not do anything so could be removed

http.TIMEOUT = 5
local response, status = http.request (“http://”…ip_address…“/decoder_control.cgi?command=33,”…username…“,”…password)

if response == nil then
luup.log("http request error: " … status)
else
luup.log("http request response: " … response)
end
[/code]

Is there somewhere I can see the log file. still not having any success with scene.

thanks

See Logs for various ways to view the log file. The InfoViewer plugin also has a good log viewer.

thanks for the quick response I have copied from log the following:

01/03/15 18:15:37.859 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x2dd9e680>
08 01/03/15 18:15:37.860 JobHandler_LuaUPnP::HandleActionRequest argument action=RunScene <0x2dd9e680>
08 01/03/15 18:15:37.860 JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=10 <0x2dd9e680>
08 01/03/15 18:15:37.860 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.6048287105235334 <0x2dd9e680>
08 01/03/15 18:15:37.861 Scene::RunScene running 10 preset_3 <0x2dd9e680>
50 01/03/15 18:15:37.881 luup_log:0: http request response: 401 Unauthorized

401 Unauthorized

Authorization required.
mini_httpd/1.19 19dec2003 <0x2dd9e680>

I wish I understood more of what this means log in problem to camera?

The camera is not liking the userid and/or password you are supplying it based on the log entries you posted. It could be that the camera expects and encrypted userid/password which is something Vera is not capable of supplying at this time. But that is only a guess based on experience as the logs are not detailed enough to be able to prove that.

Well I’m no closer to getting my vistacam pt to move. But I sure have learned alot a would like to thank everyone for there input. I’m not sure why if I can send the info from the browser the camera will move but if vera sends the info it wont. I would think that its the same info being sent.

Try taking the command that works in the browser and using it as a string in wget. So if the working command is:

http://192.168.1.123/decoder_control.cgi?command=33,<user>,<pswd>

Use it like this:

local status, resp = luup.inet.wget("http://192.168.1.123/decoder_control.cgi?command=33,<user>,<pswd>") luup.log("wget returned:"..status..":"..resp)

when i run the code you provided

local status, resp = luup.inet.wget(“http://192.168.1.123/decoder_control.cgi?command=33,,”) luup.log(“wget returned:”…status…“:”…resp)

I see the same error in the log

So I tried some different things this what i found. when i paste the code in my Google browser it returns ok and camera moves. when I paste the same code in foxfire it return a box to enter name and password.
if I don’t enter error 401 is return same as in log. So I think the Google browser is inserting the password because I click on the remember password box and in foxfire once i clicked on the same box it now moves camera. So my error is in the the user name and password part of script. When I move the camera with the browser I see nothing in the log.

OK, here’s something else to try then:

local status, resp = luup.inet.wget("http://192.168.1.123/decoder_control.cgi?command=33",5,"<user>","<pswd>") luup.log("wget returned:"..status..":"..resp)

This is sending the user and password fields separately to the URL. It may not help but it’s worth a try.

Otherwise you will need to find the correct way to encapsulate the user and password in the URL.

Another possibility:

local status, resp = luup.inet.wget("<user>:<pswd>@http://192.168.1.123/decoder_control.cgi?command=33") luup.log("wget returned:"..status..":"..resp)