Foscam Plugin - control/capture Foscam ip camera
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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)
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)
- jay (support)
- Site Admin
- Posts: 18379
- Joined: Wed Mar 19, 2008 11:52 am
- Location: Austin, Texas
- Contact:
Re: adding attachments mail sent via indigo.server.sendEmail
We don't currently support attachments, though it is on the feature request list.
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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:
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()
- matt (support)
- Site Admin
- Posts: 21470
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
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.
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.
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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
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
- matt (support)
- Site Admin
- Posts: 21470
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
Re: adding attachments mail sent via indigo.server.sendEmail
Very cool usage scenario.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
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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:
also good for random photos of food delivery personnel:
also good for random photos of food delivery personnel:
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
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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:
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!
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: the plugin is alpha (at best), I welcome any suggestions. Feel free to fork my repo and contribute!
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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
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
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
Thanks,
Carl
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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.
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.
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
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
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
- matt (support)
- Site Admin
- Posts: 21470
- Joined: Mon Jan 27, 2003 1:17 pm
- Location: Texas
- Contact:
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.
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.
- discgolfer1138
- Posts: 45
- Joined: Thu Jul 28, 2011 10:56 pm
- Location: Golden, CO
- Contact:
Foscam Plugin - control/capture Foscam ip camera
Installation Instructions:
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
- Download latest release here
- 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
- X Position
- Y Position
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