Foscam Plugin - control/capture Foscam ip camera

Posted on
Mon Oct 01, 2012 2:09 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Foscam Plugin for Indigo

Hi folks, I'm working on an Indigo plugin to wrap and extend the web api for Foscam webcams. One of the actions I am adding to this plugin is the ability to send an email containing a capture from the camera. I am currently doing all the mail-sending manually using python's smtplib. I'd much prefer to use the provided indigo.server.sendEmailTo method so that I can leverage the built-in smtp settings instead of unnecessarily managing them in plugin preferences. The only pickle is that I don't see anything in the documentation regarding if/how attachments can be added to the email message if it is sent using sendEmailTo. Any help would be greatly appreciated. All my current plugin projects are hosted on GitHub, and I welcome anyone interested to fork them at their leisure :)

https://github.com/discgolfer1138/indigo_foscam
(the plugin mentioned above; wrapper for foscam webcam)

https://github.com/discgolfer1138/indigo_pushover
(wrapper for the Pushover API, allows you to send push notifications to mobile devices)

https://github.com/discgolfer1138/indigo_yamaharx
(wrapper for web api for Yamaha RX-series receivers)

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Mon Oct 01, 2012 5:09 pm
jay (support) offline
Site Admin
User avatar
Posts: 17640
Joined: Mar 19, 2008
Location: Austin, Texas

Re: adding attachments mail sent via indigo.server.sendEmail

We don't currently support attachments, though it is on the feature request list.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Oct 01, 2012 5:41 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

thanks for your quick response, Jay!

Is there any chance the app-wide email settings are accessible in some way. I figure until attachment support is available, I can still use my existing mail-sending methods but pull the smtp auth info from app config instead of requiring a separate plugin or action config...

here's a quick snippet of how I'm sending mail with attachements via smtplib:

Code: Select all
   def sendViaEmail(self, pluginAction, dev):
      subject = pluginAction.props['subject']
      recipient = pluginAction.props['recipient']

      # Create the container (outer) email message.
      msg = MIMEMultipart()
      msg['Subject'] = subject
      # me == the sender's email address
      # family = the list of all recipients' email addresses
      msg['From'] = sender
      msg['To'] = recipient
      msg.preamble = 'cam snap test'

      # Open the files in binary mode.  Let the MIMEImage class automatically
      # guess the specific image type.
      fp = open('/tmp/snap.jpg', 'rb')
      img = MIMEImage(fp.read())
      fp.close()
      msg.attach(img)

      # Send the email via our own SMTP server.
      sender = 'user@gmail.com'
      smtp_user = 'user@gmail.com'
      smtp_pass = 'passgoeshere'
      smtp_host = 'smtp.gmail.com'
      smtp_port = 587

      s = smtplib.SMTP(smtp_host,smtp_port)
      s.ehlo()
      s.starttls()
      s.ehlo
      s.login(smtp_user, smtp_pass)
      s.sendmail(sender, recipient, msg.as_string())
      s.quit()

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Mon Oct 01, 2012 5:51 pm
matt (support) offline
Site Admin
User avatar
Posts: 21118
Joined: Jan 27, 2003
Location: Texas

Re: adding attachments mail sent via indigo.server.sendEmail

Unfortunately, there are no APIs for retrieving that account settings. I'm not sure we would want to provide access to the password from an API. You can, of course, add plugin config UI for the SMTP settings.

What about saving the image to a Web server (you could even put it into the images or static folder of Indigo's built-in Web Server, I believe) and then including a link to that in the email? Although Indigo only supports plain text email, so you cannot inline the image in HTML which would be nice.

Image

Posted on
Mon Oct 01, 2012 7:30 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

I guess I'll have to go the plugin config route for now, no worries :)

the specific reason I'm trying to send an image as an email attachment is to facilitate Actions like:
- Post snapshot to Facebook: FB provides each user with a secret post-via-email address. All i have to do is send an email with an image attached to this address and it'll show up on my Facebook wall
- Send snapshot by MMS: certain carriers (like AT&T) let you send an MMS message to your phone via email like this: 3035551212@mms.att.net.

I have an IoLinc hooked up to my doorbell and an outdoor webcam pointed at the doorstep. With the aforementioned scenarios, I can then send a camera snap to my Facebook wall or as a picture msg to my phone whenever someone rings the doorbell. I have both of these things working now with an embedded python script, but I'd much prefer to roll this functionality into my Foscam plugin so others can enjoy it :)

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Mon Oct 01, 2012 7:32 pm
matt (support) offline
Site Admin
User avatar
Posts: 21118
Joined: Jan 27, 2003
Location: Texas

Re: adding attachments mail sent via indigo.server.sendEmail

discgolfer1138 wrote:
I have an IoLinc hooked up to my doorbell and an outdoor webcam pointed at the doorstep. With the aforementioned scenarios, I can then send a camera snap to my Facebook wall or as a picture msg to my phone whenever someone rings the doorbell

Very cool usage scenario.

Image

Posted on
Tue Oct 02, 2012 10:40 am
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

It certainly makes for some interesting photos... My wife threw a surprise b-day party for me on Sunday and insisted that everyone ring the doorbell on the way out. Here's a few of the 'safer' captures:

Image
Image

also good for random photos of food delivery personnel:
Image
Image

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Fri Jul 19, 2013 6:43 pm
colovin offline
Posts: 173
Joined: Oct 27, 2009

Re: adding attachments mail sent via indigo.server.sendEmail

This looks interesting. How do you install it? Do you drag the "indigo_foscam-master folder", into the "Library:Application Support:Perceptive Automation:Indigo 6:Plugins", folder?

Indigo 7.1.1, OS 10.14.6, MacMini .3.2 GHz 6 Intel Core i7, 64 GB ram

Posted on
Sun Sep 08, 2013 8:39 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

I found the easiest way is to clone the repo somewhere on your server and then symlink into your plugins folder:

Code: Select all
prompt# cd ~/username/Projects
prompt# git clone git@github.com:discgolfer1138/indigo-foscam.git
prompt# cd /Library/Application\ Support/Perceptive\ Automation/Indigo\ 6/Plugins
prompt# sudo ln -s /Users/username/Projects/indigo-foscam foscam.indigoPlugin


Note: be sure to that the name of the symlink uses the .indigoPlugin extension
**Note: the plugin is alpha (at best), I welcome any suggestions. Feel free to fork my repo and contribute!

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Tue Nov 19, 2013 2:55 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

Just released a new build of the foscam plugin with a bunch of new actions

https://github.com/discgolfer1138/indig ... /tag/0.1.1

The following actions are now supported:
Move Camera (up, down, left, right)
Stop Movement
Enable/Disable Streams
Activate/Deactivate Motion Alarm
Enable/Disable IR leds
Email Snapshot

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Wed Nov 20, 2013 5:29 pm
ckeyes888 offline
Posts: 2346
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: adding attachments mail sent via indigo.server.sendEmail

Just tried a F18904W that wouldn't work. Any chance of adding any more cams any time soon?

Thanks,

Carl

Posted on
Wed Nov 20, 2013 7:05 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

As long as the cgi endpoints are the same, it should support most of Foscam's mjpeg cams.

But, I have two fi8905e's installed at home and I can't imagine the fi8904w is much different. I'll test against those and get back to you.

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Sat Nov 30, 2013 3:25 am
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Re: adding attachments mail sent via indigo.server.sendEmail

ok, I have rewritten much of the plugin and tested that all the actions work. New release is now available!
https://github.com/discgolfer1138/indig ... /tag/1.0.0

note: Please uninstall any previous versions and remove any actions devices.. The release contains changes that are not backwards compatible (thus the major version)

@ckeyes888, let me know if this works for you! If not, please open an issue with any debugging info you may be able to provide here:
https://github.com/discgolfer1138/indigo-foscam/issues

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Posted on
Sat Nov 30, 2013 8:36 am
matt (support) offline
Site Admin
User avatar
Posts: 21118
Joined: Jan 27, 2003
Location: Texas

Re: adding attachments mail sent via indigo.server.sendEmail

Great -- thanks for sharing.

I just changed the title of the first post on this thread to "Foscam Plugin for Indigo" so it will be easier for folks to find it.

Image

Posted on
Mon Dec 09, 2013 5:17 pm
discgolfer1138 offline
User avatar
Posts: 45
Joined: Jul 28, 2011
Location: Golden, CO

Foscam Plugin - control/capture Foscam ip camera

Installation Instructions:
    Download latest release here
    Follow standard plugin installation process

Actions Supported:
    Move Camera (up, down, left, right)
    Go to or set preset position
    Stop Movement
    Enable/Disable Streams
    Activate/Deactivate Motion Alarm
    Enable/Disable IR leds
    Email Snapshot

States Exposed:
    X Position
    Y Position

Supported Cameras:
Due to differences in the cgi paths, this plugin does not yet support the 9000-series Foscam HD cameras at this time. (models FI9805E, FI9805W, FI9821W)

Huge thanks to Tim Hamer for his huge contributions to the newly-expanded list of supported actions!

The source code is available for collaboration on GitHub
Bugs can be reported here

Indigo 6.1.0 | Mac Mini | OS 10.10.3 (Yosemite)
Fork Me on GitHub!

Who is online

Users browsing this forum: No registered users and 1 guest