I am trying to use the same.Tried Vera alert but with no sucess to get pic from Foscam 9818W. Tried the code you wrote but i am getting lua error in it. Can you give proper code you used.
Thanks
[quote=“vinicius.vbf, post:8, topic:171076”]I just created this luup script to do it - attach a picture from an IP camera registered as a device on Vera. Now you only have to create a scene with this luup script and setup the desired triggers.
I’m using SMTP2Go as a free SMTP server (20 free e-mails per day). There you can setup an e-mail address that doesn’t need to authenticate to send the e-mails via SMTP, which is required by this code.
This is the raw code:
local veraIP = "<Vera IP>" -- Please let me know if there is an automagic way to get it.
local cameraID = 45 -- The IP camera device ID on Vera.
local ltn12 = require("ltn12")
local mime = require("mime")
local smtp = require("socket.smtp")
local result, content = luup.inet.wget("http://" .. veraIP .. ":3480/data_request?id=request_image&cam=" .. cameraID)
local attachment = ltn12.source.chain(
ltn12.source.string(content),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
local source = smtp.message({
headers = {
from = "Vera <sender@domain.com>",
to = "Recipient <recipient@gmail.com>",
subject = "Here is a picure from your webcam"
},
body = {
preamble = "Hello Recipient, \r\n" ..
"This is your e-mail with a picture attached.",
[1] = {
headers = {
["content-type"] = 'image/jpeg; name="image.jpg"',
["content-disposition"] = 'attachment; filename="image.jpg"',
["content-description"] = 'Camera picture',
["content-transfer-encoding"] = "BASE64"
},
body = attachment
},
epilogue = "That's it folks! :)"
}
})
r, e = smtp.send{
from = "sender@domain.com",
rcpt = "recipient@gmail.com",
source = source,
server = "smtpserver.com",
port = 2525
}
Sources of information used when creating this code (leaving it here for future reference):
http://wiki.micasaverde.com/index.php/Luup_Requests
https://github.com/diegonehab/luasocket/blob/master/etc/get.lua
http://wiki.micasaverde.com/index.php/Luup_Scenes_Events
http://forum.micasaverde.com/index.php/topic,3662.msg17918.html
http://forum.micasaverde.com/index.php/topic,24018.0.html
http://w3.impa.br/~diego/software/luasocket/old/luasocket-2.0-beta/smtp.html[/quote]