Author Topic: Webcam Dropbox Uploader - a plugin to store images to dropbox  (Read 64661 times)

Offline martin12345

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +46/-3
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #15 on: September 14, 2013, 03:18:59 pm »
This is a fantastic App.  Thank you!!  I've loaded it into my UI5, and I've gotten it hooked up to my DropBox, and its uploading files.  But the files are 1K and they do not open. The Viewer says the files may be damaged or unsupported.

My camera is a FosCam that I bought from the MiCasaVerde site. 

I'm also trying to get a Generic IP dome camera connected.  so I'll want those stills to be uploaded to drop box as well.

Help?

thanks again!!
I am beginning to suspect that some of the cameras may behave differently to mine, so I have submitted a new version which gets the images in a different way. As soon as MCV approve it, you should get the new version which will hopefully solve this issue.

Martin

Offline martin12345

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +46/-3
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #16 on: September 14, 2013, 03:22:00 pm »
After installing and configuring I get a LUA startup error
You did save your settings didn't you? Can you look in the logs to see what error?

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +2/-0
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #17 on: September 14, 2013, 03:25:22 pm »
See above, just changed my post
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user

Offline martin12345

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +46/-3
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #18 on: September 14, 2013, 03:54:22 pm »
See above, just changed my post
That looks like the same error that a-lurker got. I really wish the log put line numbers for the exceptions, but they don't. Anyway, hopefully the new version will resolve that.

Martin

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +2/-0
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #19 on: September 14, 2013, 03:55:15 pm »
Can you addth files, so i can test them?
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user

Offline martin12345

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +46/-3
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #20 on: September 14, 2013, 03:59:12 pm »
Can you addth files, so i can test them?

I can add you as a beta tester if you PM me your username and e-mail address.

Martin

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +41/-7
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #21 on: September 14, 2013, 07:06:02 pm »
@martin12345

Had another look at this - I have a camera device that I have been using for testing. Currently it had an invalid camera URL. So I changed it to a functional one, so now the dropbox plugin works. It looks like this bit of the code assumes that "downloadUrl" should be OK, when in fact for my camera device it wasn't. Probably just need to check the return status and scribble something in the log, if it fails:

Code: [Select]
    local tempfile = ltn12.sink.file(io.open('/tmp/tempimage.jpg', 'wb'))
    http.request {
      url = downloadUrl;
      sink = tempfile;
    }

« Last Edit: September 14, 2013, 07:29:15 pm by a-lurker »

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +41/-7
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #22 on: September 14, 2013, 09:55:39 pm »
Another slight problem - "GetLuaInterface can't find device type":

Code: [Select]
50 09/15/13 10:56:19.030 luup_log:87: Dropbox file for webcam 29 sent successfully <0x2f131680>
50 09/15/13 10:56:19.031 luup_log:87: sending device 66 images to Dropbox 87 <0x2f131680>
50 09/15/13 10:56:24.527 luup_log:87: Dropbox file for webcam 66 sent successfully <0x2f131680>
01 09/15/13 10:56:24.528 GetLuaInterface can't find device type: 4/0x11b63d8 str: 87 <0x2f131680>
01 09/15/13 10:56:24.528 luup_variable_get interface 0x11b6188 args 3 <0x2f131680>
50 09/15/13 10:56:24.528 luup_log:87: Dropbox update frequency= 10 minutes

In this function there is some mix up with numbers versus strings: "update_frequency" is loaded with either a string or a number and I think luup.call_delay expects "dropboxNumber" to be a string?

Code: [Select]
     function sendImagesLoop(lul_data)
     
       send_all_images_to_dropbox(lul_data)
       local update_frequency=luup.variable_get("S_WebcamDropboxUploaderSettings1.xml","SendFrequency",lul_data) or 10
       luup.log("Dropbox update frequency= "..update_frequency.." minutes")
       update_frequency=update_frequency*60
       local dropboxNumber=tonumber(lul_data)
       if(update_frequency>0) then
         luup.call_delay('sendImagesLoop',update_frequency,dropboxNumber,true)
       end
     end

Offline martin12345

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +46/-3
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #23 on: September 15, 2013, 05:51:42 am »
Thanks for your analysis a-lurker. Glad you got it working when setting the webcam URL differently. I'm changing the next version so it should be less sensitive to that sort of problem.

With the other errors, you are right that the error message is to do with types. It's not that luup.call_delay expects a string though - lua does that conversion automatically. The problem is that luup.variable_get expects a number for the device. I wish they would be consistent about when you pass a string and when you pass a number, but I'll change that in a future version too.

Thanks

Martin

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +41/-7
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #24 on: September 15, 2013, 06:49:59 pm »
@martin12345

This plugin is a great idea - I really like it.

I was interested when you said "uup.variable_get expects a number for the device". It seemed to me this may be the case but the documentation refuted that idea:

http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_variable_get

It states the device number can be a string or a number. I tried a few tests and you are right; it must be a number. A string fails, so the documentation is incorrect.

EDIT: if it's a string it must be a udn, not the device number as a string.

The lug_startup function always get's a number, so I couldn't figure out how it was becoming a string. Turns out that these delays change "dropboxNumber" to a string:

luup.call_delay('removeOldFilesLoop',86400,dropboxNumber,true)
luup.call_delay('sendImagesLoop',update_frequency,dropboxNumber,true)

If you run this code in the Test Luup code" area - the log shows that testVar is a string, although the delay was called with a number:

Code: [Select]
function testing(testVar)

    luup.log('DELAY ENTERED')
    local theType = type(testVar)
    luup.log('type is: '..theType)
    luup.log(testVar)

end

luup.log('STARTING DELAY')
luup.call_delay('testing',3,256,true)
return true

If  the very first action of these two functions was:
lul_data=tonumber(lul_data)
and that could eliminate the need for any other type conversions elsewhere.

Thanks once again for your efforts on this plugin.
« Last Edit: September 15, 2013, 08:16:41 pm by a-lurker »

Offline RichardTSchaefer

  • Master Member
  • *******
  • Posts: 9820
  • Karma: +742/-136
    • RTS Services Plugins
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #25 on: September 15, 2013, 07:16:13 pm »
If you pass a string ... it is interpreted as a udn.
See the luup.variable_set for better documentation.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 760
  • Karma: +41/-7
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #26 on: September 15, 2013, 07:47:55 pm »
Thanks Richard - that now makes sense to me - the documentation is correct but my reading of it was in error. So as an example where "SendFrequency" = 8:

Code: [Select]
local update_frequency = luup.variable_get("S_WebcamDropboxUploaderSettings1.xml","SendFrequency",87)
local theType = type(update_frequency)
luup.log('1 type is: '..theType)
luup.log(update_frequency)

local update_frequency = luup.variable_get("S_WebcamDropboxUploaderSettings1.xml","SendFrequency","87")
local theType = type(update_frequency)
luup.log('2 type is: '..theType)
luup.log(update_frequency)

local update_frequency = luup.variable_get("S_WebcamDropboxUploaderSettings1.xml","SendFrequency","uuid:4d494342-5342-5645-0057-000001c9d682")
local theType = type(update_frequency)
luup.log('3 type is: '..theType)
luup.log(update_frequency)

return true

Running the above gives this in the log:

Code: [Select]
50 09/16/13 9:37:48.635 luup_log:0: 1 type is: string <0x2ff92680>
50 09/16/13 9:37:48.636 luup_log:0: 8 <0x2ff92680>

01 09/16/13 9:37:48.636 GetLuaInterface can't find device type: 4/0x955fa8 str: 87 <0x2ff92680>
01 09/16/13 9:37:48.636 luup_variable_get interface 0x947da0 args 3 <0x2ff92680>
50 09/16/13 9:37:48.636 luup_log:0: 2 type is: nil <0x2ff92680>
50 09/16/13 9:37:48.637 luup_log:0: (null) <0x2ff92680>

50 09/16/13 9:37:48.637 luup_log:0: 3 type is: string <0x2ff92680>
50 09/16/13 9:37:48.637 luup_log:0: 8

The first test has the device number as a number and works as expected:
The second test has the device number as a string and fails:
The third test has the device number as a string but the string must be the Unique Device Number (UDN) and works as expected:

Offline jtmoore

  • Full Member
  • ***
  • Posts: 171
  • Karma: +2/-1
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #27 on: September 18, 2013, 12:09:17 pm »
Hi. I love this plugin concept, and look forward to making it take a picture when someone presses by doorbell.

I have a Foscam camera. I don't know if the way the URL is built differently than others. All my jpg files in Dropbox apprear to be zero byte  :(


My device properties have separate device parameter values such as:
ip= 192.168.x.xxx
URL= snapshot.cgi?size=640x480&quality=4
username= admin
(I haven't got a password defined, so password is blank).

I did try building the URL as per http://{ip}{URL} in a browser. After entering username and password, I do see the camera image. I was unsuccessful using the format http://{user}:{pass}@{ip}{URL}  (possibly due to the blank password?)

Will the updated version of the plugin support the Forcam camera please? If so, is that die to be released soon? Is there any work round or setting I can change to make it work for me? Thank you.
jtmoore

Offline martin12345

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +46/-3
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #28 on: September 18, 2013, 12:14:19 pm »
I submitted a new version at the weekend which should solve your issue. I'm still waiting for that to be approved my MCV.

However, if you want to get it running sooner, I suggest adding a slash at the start of the URL, i.e. make it /snapshot.cgi?size=640x480&quality=4, and put in a dummy password, e.g. admin. I suspect it will work fine then.

Martin

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 443
  • Karma: +2/-0
Re: Webcam Dropbox Uploader - a plugin to store images to dropbox
« Reply #29 on: September 18, 2013, 01:45:19 pm »
The new version works brilliant for the Foscam, I already have the new version and it is great. I setup a scene which sends a pic whenever motion is detected
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user