We have moved at community.getvera.com

Author Topic: openLuup: Cameras  (Read 3901 times)

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: openLuup: Cameras
« Reply #15 on: March 28, 2018, 12:46:10 am »
I get the child device to trip, but no images.  Log file below.  Doesn't seem like the debug is enabled?  VERSION : 2018.03.26 in console, but plugin page says 26b.

Code: [Select]
2018-03-27 21:37:57.095   openLuup.smtp:: SMTP new client connection from 192.168.1.202: tcp{client}: 0xad8650
2018-03-27 21:37:57.220   openLuup.smtp:: EMAIL delivered to handler for: images@openLuup.local
2018-03-27 21:37:57.222   openLuup.smtp:: EMAIL delivered to handler for: openLuup@openLuup.local
2018-03-27 21:37:57.231   luup.variable_set:: 23.urn:micasaverde-com:serviceId:SecuritySensor1.Tripped was: 0 now: 1 #hooks:0
2018-03-27 21:37:57.240   luup.variable_set:: 23.urn:micasaverde-com:serviceId:SecuritySensor1.LastTripped was: 1522208824 now: 1522211877 #hooks:0
2018-03-27 21:37:57.243   luup.variable_set:: 23.urn:micasaverde-com:serviceId:SecuritySensor1.ArmedTripped was: 0 now: 1 #hooks:0
2018-03-27 21:37:57.244   openLuup.smtp:: EMAIL delivered to handler for: 192.168.1.202
2018-03-27 21:37:57.245   openLuup.smtp:: SMTP QUIT received tcp{client}: 0xad8650

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #16 on: March 28, 2018, 01:18:01 am »
I get the child device to trip, but no images.  Log file below.  Doesn't seem like the debug is enabled?  VERSION : 2018.03.26 in console, but plugin page says 26b.

No, you're right.  Debug logging is not enabled.  You HAVE put the debug code into Lua Startup, and then reloaded, rather than just running this in Lua Test?

You seem to be sending to both openLuup@openLuup.local AND images@openLuup.local?  That's not a problem, but there's no point in doing it, just images would suffice, either will still trigger the motion sensor.  It's good to see that this, at least, is working.

Also, from the timing of the logs, it would suggest that the trigger email does not have any attached images.  Is there extra configuration in your camera which enables sending image attachment?  What exactly is the model?  I'll take a look at the manual online.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: openLuup: Cameras
« Reply #17 on: March 28, 2018, 09:42:33 am »
Yes, I cut and pasted the debug into the startup Lua and reloaded.  I can see it in the user_data.json, but perhaps I missed something.  I'll try again.  Yes, the camera sends an image - when I use my own email, I get an image.  I put part of the headers below from a sample message.  Perhaps this will help?  I'll check again on the debug setting.  The camera is an Amcrest IPM-721.

Code: [Select]
Received: by pinelakepi (sSMTP sendmail emulation); Tue, 27 Mar 2018 12:00:02 -0700
From: pi@raspberrypi
Date: Tue, 27 Mar 2018 12:00:02 -0700
Content-Type: multipart/mixed; boundary="1499846546-1522177202=:25280"
MIME-Version: 1.0
Subject: Street Image
To: <me@gmail.com>
X-Mailer: mail (GNU Mailutils 3.1.1)
X-CMAE-Envelope: MS4wfOKYd83FzLkvi0IPSYHjs8kJRfIjOEh6kisRmYZDc94t04plL30UeXobrlDR7McH8cFkoUDekC+Yc6dn8y05gqt4ksCXFfMQWnDflkhVfHiuGzxsIp5M Okf5uzwdT3cxMRkEhdXJ+Z+SS/GmhCOft2GTyx8JHaTFo7W3w+OpK9uk

--1499846546-1522177202=:25280
Content-ID: <20180327120002.25280@raspberrypi>
Content-Type: text/plain


--1499846546-1522177202=:25280
Content-ID: <20180327120002.25280.1@raspberrypi>
Content-Type: application/octet-stream; name=streetImage.jpg
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=streetImage.jpg


--1499846546-1522177202=:25280--

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #18 on: March 28, 2018, 10:04:09 am »
Yes, I cut and pasted the debug into the startup Lua and reloaded.  I can see it in the user_data.json, but perhaps I missed something.  I'll try again. 

This should definitely work... but only if you clicked the blue Submit button on the bottom of the page before reloading...

Quote
Yes, the camera sends an image - when I use my own email, I get an image.  I put part of the headers below from a sample message.  Perhaps this will help?

Good call! Yes, that helps a lot.  The problem is here:

Code: [Select]
Content-Type: application/octet-stream; name=streetImage.jpg
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=streetImage.jpg

...since the Content-Type is marked as "application", not image. 

I'll need to read up more about attachments to work around this, but it seems wrong to me ATM.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #19 on: March 28, 2018, 10:34:36 am »
OK, I have added Content-Type: application to the images mail handler.

Available in the latest development branch commit: v18.3.28
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: openLuup: Cameras
« Reply #20 on: March 28, 2018, 10:55:55 pm »
No luck - this looks wrong: "luup_log:2: no image attachments found"
Code: [Select]
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

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #21 on: March 31, 2018, 08:22:32 am »
OK.  Think this is all sorted in development  commit 18.3.31.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #22 on: April 02, 2018, 06:47:45 am »
Well, it wasn't, but it is now thanks to @jswim788's keen eyes.

Fixed (I really hope) in development commit 18.4.2
 
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: openLuup: Cameras
« Reply #23 on: April 02, 2018, 05:14:06 pm »
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!

This feature brings with it the possibility of generating quite a large number of files, in due course.  As a result I've found it helpful to include some sort of file retention policy implementation.  There are two new openLuup plugin actions:

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #24 on: April 09, 2018, 09:46:50 am »
@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 /data_request?id=lu_archive_video, 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:

Code: [Select]
/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.

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: openLuup: Cameras
« Reply #25 on: April 09, 2018, 12:43:33 pm »
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.

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:
Code: [Select]
curl --digest -u user:pass http://w.x.y.z/cgi-bin/snapshot.cgi?1

Offline bwillette

  • Sr. Newbie
  • *
  • Posts: 47
  • Karma: +3/-0
Re: openLuup: Cameras
« Reply #26 on: April 09, 2018, 08:17:06 pm »
@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.

Correct!  Thanks Ak!

Offline bwillette

  • Sr. Newbie
  • *
  • Posts: 47
  • Karma: +3/-0
Re: openLuup: Cameras
« Reply #27 on: April 10, 2018, 06:37:23 am »
Just to be specific, you?d simply need to construct the camera url with http://username:password@IP/URL to be successful.


Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #28 on: April 10, 2018, 06:51:24 am »
Ah, standard HTTP request plaintext authorization.  Not secure, but within LAN, so fine by me.  I wonder if headers work too?
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Cameras
« Reply #29 on: April 10, 2018, 07:49:42 am »
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:
  • /data_request?id=request_image&cam=xxx
  • /data_request?id=archive_image&cam=xxx&format=1
  • /data_request?id=action&DeviceNum=xxx&serviceId=urn:micasaverde-com:serviceId:Camera1&action=ArchiveVideo&Format=1
...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?
« Last Edit: April 10, 2018, 08:08:00 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.