openLuup: Cameras

No luck - this looks wrong: “luup_log:2: no image attachments found”

2018-03-28 19:42:19.777 openLuup.smtp:: SMTP new client connection from 192.168.1.202: tcp{client}: 0x1e73ca8 2018-03-28 19:42:19.777 openLuup.smtp:: SEND: 220 (openLuup.smtp v18.3.28) [192.168.1.212] Service ready 2018-03-28 19:42:19.783 openLuup.smtp:: EHLO localhost 2018-03-28 19:42:19.783 openLuup.smtp:: SEND: 250 AUTH LOGIN 2018-03-28 19:42:19.787 openLuup.smtp:: AUTH LOGIN 2018-03-28 19:42:19.787 openLuup.smtp:: SEND: 334 VXNlciBOYW1lAA== 2018-03-28 19:42:19.790 openLuup.smtp:: anNzY2htaXR6 2018-03-28 19:42:19.790 openLuup.smtp:: SEND: 334 UGFzc3dvcmQA 2018-03-28 19:42:19.793 openLuup.smtp:: dHJ3OHJhaW4k 2018-03-28 19:42:19.793 openLuup.smtp:: SEND: 235 Authentication successful 2018-03-28 19:42:19.798 openLuup.smtp:: MAIL FROM: <Street@openLuup.local> 2018-03-28 19:42:19.798 openLuup.smtp:: SEND: 250 OK 2018-03-28 19:42:19.802 openLuup.smtp:: RCPT TO: <images@openLuup.local> 2018-03-28 19:42:19.802 openLuup.smtp:: SEND: 250 OK 2018-03-28 19:42:19.805 openLuup.smtp:: RCPT TO: <openLuup@openLuup.local> 2018-03-28 19:42:19.805 openLuup.smtp:: SEND: 250 OK 2018-03-28 19:42:19.808 openLuup.smtp:: DATA 2018-03-28 19:42:19.808 openLuup.smtp:: SEND: 354 Start mail input; end with <CRLF>.<CRLF> 2018-03-28 19:42:19.924 openLuup.smtp:: SEND: 250 OK 2018-03-28 19:42:19.925 openLuup.smtp:: Deliver Mail: 2018-03-28 19:42:19.925 openLuup.smtp:: Data lines: 4145 2018-03-28 19:42:19.925 openLuup.smtp:: Sender: Street@openLuup.local 2018-03-28 19:42:19.925 openLuup.smtp:: Mail Delivery job 2018-03-28 19:42:19.925 openLuup.smtp:: Recipient #1 images@openLuup.local 2018-03-28 19:42:19.925 openLuup.smtp:: EMAIL delivery to handler for: images@openLuup.local 2018-03-28 19:42:19.950 luup_log:2: no image attachments found 2018-03-28 19:42:19.950 openLuup.smtp:: Recipient #2 openLuup@openLuup.local 2018-03-28 19:42:19.950 openLuup.smtp:: EMAIL delivery to handler for: openLuup@openLuup.local 2018-03-28 19:42:19.951 openLuup.smtp:: IP listener 192.168.1.202 2018-03-28 19:42:19.951 openLuup.smtp:: EMAIL delivery to handler for: 192.168.1.202

OK. Think this is all sorted in development commit 18.3.31.

Well, it wasn’t, but it is now thanks to @jswim788’s keen eyes.

Fixed (I really hope) in development commit 18.4.2

This is working fairly well for me now. Thanks, akbooer!

One note for anyone else trying this: pay attention to the last quoted sentence below. I mistakenly assumed the actions would be on the camera itself, but I reread the sentence and sure enough, they are on the openLuup plugin. So don’t get lost looking for them on the camera - they are not there!

@bwillette

Following on from the discussion here: Camera - No authentication information being passed to wget for images

I’ve taken a look at this and done some refactoring, including adding [tt]/data_request?id=lu_archive_video[/tt], which I had previously not implemented. However, the problem that I hit is that every camera has its own syntax for the URL parameters, including username and password. For example, my Foscam needs a line such as:

/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=yyy

So I’m assuming that, at least for the camera you are using, the authorization is done in the HTTP request headers and not with URL parameters.

There’s not really any problem in implementing this, and I haven’t yet tried it with my own camera, but I thought I should check before proceeding.

I can say that the Amcrest camera I have wants authorization in the HTTP headers (digest authorization). I use something like this with curl to get the image:

curl --digest -u user:pass http://w.x.y.z/cgi-bin/snapshot.cgi?1

[quote=“akbooer, post:25, topic:198812”]@bwillette

Following on from the discussion here: Camera - No authentication information being passed to wget for images

So I’m assuming that, at least for the camera you are using, the authorization is done in the HTTP request headers and not with URL parameters.

There’s not really any problem in implementing this, and I haven’t yet tried it with my own camera, but I thought I should check before proceeding.[/quote]

Correct! Thanks Ak!

Just to be specific, you?d simply need to construct the camera url with [i]http://username:password@IP/URL[/i] to be successful.

Ah, standard HTTP request plaintext authorization. Not secure, but within LAN, so fine by me. I wonder if headers work too?

OK, I’ve implemented this request line authorization, but before I release it, can I just do a sanity check?

What are you expecting to be able to do?

At the moment the modifications construct the correct URL to allow the following requests to work:

[ul][li][tt]/data_request?id=request_image&cam=xxx[/tt][/li]
[li][tt]/data_request?id=archive_image&cam=xxx&format=1[/tt][/li]
[li][tt]/data_request?id=action&DeviceNum=xxx&serviceId=urn:micasaverde-com:serviceId:Camera1&action=ArchiveVideo&Format=1[/tt][/li][/ul]

…assuming the URL variable and the username and password attributes are defined correctly.

However, this won’t make any difference to AltUI and streaming video.

Does that meet your requirements?

Assuming AltUI uses one of these requests for rendering a cameras control panel pages (all I can tell currently is that your wget function gets called with the IP/URL pattern eventually), and/or this is what?s used when I trigger a request to capture a snapshot, we should be good! Thanks again.

As mentioned in the earlier thread, AltUI uses the DirectStreamingURL for direct access to camera video, when available. However, if you know that wget is called for your setup, then this should do it.

and/or this is what?s used when I trigger a request to capture a snapshot, we should be good! Thanks again.

AFAIK, that’s the only way to get a snapshot. I’ll try and release this later today.

This change now in development release v18.4.10.

Indeed, with no VideoStreamingURL, AltUI uses [tt]/data_request?id=request_image&cam=xxx[/tt] to try and generate an image stream. This seems to have something of a detrimental effect on my browser, introducing some sort of (large) delay to the displayed image. This only happens when on the device’s control page. A thumbnail is not presented on the Devices page.

However, both [tt]request_image[/tt] and [tt]archive_video&format=1[/tt] (for a JPEG snapshot) work, with the image being written to the [tt]cmh-ludl/images/[/tt] folder.

With [tt]username[/tt] and [tt]password[/tt] as defined device attributes, the URL is suitably modified for these calls.

Works like a champ Ak! I can now see my camera snapshots on the control panel and they update just like UI7 does. Thanks a bunch!

Good to know! Thanks again for asking in the first place. This was something that I’ve wanted to get right for quite a time.

Would it be possible for the request_image to have the luup.inet.wget replaced by code that will switch to digest authentication if it gets the 401/www-authenticate response? Essentially, this code: lua-http-digest/http-digest.lua at master · catwell/lua-http-digest · GitHub I believe UI7 supports this for the same request (http://forum.micasaverde.com/index.php/topic,38406.msg326659.html#msg326659).

Thanks

I’ll take a look!

I was already thinking of including the MD5 hash algorithm for authentication in the POP3 server which is now part of openLuup.

If I can get the digest authentication coded correctly, then I think that the easiest thing would simply be to have an additional parameter to [tt]request_image[/tt] which specifies which authentication to use, rather than trying one and then another.

That sounds more efficient. But how does the user get the parameter into the request_image when AltUI is making the request? It would need to be in the camera device URL variable or some other variable that the GUI already accesses and passes on to the request_image? (As you can see I’m not very familiar with how the GUI’s such as AltUI do their work here.) Or is the idea to make this AltUI specific where it knows to look at an additional variable?

Good question, and there’s lots of ways.

At the moment, there is a global openLuup system attribute “openLuup.Server.WgetAuthorization”, which is, by default, set to “URL”. It may be set to “Header” to allow the use of headers instead. It would be an easy matter to extend the options to Digest on a request-by-request basis. But I’ll play with it and see.

I’ve just been reviewing MD5 Lua modules, and my iMac has the “md5” one, which is also available to install under Debian systems (RPi, etc.)

apt-get install lua-md5

so we’re halfway there.

My main impediment in testing, ATM, is the lack of hardware which needs this. An alternative is an appropriate website. Any suggestions* for what I could try?


Edit: * it looks as though this might do the trick: https://docs.postman-echo.com/