element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog Forget_me_not : My Smart Home Post#6 Week-5 Smart Mailbox and doorbell with pi-camera
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ravi_butani
  • Date Created: 4 Sep 2014 9:59 AM Date Created
  • Views 433 views
  • Likes 0 likes
  • Comments 1 comment
  • forget_me_not
  • openhab
  • tektronix
  • enocean
  • raspberrypi
  • iot_homeauto
Related
Recommended

Forget_me_not : My Smart Home Post#6 Week-5 Smart Mailbox and doorbell with pi-camera

ravi_butani
ravi_butani
4 Sep 2014

Table of Contents

 

In my previous post Forget_me_not : My Smart Home Post#5 Week-4 Smart Mailbox with email and tweet support I have shared my basic build of smart mailbox with email and tweet support,

 

In this week I have received parts I have requested for "My Smarthome" initial phase build...

As now I have raspberry-pi camera, I have added one more feature to my smart doorbell application , That is with visitor image capturing when doorbell event is there , or take photograph of your door step to look around doorstep any time from openhab application with of course email and tweet support....

 

My demo.rules file..

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.openhab.binding.*
import org.openhab.action.*
import org.apache.commons.mail.*
import java.util.Date


var Number mail_count = 0
var Number visitor_count = 0


/** When system starts update all items with its default value */
rule "Initialization at system startup"
  when
  System started
  then
  postUpdate(No_new_mail, mail_count)
  postUpdate(No_visitor, visitor_count)
end


/**
* This rule sends email to home owner when doorbell switch pressed with photo as attachment
* here execute command line is just for demo it actually takes photo from PI Camera and save this image in specified folder
* So far I am waiting for PI camera so its not implemented
*/


rule "send mail doorbell"
  when
  Item EnOcean_switch received update ON
  then
  executeCommandLine("/opt/openhab/cam.sh")
  visitor_count=visitor_count+1
  postUpdate(Doorbell_tstamp, new DateTimeType())
  postUpdate(No_visitor, visitor_count)
  playSound("doorbell.mp3")
  var String tweet_doorbell="Doorbell:You have visitor at home (" + new Date + ")\nTotal visitor so far = " + visitor_count
  sendTweet(tweet_doorbell)
  sendMail("ravi.butani03@gmail.com", "My Smart Home (Doorbell)",tweet_doorbell +".\nOpen attachment to see latest visitor's image" ,"http://localhost:8080/doorcam/visitor.jpg")

end


rule "send mail manual image"
  when
  Item Send_pic_email received update ON
  then
  sendMail("ravi.butani03@gmail.com", "My Smart Home (Door image latest)"," Open attachment to see latest manually captured image at ("+ new Date +")" ,"http://localhost:8080/doorcam/man_pic.jpg")
  postUpdate(Send_pic_email, OFF)
end


rule "take manual image of door step"
  when
  Item Take_doorstep_pic received update ON
  then
  executeCommandLine("/opt/openhab/cam_manual.sh")
  postUpdate(Manual_tstamp, new DateTimeType())
  postUpdate(Take_doorstep_pic, OFF)
end


rule "reset visitor count"
  when
  Item Reset_visitor_count received update ON
  then
  visitor_count=0
  postUpdate(No_visitor, visitor_count)
  var String tweet_reset_visitor_count="Doorbell:You have Reset visitor count at (" + new Date + ")"
  sendTweet(tweet_reset_visitor_count)
  sendMail("ravi.butani03@gmail.com", "My Smart Home (Doorbell)", tweet_reset_visitor_count)
  postUpdate(Reset_visitor_count, OFF)

end


/**
* This rule sends email to home owner when new mail dropped in mail box
*/
rule "send mail update Mailbox "
  when
  Item EnOcean_contact changed from CLOSED to OPEN
  then
  mail_count=mail_count+1
  postUpdate(No_new_mail, mail_count)
  postUpdate(Mail_tstamp, new DateTimeType())
  var String tweet_mailbox="Mailbox : You have " + mail_count+" new mail. latest at (" +new Date + ")"
     sendTweet(tweet_mailbox)
  sendMail("ravi.butani03@gmail.com", "My Smart Home (Mailbox)" , tweet_mailbox)

end


rule "send mail collect Mailbox "
  when
  Item EnOcean_contact_collect changed from CLOSED to OPEN
  then
  mail_count=0
  postUpdate(No_new_mail, mail_count)
  postUpdate(Mail_tstamp, new DateTimeType())
  var String tweet_mailbox_collect="Mailbox : You have collected all mails at (" +new Date + ")"
     sendTweet(tweet_mailbox_collect)
  sendMail("ravi.butani03@gmail.com", "My Smart Home (Mailbox)" , tweet_mailbox_collect)

end

 

 

My demo.items file...

/* My Smart Home items */


Switch EnOcean_switch "Doorbell" <doorbell1> (enocean) {enocean="{id=00:17:D3:AD, eep=F6:02:01, channel=A, parameter=I}"}
Switch EnOcean_switch_B "DoorbellB" <doorbell1> (enocean) {enocean="{id=00:17:D3:AD, eep=F6:02:01, channel=B, parameter=I}"}
Number EnOcean_sensor_temp "Temperature [%.1f °C]" <temperature> (enocean) {enocean="{id=00:83:02:70, eep=A5:04:01, parameter=TEMPERATURE}"}
Number EnOcean_sensor_humd "Humidity [%.1f %%]" <humidity> (enocean) {enocean="{id=00:83:02:70, eep=A5:04:01, parameter=HUMIDITY}"}
Contact EnOcean_contact "MailBox [MAP(en.map):%s]" <mailbox> (enocean) {enocean="{id=00:83:4A:99, eep=D5:00:01, parameter=CONTACT_STATE"}
Contact EnOcean_contact_collect "MailBox collect [MAP(en.map):%s]" <mailbox> (enocean) {enocean="{id=00:82:B9:65, eep=D5:00:01, parameter=CONTACT_STATE"}






Switch Take_doorstep_pic "Capture image" <click>
Switch Send_pic_email "Send me image as email" <email>
Switch Reset_visitor_count "Reset Visitor count" <reset>
Number No_new_mail "Mailbox [%d New mails]" <mailbox>
Number No_visitor  "Latest Visitors  [%d Latest visitors]" <doorbell>
//String Arduino "Arduino [%s]" (arduino) {serial="/dev/ttyUSB0"}


/* Time stamp items */
DateTime Date "Date [%1$tA, %1$td.%1$tm.%1$tY]" <calendar>
DateTime Mail_tstamp "Mailbox last updated [%1$tA, %1$td.%1$tm.%1$tY, %1$tI:%1$tM %1$tp]" <clock1>
DateTime Doorbell_tstamp "Doorbell last updated [%1$tA, %1$td.%1$tm.%1$tY, %1$tI:%1$tM %1$tp]" <clock1>
DateTime Manual_tstamp "Latest image [%1$tA, %1$td.%1$tm.%1$tY, %1$tI:%1$tM %1$tp]" <clock1>


/* This portion will be used in application soon */
String UnknownDevices    "Unknown Devices in Range: [%s]" { bluetooth="?" }
Number NoOfPairedDevices "Paired Devices in Range: [%d]"  { bluetooth="!" }

 

my demo.sitemap file...

sitemap demo label="My Smart Home"
{
  Frame label="Latest events and parameters" {
  Text item=EnOcean_sensor_temp valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
  Text item=EnOcean_sensor_humd valuecolor=[>25="orange",>15="green",>5="orange",<=5="blue"]
  //Text item=Date
  Text item=No_new_mail valuecolor=[==0="blue",>=1="green",>5="orange"]
  Text item=Mail_tstamp
  Text item=No_visitor valuecolor=[==0="blue",>=1="green",>5="orange"]
  Text item=Doorbell_tstamp
  //Text item=Arduino
    }

  Frame label="Visitor and manual image captures" {
  Text label="Latest Doorbell image and setting" icon="doorbell1"{
  Switch item=Reset_visitor_count
  Text label="See latest Visitor image..." icon="video"{
  Frame label="Latest visitor image.." {
  Text item=Doorbell_tstamp
  Image url="http://localhost:8080/doorcam/visitor.jpg"  
  }
  }
  }
  Text label="Manual image capture and settings" icon="video"{
  Frame label="Capture and send via email" {
  Switch item=Take_doorstep_pic
  Switch item=Send_pic_email
  }
  Frame label="See Latest captured Image" {
  Text label="Latest Image and time" icon="video"{
  Frame label="Latest Image.." {
  Text item=Manual_tstamp
  Image url="http://localhost:8080/doorcam/man_pic.jpg" 
  }
  }

  }
  }
  }
}

 

This short video shows scripts for handle pi-camera and directories structure for image database with time stamp...

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Here are some pics of my openhab url...

image

<< Previous

Home

Next >>

  • Sign in to reply
  • vish
    vish over 11 years ago

    ??image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube