http post with Luup to communicate with my DVR

Hello, I just want to communicate with my DVR when a sensor is triggered with HTTP post method. No experience with web services :-[

http://MyDVRServer/adminSettings.html?action=RecordStart&camID=1

How to simply Luup this command?

Thanx

chris

Ok! As usual, I answer to myself, nad hope it helps other dummies: ;D

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://login:pswrd@ipserver/adminSettings.html?action=RecordStart&camID=1”, “run=run”)

hi

i’m trying to do this with zoneminder, change status of camera monitor to modect :

syntax is : Connect to Zoneminder cameras

my first camera is :
http://192.168.1.120/zm/index.php?view=watch&mid1
2nd:
http://192.168.1.120/zm/index.php?view=watch&mid2

after many examples, it’s not ok :

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.120/zm/index.php?view=watch&mid1&newFunction=Modect&newEnabled=1&user=xxxxxxxx&pass=xxxxxxxx”), “run=run”)

ECHEC code lua failed

version 3

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://login:password@192.168.1.120/zm/index.php?view=watch&mid1&newFunction=Modect&newEnabled=1”), “run=run”)

ECHEC code lua failed

do you have any ideas?

thanks

Two comments:
a) You probably don’t need the [tt]POST [/tt]body ([tt]“run=run”[/tt])
b) You have an extra end-parenthesis

Try this snippet (merged into your larger block, of course):

result, status = http.request("http://login:password@192.168.1.120/zm/index.php?view=watch&mid1&newFunction=Modect&newEnabled=1")

thanks

now code is ok but nothing change in zoneminder ::slight_smile:

It’s possible it doesn’t like that style of URL with the UN/PW encoded. Try something more like the snippet at the bottom of this:
LuaSocket: HTTP support

where the UN/PW is passed as an [encoded] parameter to the URL call.

Hello guessed,
with http.request, I’m limited to send commands to VLC. I’ve seen that there is a Telnet interface with VLC. Is it possible to send a Telnet command with Vera?
My objective would be when a sensor is triggered in Vera, send a command on my fitpc2 where I have VLC to start recording the stream. Now with http.request, I’m just able to start reading the stream.
On the fitpc2 where I have VLC, I have a local command-line that works. But I am unable to activate this “.bat” file in order to do what I want.
So with your experience, what is the best way to do that?

Thanks, chris

Chris,
I’m not familiar with VLC, but if there’s a Remote interface (“listener”) for commands then you can likely hookup Vera to talk to it. It would really depend upon what commands that remote interface directly exposes, and if it exposes them in a manner that’s accessible to Vera (a TCP “socket”)

It sounds like it’s already providing some sort of HTTP control/command interface but you’d need to read up on the specs to see if it has other interfaces, and what extra command (if any) they support that aren’t already exposed via the HTTP interface.

It would likely require a whole bunch of experimentation, and a lot of patience to get going. Not sure how your .BAT file ties into this though, unless VLC itself has some way to launch it via the interfaces your seeing.

Hello guessed,
thanks for taking time to answer. It sounds like VLC has different interfaces, like http, command-line and Telnet. With the command-line I’m able to do what I want, but only from the PC where the VLC is installed. With http.request, I’m able to launch a VLC stream from vera. But still not able to find the record option.

So one more question, is it possible to “Telnet” with a luup script from vera? If yes, I would investigate more, and be patient :wink:

chris

In Lua, its possible to open a regular Socket to anything, and speak whatever you want down it. When folks send clear text commands (not binary) down this Channel some refer to this as using Telnet protocol… somewhat of a misnomer, but we won’t go into that here.

An acid test for this is whether you can run a command like
telnet hostname port

Eg.telnet 192.168.33.24 5000

And get that to connect. The IP and port will need to be those provided by the application you’re attempting to connect to (like VLC)

Thanks!

What is funny is that the VLC Web Interface is written in Lua. And is OpenSource. So for a developper it could be a good challenge to do a VLC plugin! This plugin could have the basic following functionnalities:
Start recording
Stop recording
And this could be a nice solution to store the IP camera stream in our own NAS or PC, as this functionnality is not available now within Micasaverde. Storage will be only available on their servers, and will be an option.
chris

may be is it possible with ssh access ?

http://forum.micasaverde.com/index.php/topic,11663.msg84044.html#msg84044

with script .sh on ubuntu server? like

Mise en mode monitor des cameras

#!/bin/bash
/home/scripts/ZM_change_cam1_Monitor.sh > /dev/null 2>&1
/home/scripts/ZM_change_cam2_Monitor.sh > /dev/null 2>&1
/home/scripts/ZM_change_cam3_Monitor.sh > /dev/null 2>&1
etc...




contenu des scripts par caméra
ex: ZM_change_cam1_Monitor.sh

#!/bin/bash
curl -m 30 --connect-timeout 5 -f -k -s -L "192.168.1.120/zm/index.php?view=watch&mid1&newFunction=Modect&newEnabled=1"

with command : zmpkg.pl monitor on my zoneminder server, that change state my cam in monitor. i’m creating a state : surveillance and with this commande zmpkg.pl surveillance it’s ok
now i’m searching to do this with veralite by ssh

do you have any idea?

After some investigations, get the answer from VLC that due to security reasons, this command (start record and stop record with http requests) will not be available.

So I find a solution with ISpy Connect (freeware solution that supports http requests):
With this basic scene, triggered by a sensor, I can record on my fitpc2 (7Watts power only!) 30 seconds of video:

local http = require("socket.http") -- 5 Second timeout http.TIMEOUT = 5 result, status = http.request("http://login:password@myIP:PORT/record?otid=2&oid=0") luup.sleep(30000) result, status = http.request("http://login:password@myIP:PORT/recordstop?otid=2&oid=0")
:smiley: hope it helps someone.

chris

[quote=“chris66, post:13, topic:172590”]After some investigations, get the answer from VLC that due to security reasons, this command (start record and stop record with http requests) will not be available.

So I find a solution with ISpy Connect (freeware solution that supports http requests):
With this basic scene, triggered by a sensor, I can record on my fitpc2 (7Watts power only!) 30 seconds of video:

local http = require("socket.http") -- 5 Second timeout http.TIMEOUT = 5 result, status = http.request("http://login:password@myIP:PORT/record?otid=2&oid=0") luup.sleep(30000) result, status = http.request("http://login:password@myIP:PORT/recordstop?otid=2&oid=0")
:smiley: hope it helps someone.

chris[/quote]
Know this is an old post, but I am trying to get this to work on a VeraPlus with UI7 and my iSpy server.
Had to change the “otid” to “ot” for compliance to current iSpy connect syntex, but scene still refuses to run.
The http string works fine when issued from a web browser, but does not run in a scene.
Maybe the syntax has changed in Vera?

Sorry, still in UI5, now using BlueIris with this command line: luup.inet.wget(“http://myip:myport/admin?camera=CamNord&trigger&user=myusername&pw=mypassword”)

Hope it helps.